Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'attribute': 0.05; 'attributes': 0.07; 'interpreter.': 0.07; 'list?': 0.07; "subject:' ": 0.07; 'docstrings': 0.09; 'subject:method': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'hedge': 0.16; 'list),': 0.16; 'subject:object': 0.16; 'wrote:': 0.17; '(or': 0.18; 'bit': 0.21; '"",': 0.22; 'cc:2**0': 0.23; 'mention': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'wrote': 0.26; 'skip:" 20': 0.26; '(most': 0.27; 'am,': 0.27; 'in.': 0.27; "doesn't": 0.28; '>>>>': 0.29; 'words': 0.29; 'error': 0.30; 'file': 0.32; "skip:' 20": 0.32; 'print': 0.32; 'docs': 0.33; 'traceback': 0.33; 'text': 0.34; 'list': 0.35; 'follows:': 0.35; 'generic': 0.35; 'text.': 0.35; 'so,': 0.35; 'add': 0.36; 'really': 0.36; 'but': 0.36; "didn't": 0.36; 'subject:with': 0.36; 'why': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'received:192': 0.39; 'list,': 0.39; 'received:192.168': 0.40; 'end': 0.40; 'think': 0.40; 'your': 0.60; 'telling': 0.61; 'free': 0.61; 'skip:n 10': 0.63; 'brown': 0.65; 'header:Reply-To:1': 0.68; 'skip:n 30': 0.69; 'online': 0.70; 'subject:The': 0.71; 'acts': 0.71; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'subjectcharset:utf-8': 0.72; "'like'": 0.84 Date: Sun, 02 Sep 2012 07:10:29 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Token Type Subject: =?UTF-8?B?UmU6IFRoZSBtZXRob2Qgb2YgaW5zZXJ0IGRvZXNuJ3Qgd29yayB3aXQ=?= =?UTF-8?B?aCBubHRrIHRleHRzOuOAgEF0dHJpYnV0ZUVycm9yOiAnQ29uY2F0ZW5hdGVkQ28=?= =?UTF-8?B?cnB1c1ZpZXcnIG9iamVjdCBoYXMgbm8gYXR0cmlidXRlICdpbnNlcnQn?= References: <58dd6730-9c37-4b90-9dbc-2724300ff5f4@googlegroups.com> In-Reply-To: <58dd6730-9c37-4b90-9dbc-2724300ff5f4@googlegroups.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:WTOQX7hE38+/VhB+Fk4cEv+nHAzNUf+mghVmra6WxYm JgdYutDwgnLcS9LkvXuDfw3Qe6O6c1lQcyL1hkmVOCOOR4a7Id VAN8NVRO2HmJdek94pTjp3PFunNojJzaTfixYwTsoh3kgeCyFc 0GRoMzOxoa3tGZPKbTZS2+AI2kVVRq2lGnQA14D3bpxJS/e65M cCCkcvese76LDDc2kbwXYgzV+hNgCHWoNpW6hP4nUAG+eEyJdu 3qblOwt/Hf6JArR/dxlRKj/f24VtA0OlGwF/3jY6D/v5UnPRnf 6ndiU2IvY92YWpQH0K9+TEJ1ERh99Qcqi1yzzveT5jXWBYIRw= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346584263 news.xs4all.nl 6868 [2001:888:2000:d::a6]:57278 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28263 On 09/02/2012 05:39 AM, Token Type wrote: > 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 "", line 1, in > hedge(text) > File "", 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'? > I tried to find online documentation for nltk, and although I found the mention of a free online book, I didn't see it. So, some generic comments. The error message is telling you that the object 'text' is not a list, but a "ConcatenatedCorpusView". Perhaps you can look that up in your docs for nltk. But there's quite a bit you can do just with the interpreter. try print type(text) to see the type of text. try dir(text) to see what attributes it has try help(text) to see what docstrings might be built in. Incidentally, if you really think it's a list of words (or that it acts like a list), then 'text' might not be the best name for it. Any reason you didn't just call it words ? -- DaveA