Hey there,
The question here: what type of an object is "text" here? If it's a
list of strings, then you're set, but if it's a
ConcatenatedCorpusView, then apparently that won't work! Can you get a
list of words out of your text before passing it to your hedge
function?
On Sun, Sep 2, 2012 at 12:37 AM, typetoken <
type...@gmail.com> wrote:
> I want to insert 'like' at the end of every other 3 words in a text. Then I
> use the method of insert as follows:
>
>>>> 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'
>
> Quite puzzled? Isn't text here a list? Why doesn't it has the method insert?
>
> Then I test insert as follows. It did exist in python.
>>>> text = ['The', 'Fulton', 'County', 'Grand']
>>>> text.insert(3,'like')
>>>> text
> ['The', 'Fulton', 'County', 'like', 'Grand']
>
> Thanks very much.
--
-- alexr