Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'operator': 0.03; 'syntax': 0.04; 'elif': 0.05; 'subject:Python': 0.06; 'element': 0.07; 'problem?': 0.07; 'subject:Error': 0.07; 'none)': 0.09; 'statements': 0.09; 'suggestions.': 0.09; 'to:addr:comp.lang.python': 0.09; 'valueerror:': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'expression.': 0.16; 'guessing': 0.16; 'interpreter,': 0.16; 'statement.': 0.16; 'traceback.': 0.16; 'url:tag': 0.16; 'alpha': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'file,': 0.19; 'thanks.': 0.20; 'help.': 0.21; '>>>': 0.22; 'issue.': 0.22; 'putting': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; "aren't": 0.24; 'interpret': 0.24; 'url:moin': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'skip:" 40': 0.26; 'post': 0.26; 'skip:_ 20': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'array': 0.29; 'room': 0.29; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'posting': 0.31; 'url:wiki': 0.31; '"",': 0.31; 'probability': 0.31; 'file': 0.32; 'run': 0.32; 'text': 0.33; 'url:python': 0.33; 'running': 0.33; '(most': 0.33; 'checking': 0.33; 'could': 0.34; 'display': 0.35; 'skip:s 30': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'like,': 0.36; 'sequence': 0.36; 'skip:" 50': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'list': 0.37; 'email addr:python.org': 0.37; 'pm,': 0.38; 'previous': 0.38; 'recent': 0.39; 'how': 0.40; 'dave': 0.60; 'solve': 0.60; 'from:no real name:2**0': 0.61; 'forum': 0.61; 'url:5': 0.61; 'full': 0.61; 'kindly': 0.61; "you're": 0.61; 'address': 0.63; 'email addr:gmail.com': 0.63; 'show': 0.63; 'kind': 0.63; 'group,': 0.63; 'more': 0.64; 'different': 0.65; 'dear': 0.65; 'email name:python- list': 0.65; 'sample': 0.67; 'url:0': 0.67; 'manner.': 0.74; 'truth': 0.81; "'and'": 0.84; '3.8': 0.84; 'confusing': 0.84; 'fragments': 0.84; 'angel': 0.91; '2013': 0.98 X-Received: by 10.49.130.7 with SMTP id oa7mr1330610qeb.12.1365282837269; Sat, 06 Apr 2013 14:13:57 -0700 (PDT) Newsgroups: comp.lang.python Date: Sat, 6 Apr 2013 14:13:57 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=122.161.41.166; posting-account=6SonuQoAAACzSakS5dCECcJQe6ylLrzY References: <8dd5cddd-792a-489f-bc1a-46026a227aa8@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 122.161.41.166 MIME-Version: 1.0 Subject: Re: Error in Python NLTK From: subhabangalore@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 107 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365282845 news.xs4all.nl 6949 [2001:888:2000:d::a6]:60713 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42948 On Sunday, April 7, 2013 2:14:41 AM UTC+5:30, Dave Angel wrote: > On 04/06/2013 03:56 PM, subhabangalore@gmail.com wrote: >=20 > > Dear Group, >=20 > > >=20 > > I was using a package named NLTK in Python. >=20 > > >=20 > > I was trying to write a code given in section 3.8 of >=20 > > >=20 > > http://docs.huihoo.com/nltk/0.9.5/guides/tag.html. >=20 > > >=20 > > Here, in the >>> test =3D ['up', 'down', 'up'] if I put more than 3 val= ues and trying to write the reciprocal codes, like, >=20 > > >=20 > > sequence =3D [(t, None) for t in test] and print '%.3f' % = (model.probability(sequence)) >=20 >=20 >=20 > This 'and' operator is going to try to interpret the previous list as a= =20 >=20 > boolean. Could that be your problem? Why aren't you putting these two= =20 >=20 > statements on separate lines? And what version of Python are you using?= =20 >=20 > If 2.x, you should get a syntax error because print is a statement.=20 >=20 > If 3.x, you should get a different error because you don't put parens=20 >=20 > around the preint expression. >=20 >=20 >=20 > > >=20 > > I am getting an error as, >=20 > > >=20 > > Traceback (most recent call last): File "", line 1, in model.probabilit= y(sequence) File "C:\Python27\lib\site-packages\nltk\tag\hmm.py", line 228,= in probability return 2**(self.log_probability(self._transform.transform(s= equence))) File "C:\Python27\lib\site-packages\nltk\tag\hmm.py", line 259, = in log_probability alpha =3D self._forward_probability(sequence) File "C:\P= ython27\lib\site-packages\nltk\tag\hmm.py", line 694, in _forward_probabili= ty alpha[0, i] =3D self._priors.logprob(state) + \ File "C:\Python27\lib\si= te-packages\nltk\probability.py", line 689, in logprob elif self._prob_dict= [sample] =3D=3D 0: return _NINF ValueError: The truth value of an array wit= h more than one element is ambiguous. Use a.any() or a.all() >=20 > > >=20 > > If any learned member may kindly assist me how may I solve the issue. >=20 > > >=20 >=20 >=20 > Your error display has been trashed, thanks to googlegroups. >=20 > http://wiki.python.org/moin/GoogleGroupsPython >=20 > Try posting with a text email message, since this is a text forum. >=20 >=20 >=20 > Your code is also sparse. Why do you point us to fragments on the net,= =20 >=20 > when you could show us the exact code you were running when it failed?=20 >=20 > I'm guessing you're running it from the interpreter, which can be very=20 >=20 > confusing once you have to ask for help. Please put a sample of code=20 >=20 > into a file, run it, and paste into your text email both the contents of= =20 >=20 > that file and the full traceback. thanks. >=20 >=20 >=20 > The email address to post on this forum is python-list@python.org >=20 >=20 >=20 >=20 >=20 > --=20 >=20 > DaveA Thanks Dave for your kind suggestions. I am checking on them and if I get a= ny questions I am sending the room in detailed manner. Regards,Subhabrata.