pke_ja / fn.py
aka7774's picture
Upload 6 files
6dda94e verified
raw
history blame contribute delete
421 Bytes
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])