I wrote codes to add 'like' at the end of every 3 word in a nltk text as 
follows:

>>> text = nltk.corpus.brown.words(categories = 'news')
>>> def hedge(text):
        for i in range(3,len(text),4):
                new_text = text.insert(i, 'like')
        return new_text[:50]

>>> hedge(text)

Traceback (most recent call last):
  File "<pyshell#77>", line 1, in <module>
    hedge(text)
  File "<pyshell#76>", line 3, in hedge
    new_text = text.insert(i, 'like')
AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'

Isn't text in the brown corpus above a list? why doesn't it has attribute 
'insert'?

Thanks much for your hints.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to