中日形态分析仪(分词器+词性标记器)

rakutenma的Python项目详细描述


乐天麻蟒

travis-ci.orgcoveralls.iopyversionlatest versionCode Healthlicense

Rakuten MA Python(形态分析器)是Rakuten MA(word segmentor+PoS Tagger)的Python版本,用于中文和日语

有关Rakuten MA的详细信息,请参见https://github.com/rakuten-nlp/rakutenma

另见http://qiita.com/yukinoi/items/925bc238185aa2fad8a7(日语)

欢迎投稿!

安装

pip install rakutenma

示例

fromrakutenmaimportRakutenMA# Initialize a RakutenMA instance with an empty model# the default ja feature set is set alreadyrma=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/rakutenmaimportjsontatoeba=json.load(open("tatoeba.json"))foriintatoeba:rma.train_one(i)# Now what does the result look like?print(rma.tokenize("彼は新しい仕事できっと成功するだろう。"))# Initialize a RakutenMA instance with a pre-trained modelrma=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 sentenceprint(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 updatedprint(res)# Now what does the result look like?print(rma.tokenize("うらにわにはにわにわとりがいる"))

添加了api

与原乐天相比,增加了以下方法:

  • RakutenMA::加载(模型路径) -从json文件加载模型
  • rakutenma::save(模型路径) -将模型保存到路径

其他

作为初始设置,将设置以下值:

  • rma.featset=CTYPE_JA_PATTERNS#RakutenMA.default_featset_JA
  • rma.hash_func=rma.create_hash_func(15个)
  • rma.tag_scheme=“sbieo”如果使用中文,请设置“iob2”

许可证

apache许可证2.0版

更改

0.3.3(2017-05-22)

  • 关于培训的错误修复

0.3.2(2017-02-01)

  • 尽可能使用ujson
  • 启用POS到MECAB样式
  • 支持Python3.5和3.6

0.3(2016-04-10)

  • 加上崔(乐天)

0.2.2(2016-04-09)

  • 捆绑模型文件(model_ja.json、model_ja_min.json)
  • 支持Windows

0.2(2015-01-10)

  • 支持Python2.6和2.7

0.1.1(2015-01-08)

  • 性能略有提高

0.1(2015-01-01)

  • 第一次释放。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java FloatingAction按钮与RecyclerView中的CardView重叠   java如何计算CardLayout中的卡数   从远程系统上传MySQL数据库并访问Java应用程序   java调用堆栈如何处理带或不带返回类型的递归?   Springboot中的java组计数聚集   java如何在javafx textarea中使用richtextfx   获取与Mockito相关的错误时出现Java问题   java如何将JaxRS响应转换为Wiremock响应   Hadoop集群java。net ConnectionException:连接被拒绝错误   java如何加载文件私有文件类型是pem   java在元空间中的提升和加载的类   如何将系统属性传递给从HTML启动的Java小程序   java如何从网页中获取值并在主类中使用它?安卓应用   java在春天,advisor和aspect之间有什么区别?   java如何检测文件是否已重命名?   java消息驱动Bean何时使用