Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion The Method of Insert doesn't work. AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert'
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Steven Bird  
View profile  
 More options Sep 2 2012, 10:18 pm
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'))

-Steven Bird

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')
>>>> def hedge(text):
> for i in range(0, len(text),3):
> text.insert(i,'like')

>>>> hedge(text)

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

> Further more, I test the function of insert. It did work as follows:

>>>> text = ['The', 'Fulton', 'County', 'Grand']
>>>> text.insert(3,'like')
>>>> text
> ['The', 'Fulton', 'County', 'like', '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.