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


Groups > comp.lang.python > #42942

Re: Error in Python NLTK

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
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; 'valueerror:': 0.09; 'python': 0.11; 'expression.': 0.16; 'guessing': 0.16; 'interpreter,': 0.16; 'received:74.208.4.195': 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; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; "aren't": 0.24; 'interpret': 0.24; 'url:moin': 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; '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; 'could': 0.34; 'display': 0.35; 'skip:s 30': 0.35; 'test': 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; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'solve': 0.60; '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; '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; 'received:74.208': 0.68; 'truth': 0.81; "'and'": 0.84; '3.8': 0.84; 'confusing': 0.84; 'fragments': 0.84
Date Sat, 06 Apr 2013 16:44:41 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: Error in Python NLTK
References <8dd5cddd-792a-489f-bc1a-46026a227aa8@googlegroups.com>
In-Reply-To <8dd5cddd-792a-489f-bc1a-46026a227aa8@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:zrxgtRSnby6TQCusNhcfNfx/xvRrOa092hbeY+LVjbj oZb5rrux/lebhjwg3cQyJGhFlRKMgE283b/djiObGyS5Eknn/D a7W31hfAIw0EwpXDf1bKqjXtP2PMm2vakoF6KtyQ4ref8VRCtF ALo2J2szKOLIf9nY42MeQ3zeBp5XkFDBsZprh9uIt+RzdKRXqr hn6LZX0i1+uPUUbZr2QaaGpnU08y5kAhCCUKlEYdDDpxu7b7s/ zzkeYYVSfGfGXZDiSYqAKCQMMcaNakrI/EfQTwwy2E4SYcTP7L NQUAGpZnf8jVyX5LTBzdQOquWF2/fe8n7OQwmun3al4Kv3PDA= =
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>
Newsgroups comp.lang.python
Message-ID <mailman.209.1365281115.3114.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365281115 news.xs4all.nl 6849 [2001:888:2000:d::a6]:37985
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42942

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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