Rakuten MA Python
Rakuten MA Python (morphological analyzer) is a Python version of Rakuten MA (word segmentor + PoS Tagger) for Chinese and Japanese.
For details about Rakuten MA, See https://github.com/rakuten-nlp/rakutenma
See also http://qiita.com/yukinoi/items/925bc238185aa2fad8a7 (In Japanese)
Contributions are welcome!
Installation
pip install rakutenma
Example
from rakutenma import RakutenMA
# Initialize a RakutenMA instance with an empty model
# the default ja feature set is set already
rma = RakutenMA()
# Let's analyze a sample sentence (from http://tatoeba.org/jpn/sentences/show/103809)
# With a disastrous result, since the model is empty!
print(rma.tokenize("彼は新しい仕事できっと成功するだろう。"))
# Feed the model with ten sample sentences from tatoeba.com
# "tatoeba.json" is available at https://github.com/rakuten-nlp/rakutenma
import json
tatoeba = json.load(open("tatoeba.json"))
for i in tatoeba:
rma.train_one(i)
# Now what does the result look like?
print(rma.tokenize("彼は新しい仕事できっと成功するだろう。"))
# Initialize a RakutenMA instance with a pre-trained model
rma = RakutenMA(phi=1024, c=0.007812) # Specify hyperparameter for SCW (for demonstration purpose)
rma.load("model_ja.json")
# Set the feature hash function (15bit)
rma.hash_func = rma.create_hash_func(15)
# Tokenize one sample sentence
print(rma.tokenize("うらにわにはにわにわとりがいる"));
# Re-train the model feeding the right answer (pairs of [token, PoS tag])
res = rma.train_one(
[["うらにわ","N-nc"],
["に","P-k"],
["は","P-rj"],
["にわ","N-n"],
["にわとり","N-nc"],
["が","P-k"],
["いる","V-c"]])
# The result of train_one contains:
# sys: the system output (using the current model)
# ans: answer fed by the user
# update: whether the model was updated
print(res)
# Now what does the result look like?
print(rma.tokenize("うらにわにはにわにわとりがいる"))
NOTE
Added API
As compared to original RakutenMA, following methods are added:
RakutenMA::load(model_path) - Load model from JSON file
RakutenMA::save(model_path) - Save model to path
misc
As initial setting, following values are set:
rma.featset = CTYPE_JA_PATTERNS # RakutenMA.default_featset_ja
rma.hash_func = rma.create_hash_func(15)
rma.tag_scheme = “SBIEO” # if using Chinese, set “IOB2”
LICENSE
Apache License version 2.0
Copyright
Rakuten MA Python (c) 2015- Yukino Ikegami. All Rights Reserved.
Rakuten MA (original) (c) 2014 Rakuten NLP Project. All Rights Reserved.
CHANGES
0.3.3 (2017-05-22)
Bug fix about training
0.3.2 (2017-02-01)
Use ujson when possible
Enable POS to MeCab style
Support Python 3.5 and 3.6
0.3 (2016-04-10)
Add CUI ($ rakutenma)
0.2.2 (2016-04-09)
Bundle model files (model_ja.json, model_ja_min.json)
Support Windows
0.2 (2015-01-10)
Support Python 2.6 and 2.7
0.1.1 (2015-01-08)
Slightly improve performance
0.1 (2015-01-01)
First release.
Metadata
Release files for rakutenma 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rakutenma-0.3.3.tar.gz | 25.0 MB | Without provenance | Details for rakutenma-0.3.3.tar.gz |
Release files / rakutenma-0.3.3.tar.gz
| Download URL | rakutenma-0.3.3.tar.gz |
|---|---|
| Size | 25.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ee2ffe6cf93d7dae805f7e0e1971ef6a40f724a72e92d4de4f498097f776773
|
|
BLAKE2b-256 checksum How to use checksums |
b753e2c622a87a70a8f271b8bf8d62147366f619cad41e3ecbb21e4c6acdc540
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for rakutenma 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.