File size: 421 Bytes
6dda94e |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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])
|