tsroten / pynlpir

A Python wrapper around the NLPIR/ICTCLAS Chinese segmentation software.
MIT License
561 stars 135 forks source link

get_key_words #109

Open lena9017 opened 6 years ago

lena9017 commented 6 years ago

About pynlpir.get_key_words(s,w), can I specify the type of output like jieba does. For example only get the noun keywords. "jieba.analyse.extract_tags(s, topK = 10, withWeight = False, allowPOS = ('n'))"

joenahm commented 2 years ago

yes你可以,但又不完全可以,就是最后的通过词性过滤 pynlpir 是没有的,不过你可以自己手动过滤 以下内容来自pynlpir的文档(https://pynlpir.readthedocs.io/en/latest/api.html#pynlpir.get_key_words):

pynlpir.get_key_words(s, max_words=50, weighted=False)

Determines key words in Chinese text s.

The key words are returned in a list. If weighted is True, then each list item is a tuple: (word, weight), where weight is a float. If it’s False, then each list item is a string.

This uses the function GetKeyWords() to determine the key words in s.

Parameters:

    s – The Chinese text to analyze. s should be Unicode or a UTF-8 encoded string.
    max_words (int) – The maximum number of key words to find (defaults to 50).
    weighted (bool) – Whether or not to return the key words’ weights (defaults to True).