2011-07-13 15 views
5
>>> c = t.concordance('president') 
Displaying 25 of 142 matches: 
of Hays , Kan. as the school's new president . Dr. Clark will succeed Dr. J. R. 
dollars , said C. Virgil Martin , president of Carson Pirie Scott & Co. , comm 
dants '' . Washington , July 24 -- president Kennedy today pushed aside other W 
ionwide television and radio . The president spent much of the week-end at his 
drafts '' . Salinger said the work president Kennedy , advisers , and members o 
miss them . Washington , Feb. 9 -- president Kennedy today proposed a mammoth n 
railroad retirement programs . The president , in a special message to Congress 
ged care plan , similar to one the president sponsored last year as a senator , 
or up to 240 days an illness . The president noted that Congress last year pass 
e medical and dental schools . The president said the nation's 92 medical and 4 
go up to 21 millions by 1966 . The president recommended federal `` matching gr 
community health services '' , the president called for doubling the present 10 
. In the child health field , the president said he will recommend later an in 
nstitute . Asks research funds The president said he will ask Congress to incre 
building research facilities . The president said he will also propose increasi 
ernment research in medicine . The president said his proposals combine the `` 
e (D. , Ore.) in connection with president Eisenhower's cabinet selections in 
r's cabinet selections in 1953 and president Kennedy's in 1961 . Oslo The most 
e was critical of what he feels is president Kennedy's tendency to be too conci 
cation . But he did recommend that president Kennedy state clearly that if Comm 
any observer would have said that president Kennedy had blended a program that 
nquency in the United States . The president is deeply concerned over this prob 
orities on juvenile problems . The president asks the support and cooperation o 
rime trend . Offenses multiply The president has also called upon the Attorney 
h the problem . Simultaneously the president announced Thursday the appointment 
>>> print c 
None 

लेकिन मैं इसे एक चर में सेट नहीं कर सकता ... मैं इसे एक चर में सेट करने में सक्षम होना चाहता हूं ताकि मैं इसके साथ सामान कर सकूं।एनएलटीके में, मैं एक पाठ की समरूपता कैसे प्राप्त करूं?

उत्तर

5

कोड आप कॉल कर रहे nltk/nltk/text.py में है, और लगता है कि:

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) 

तो तुम एक ConcordanceIndex खुद बनाते हैं, और फिर भी आप करना चाहते हैं यह हेरफेर करने के लिए सक्षम होना चाहिए। ConcordanceIndex क्लास the same file में है, और इसमें print_concordance के लिए कोड शामिल है, जो शायद शुरू करने के लिए एक अच्छी जगह है।

+1

उत्तर को पूरा करने के लिए: t._concordance_index में कॉनकॉर्डेंस इंडेक्स ऑब्जेक्ट है जो ओपी के साथ सामान करना चाहता है। –

संबंधित मुद्दे