2016-12-14 7 views
0

一致を見つけるのにNLTKを使用していますが、すべての結果を得る方法が見つかりません&リストまたはセットに入れてください。すべての結果を取得frm NLTKの一致

ex :text.concordance(word) 
PRINT just the 25 first results 

答えて

2

TL; DR

text.concordance(lines=100) 
コードから

https://github.com/nltk/nltk/blob/develop/nltk/text.py#L323

def concordance(self, word, width=79, lines=25): 
    """ 
    Print a concordance for ``word`` with the specified context window. 
    Word matching is not case-sensitive. 
    :seealso: ``ConcordanceIndex`` 
    """ 
    if '_concordance_index' not in self.__dict__: 
     #print("Building index...") 
     self._concordance_index = ConcordanceIndex(self.tokens, 
                key=lambda s:s.lower()) 

    self._concordance_index.print_concordance(word, width, lines) 
関連する問題