From: Steven Bird <stevenbi...@gmail.com>
Date: Mon, 3 Sep 2012 12:18:37 +1000
Local: Sun, Sep 2 2012 10:18 pm
Subject: Re: [nltk-users] The Method of Insert doesn't work. AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'
The problem here is that you are trying to access an NLTK corpus
object as if it was a list object. However, you can convert it to a
list like this:
text = list(nltk.corpus.brown.words(categories = 'news'))
On 2 September 2012 14:32, typetoken <typeto...@gmail.com> wrote:
> I want to add 'like' at the end of every other 3 words in a text. Then I
> try to use insert as follows. However, it told me that "AttributeError:
> 'ConcatenatedCorpusView' object has no attribute 'insert'". Quite puzzled?
> Isn't text a list here? If it is a list, why doesn't not insert work here?
>>>> text = nltk.corpus.brown.words(categories = 'news')
> Traceback (most recent call last):
> Further more, I test the function of insert. It did work as follows:
>>>> text = ['The', 'Fulton', 'County', 'Grand']
> Thanks for your instructions!
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.