2016-12-14 2 views

ответ

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) 
Смежные вопросы