import os | |
import pke | |
from spacy.lang import ja | |
def fn_pke(text, n=10): | |
extractor = pke.unsupervised.MultipartiteRank() | |
extractor.load_document(input=text, language='ja', normalization=None) | |
extractor.candidate_selection(pos={'NOUN', 'PROPN', 'ADJ', 'NUM'}) | |
extractor.candidate_weighting(threshold=0.74, method='average') | |
res = extractor.get_n_best(n=n) | |
return "\n".join([k for k, v in res]) | |