Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43027

Re: Error in Python NLTK

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <subhabangalore@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*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; 'to:addr:comp.lang.python': 0.09; 'valueerror:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'angle': 0.16; 'expression.': 0.16; 'guessing': 0.16; 'interpreter,': 0.16; 'statement.': 0.16; 'traceback.': 0.16; 'url:tag': 0.16; 'alpha': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'trying': 0.19; 'file,': 0.19; 'thanks.': 0.20; 'help.': 0.21; '>>>': 0.22; 'input': 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; 'generally': 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; 'monday,': 0.33; 'could': 0.34; 'problem': 0.35; 'display': 0.35; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'skip:s 30': 0.35; 'test': 0.35; 'but': 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; 'error.': 0.37; 'wrong': 0.37; 'two': 0.37; 'list': 0.37; 'email addr:python.org': 0.37; 'received:209': 0.37; 'issue': 0.38; '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; 'you.': 0.62; 'making': 0.63; 'address': 0.63; 'email addr:gmail.com': 0.63; 'show': 0.63; 'soon': 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; 'sir,': 0.81; '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.82.134 with SMTP id i6mr1463660qey.20.1365372696648; Sun, 07 Apr 2013 15:11:36 -0700 (PDT)
Newsgroups comp.lang.python
Date Sun, 7 Apr 2013 15:11:36 -0700 (PDT)
In-Reply-To <mailman.254.1365366047.3114.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=122.161.87.32; posting-account=6SonuQoAAACzSakS5dCECcJQe6ylLrzY
References <8dd5cddd-792a-489f-bc1a-46026a227aa8@googlegroups.com> <mailman.209.1365281115.3114.python-list@python.org> <mailman.254.1365366047.3114.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 122.161.87.32
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.259.1365372704.3114.python-list@python.org> (permalink)
Lines 214
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365372704 news.xs4all.nl 6974 [2001:888:2000:d::a6]:52163
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43027

Show key headers only | View raw


On Monday, April 8, 2013 1:50:38 AM UTC+5:30, subhaba...@gmail.com wrote:
> 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:
> 
> > 
> 
> > > Dear Group,
> 
> > 
> 
> > >
> 
> > 
> 
> > > I was using a package named NLTK in Python.
> 
> > 
> 
> > >
> 
> > 
> 
> > > I was trying to write a code given in section 3.8 of
> 
> > 
> 
> > >
> 
> > 
> 
> > > http://docs.huihoo.com/nltk/0.9.5/guides/tag.html.
> 
> > 
> 
> > >
> 
> > 
> 
> > > Here, in the >>> test = ['up', 'down', 'up'] if I put more than 3 values and trying to write the reciprocal codes, like,
> 
> > 
> 
> > >
> 
> > 
> 
> > >              sequence = [(t, None) for t in test] and print '%.3f' % (model.probability(sequence))
> 
> > 
> 
> > 
> 
> > 
> 
> > This 'and' operator is going to try to interpret the previous list as a 
> 
> > 
> 
> > boolean.  Could that be your problem?  Why aren't you putting these two 
> 
> > 
> 
> > statements on separate lines?  And what version of Python are you using? 
> 
> > 
> 
> >   If 2.x, you should get a syntax error because print is a statement. 
> 
> > 
> 
> > If 3.x, you should get a different error because you don't put parens 
> 
> > 
> 
> > around the preint expression.
> 
> > 
> 
> > 
> 
> > 
> 
> > >
> 
> > 
> 
> > > I am getting an error as,
> 
> > 
> 
> > >
> 
> > 
> 
> > > Traceback (most recent call last): File "", line 1, in model.probability(sequence) File "C:\Python27\lib\site-packages\nltk\tag\hmm.py", line 228, in probability return 2**(self.log_probability(self._transform.transform(sequence))) File "C:\Python27\lib\site-packages\nltk\tag\hmm.py", line 259, in log_probability alpha = self._forward_probability(sequence) File "C:\Python27\lib\site-packages\nltk\tag\hmm.py", line 694, in _forward_probability alpha[0, i] = self._priors.logprob(state) + \ File "C:\Python27\lib\site-packages\nltk\probability.py", line 689, in logprob elif self._prob_dict[sample] == 0: return _NINF ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
> 
> > 
> 
> > >
> 
> > 
> 
> > > If any learned member may kindly assist me how may I solve the issue.
> 
> > 
> 
> > >
> 
> > 
> 
> > 
> 
> > 
> 
> > Your error display has been trashed, thanks to googlegroups.
> 
> > 
> 
> >      http://wiki.python.org/moin/GoogleGroupsPython
> 
> > 
> 
> > Try posting with a text email message, since this is a text forum.
> 
> > 
> 
> > 
> 
> > 
> 
> > Your code is also sparse.  Why do you point us to fragments on the net, 
> 
> > 
> 
> > when you could show us the exact code you were running when it failed? 
> 
> > 
> 
> > I'm guessing you're running it from the interpreter, which can be very 
> 
> > 
> 
> > confusing once you have to ask for help.  Please put a sample of code 
> 
> > 
> 
> > into a file, run it, and paste into your text email both the contents of 
> 
> > 
> 
> > that file and the full traceback.  thanks.
> 
> > 
> 
> > 
> 
> > 
> 
> > The email address to post on this forum is  python-list@python.org
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> > DaveA
> 
> 
> 
> Dear Sir, 
> 
> I generally solved this problem from some other angle but I would like to fix this particular issue also so I am posting soon to you. 
> 
> Regards,
> 
> Subhabrata.

Dear Sir,
I was trying to give wrong input. I was making an input error.

Regards,
Subhabrata. 

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Error in Python NLTK subhabangalore@gmail.com - 2013-04-06 12:56 -0700
  Re: Error in Python NLTK Dave Angel <davea@davea.name> - 2013-04-06 16:44 -0400
    Re: Error in Python NLTK subhabangalore@gmail.com - 2013-04-06 14:13 -0700
    Re: Error in Python NLTK subhabangalore@gmail.com - 2013-04-06 14:13 -0700
    Re: Error in Python NLTK subhabangalore@gmail.com - 2013-04-07 13:20 -0700
    Re: Error in Python NLTK subhabangalore@gmail.com - 2013-04-07 13:20 -0700
      Re: Error in Python NLTK subhabangalore@gmail.com - 2013-04-07 15:11 -0700
        Re: Error in Python NLTK Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-07 22:40 +0000
      Re: Error in Python NLTK subhabangalore@gmail.com - 2013-04-07 15:11 -0700

csiph-web