nagisa
v0.2.11

Nagisa是用于日语单词分割/pos-tagging的Python模块。它被设计为一种简单易用的工具。
该工具具有以下功能。
有关更多详细信息,请参阅以下链接。
要使用Nagisa,您需要在Linux上使用Python版本3.6至3.12,或MacOS上的Python版本3.9至3.12(Intel或M1/M2)。您可以使用以下命令安装nagisa。
pip install nagisa对于Windows用户,请使用Python 3.6、3.7或3.8(64位)运行它。它也与Linux(WSL)的Windows子系统兼容。
单词分割的样本和日语的POS标记。
import nagisa
text = 'Pythonで簡単に使えるツールです'
words = nagisa . tagging ( text )
print ( words )
#=> Python/名詞 で/助詞 簡単/形状詞 に/助動詞 使える/動詞 ツール/名詞 です/助動詞
# Get a list of words
print ( words . words )
#=> ['Python', 'で', '簡単', 'に', '使える', 'ツール', 'です']
# Get a list of POS-tags
print ( words . postags )
#=> ['名詞', '助詞', '形状詞', '助動詞', '動詞', '名詞', '助動詞']通过特定的POS标签过滤和extarct单词。
# Filter the words of the specific POS tags.
words = nagisa . filter ( text , filter_postags = [ '助詞' , '助動詞' ])
print ( words )
#=> Python/名詞 簡単/形状詞 使える/動詞 ツール/名詞
# Extarct only nouns.
words = nagisa . extract ( text , extract_postags = [ '名詞' ])
print ( words )
#=> Python/名詞 ツール/名詞
# This is a list of available POS-tags in nagisa.
print ( nagisa . tagger . postags )
#=> ['補助記号', '名詞', ... , 'URL']以简单的方式添加用户字典。
# default
text = "3月に見た「3月のライオン」"
print ( nagisa . tagging ( text ))
#=> 3/名詞 月/名詞 に/助詞 見/動詞 た/助動詞 「/補助記号 3/名詞 月/名詞 の/助詞 ライオン/名詞 」/補助記号
# If a word ("3月のライオン") is included in the single_word_list, it is recognized as a single word.
new_tagger = nagisa . Tagger ( single_word_list = [ '3月のライオン' ])
print ( new_tagger . tagging ( text ))
#=> 3/名詞 月/名詞 に/助詞 見/動詞 た/助動詞 「/補助記号 3月のライオン/名詞 」/補助記号Nagisa(V0.2.0+)为联合单词分割和序列标记(例如,POS-TAGGING,NER)模型提供了一种简单的火车方法。
火车/开发/测试文件的格式为TSV。每行都是word和tag ,一行由word t(tab) tag表示。请注意,您将EOS放在句子之间。请参阅示例数据集和教程(训练通用依赖性的模型)。
$ cat sample.train
唯一 NOUN
の ADP
趣味 NOU
は ADP
料理 NOUN
EOS
とても ADV
おいしかっ ADJ
た AUX
です AUX
。 PUNCT
EOS
ドル NOUN
は ADP
主要 ADJ
通貨 NOUN
EOS
# After finish training, save the three model files (*.vocabs, *.params, *.hp).
nagisa . fit ( train_file = "sample.train" , dev_file = "sample.dev" , test_file = "sample.test" , model_name = "sample" )
# Build the tagger by loading the trained model files.
sample_tagger = nagisa . Tagger ( vocabs = 'sample.vocabs' , params = 'sample.params' , hp = 'sample.hp' )
text = "福岡・博多の観光情報"
words = sample_tagger . tagging ( text )
print ( words )
#> 福岡/PROPN ・/SYM 博多/PROPN の/ADP 観光/NOUN 情報/NOUN