Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28253
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2012-09-02 02:39 -0700 |
| Message-ID | <58dd6730-9c37-4b90-9dbc-2724300ff5f4@googlegroups.com> (permalink) |
| Subject | The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert' |
| From | Token Type <typetoken@gmail.com> |
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.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert' Token Type <typetoken@gmail.com> - 2012-09-02 02:39 -0700 Re: The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert' Dave Angel <d@davea.name> - 2012-09-02 07:10 -0400 Re: Fwd: The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert' Dave Angel <d@davea.name> - 2012-09-02 09:51 -0400 Re: The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert' Peter Otten <__peter__@web.de> - 2012-09-02 16:12 +0200
csiph-web