2020-05-20から1日間の記事一覧

言語処理100本ノック2020(python)備忘録40-49

まずはcabochaをインストール $cabocha -f1 neko.txt>neko.txt.cabocha を実行。-f1をオプションでつけた。 * 0 -1D 0/0 0.000000 一 名詞,数,*,*,*,*,一,イチ,イチ EOS EOS * 0 2D 0/0 -0.764522 記号,空白,*,*,*,*, , , * 1 2D 0/1 -0.764522 吾輩 名詞,代…

言語処理100本ノック2020(python)備忘録30-39

30 まずはmecabを使って $ mecab neko.txt > neko.txt.mecab を実行します。mecabのインストールは読者が頑張ってください。 word_array = [] with open('neko.txt.mecab') as r: r_lines = r.read() r_test = r_lines.splitlines() r_test_1bun = r_test[4:…

言語処理100本ノック2020(python)備忘録20-29

20 import gzip import json country_dict_list = [] with gzip.open('jawiki-country.json.gz', 'rt') as r: data = r.readlines() for line in data: country_dict_list.append(json.loads(line)) for line_dict in country_dict_list: if line_dict['titl…