Пример #1
0
from knock30 import neko_mecab

list_mecab = []

for line in neko_mecab():
    list_mecab.append(line)

for i, line in enumerate(list_mecab):
    if line['surface'] == 'の':
        if list_mecab[i - 1]['pos'] == '名詞' and list_mecab[i +
                                                           1]['pos'] == '名詞':
            print(list_mecab[i - 1]['surface'] + line['surface'] +
                  list_mecab[i + 1]['surface'])
Пример #2
0
from collections import defaultdict
from knock30 import neko_mecab
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

words_mecab = defaultdict(lambda:0)
count_of_words = 0
l = []
n = []
for line in neko_mecab():
    for word in line['surface']:
        if word not in words_mecab: count_of_words += 1
        words_mecab[word] += 1

for key, value in reversed(sorted(words_mecab.items(), key=lambda x:x[1])):
    l.append(value)
    n.append(key)
print(l)
plt.hist(l,50, range=(1,50))
plt.show()