
Nagisa é um módulo Python para segmentação de palavras japonesa/margem de POS. Ele foi projetado para ser uma ferramenta simples e fácil de usar.
Esta ferramenta possui os seguintes recursos.
Para mais detalhes, consulte os links a seguir.
Para usar o NAGISA, você precisa ter as versões Python 3.6 a 3.12 no Linux, ou versões Python 3.9 a 3.12 no macOS (Intel ou M1/M2). Você pode instalar Nagisa com o seguinte comando.
pip install nagisaPara usuários do Windows, execute -o com o Python 3.6, 3,7 ou 3,8 (64 bits). Também é compatível com o subsistema Windows para Linux (WSL).
Amostra de segmentação de palavras e marque de POS para japonês.
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 )
#=> ['名詞', '助詞', '形状詞', '助動詞', '動詞', '名詞', '助動詞']Filtre e exalte as palavras pelas tags POS específicas.
# 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']Adicione o dicionário de usuário de maneira fácil.
# 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月のライオン/名詞 」/補助記号O NAGISA (v0.2.0+) fornece um método de trem simples para um modelo de segmentação de palavras e marcação de sequência de palavras juntas (por exemplo, margem de posse, NER).
O formato dos arquivos de trem/dev/teste é TSV. Cada linha é word e tag e uma linha é representada pela tag word t (tab). Observe que você coloca EOS entre frases. Consulte os conjuntos de dados de amostra e tutorial (treine um modelo para dependências universais).
$ 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