Re: BOXER interface NLTK

502 views
Skip to first unread message

Miguel Ferreira Gaspar

unread,
Jun 9, 2010, 1:55:28 PM6/9/10
to Dan Garrette, nltk-...@googlegroups.com
I check current version of NLTK directly from its SVN repository but have got an error:

Traceback (most recent call last):
  File "/home/gaspar/Documentos/tests-nltk/nltkboxertest.py", line 2, in <module>
    print Boxer().interpret('Every man sees a dog').normalize()
AttributeError: 'NoneType' object has no attribute 'normalize'

I thing it have to do with needed "--candc-printer boxer" option when executing CANDC current version with SVN repository.

So i have done some correction in code 
Where boxer.py have :
        args = ['--models', os.path.join(self._candc_models_path, 'boxer'),
                '--output', filename]

i have:
        args = ['--models', os.path.join(self._candc_models_path, 'boxer'),
                '--candc-printer', 'boxer', 
                '--output', filename]


But doesnt seems to work anyway, it gives another error msg:

Traceback (most recent call last):
  File "/home/gaspar/Documentos/tests-nltk/nltkboxertest.py", line 2, in <module>
    print Boxer().interpret('Every man sees a dog').normalize()
  File "/usr/lib/pymodules/python2.6/nltk/sem/boxer.py", line 56, in interpret
    return self.batch_interpret([input], occur_index, sentence_id, verbose)[0]
  File "/usr/lib/pymodules/python2.6/nltk/sem/boxer.py", line 78, in batch_interpret
    drs_dict = self._parse_to_drs_dict(boxer_out, occur_index, sentence_id)
  File "/usr/lib/pymodules/python2.6/nltk/sem/boxer.py", line 169, in _parse_to_drs_dict
    assert line.startswith('sem(%s,' % drs_id)
AssertionError

Don know what else to do. Can you give some help?
If you prefer or it is better to make a POST, i can make it???


Miguel Gaspar






I can't compile C&C and BOXER version 1, so i got SVN code and compile it without problems.
But this only work if command CANDC uses --candc-printer boxer,  



Traceback (most recent call last):
  File "nltkboxer.py", line 587, in <module>
    drs = Boxer().interpret(args[0], verbose=options.verbose)
  File "nltkboxer.py", line 56, in interpret
    return self.batch_interpret([input], occur_index, sentence_id, verbose)[0]
  File "nltkboxer.py", line 78, in batch_interpret
    drs_dict = self._parse_to_drs_dict(boxer_out, occur_index, sentence_id)
  File "nltkboxer.py", line 169, in _parse_to_drs_dict
    assert line.startswith('sem(%s,' % drs_id)
AssertionError


2010/6/9 Dan Garrette <dhgar...@gmail.com>
Hi Miguel,

Are you using one of the standard NLTK distributions?  If so, then the boxer interface will not be included since it is new.  You should download the module from [1].  You may also need to get the updated versions of logic.py [2] and drt.py [3].  Alternatively, you can just check out the current version of NLTK directly from its SVN repository.  This will, of course, have all the newest features.

-Dan

[1] http://nltk.googlecode.com/svn/trunk/nltk/nltk/sem/boxer.py
[2] http://nltk.googlecode.com/svn/trunk/nltk/nltk/sem/logic.py
[3] http://nltk.googlecode.com/svn/trunk/nltk/nltk/sem/drt.py



On Wed, Jun 9, 2010 at 10:12 AM, Miguel Ferreira Gaspar <miguel...@eb23andreresende.net> wrote:
I Dan, congratulations on working!

How can I integrate the interface and uses it in NLTK. I have already
installed and CANDC BOXER but trying to run in NLTK gives me error:

>>> from nltk import Boxer
Traceback (most recent call last):
 File "<pyshell#0>", line 1, in <module>
   from nltk import Boxer
ImportError: cannot import name Boxer
>>>

Best Regards

Miguel Gaspar


T kushwanth naga goutham

unread,
Sep 25, 2013, 6:05:03 AM9/25/13
to nltk-...@googlegroups.com, Dan Garrette, miguel...@eb23andreresende.net
import will not work like that

try this :
import nltk.sem.boxer;
x=nltk.sem.boxer.Boxer();
y=x.interpret('Every man runs')

MS

unread,
Dec 12, 2013, 4:41:06 AM12/12/13
to nltk-...@googlegroups.com, Dan Garrette, miguel...@eb23andreresende.net
Hello all,

This is with reference to https://groups.google.com/d/topic/nltk-users/n4EVbLzuHO0/discussion

I tried out Boxer with the examples from both the documentation and the one shown below by Goutham.

For a checklist,
 - I have installed boxer by using the latest C&C and Boxer sources from SVN.
 - Pointed CANDCHOME variable to the appropriate directory
 - imported nltk.sem.boxer
 - also tried out replacing logic.py, drt.py, and boxer.py from the SVN link suggested in above thread.

The result of the interpret function is,
---------------------------------------------------------
>>> x = nltk.sem.boxer.Boxer()
>>> y = x.interpret("Every man runs")
>>> y
>>> type(y)
<type 'NoneType'>
>>> print str(y)
None
---------------------------------------------------------
I understand that this is not the output one might expect. Shouldn't 'y' be of type drt.AbstractDrs ?
What might I be missing ?

Thanks and regards,
Madhu.
=======================================================================

T kushwanth naga goutham

unread,
Dec 12, 2013, 5:54:59 AM12/12/13
to nltk-...@googlegroups.com, Dan Garrette, miguel...@eb23andreresende.net
Madhu,

I think u might be missing some installations which are the prerequisites for boxer like prolog like that.Dont go with development version of boxer.use standard version.
I have got the output as like this.

>>> import nltk
>>> x = nltk.sem.boxer.Boxer()
>>> y = x.interpret("Every man runs")
>>> y
<DRS ([],[(([x2],[n_man(x2)]) -> ([x4],[agent(x4,x2), v_run(x4)]))])>
>>> type(y)
<class 'nltk.sem.drt.DRS'>
>>> print str(y)
([],[(([x2],[n_man(x2)]) -> ([x4],[agent(x4,x2), v_run(x4)]))])

I am running it on a ubuntu 12.04 machine.





--
You received this message because you are subscribed to a topic in the Google Groups "nltk-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nltk-users/n4EVbLzuHO0/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dan Garrette

unread,
Dec 12, 2013, 10:52:17 AM12/12/13
to T kushwanth naga goutham, nltk-users, miguel...@eb23andreresende.net
Dont go with development version of boxer.use standard version.

You definitely need the development version straight from the C&C svn repository.  The standard download (version 1.00) is 6 years old, and Boxer has changed dramatically since then.  This old version of C&C will not work with NLTK.  (Unless, I guess, your version of NLTK is also extremely old).

As for why you're getting `None` as the result from `interpret`, that doesn't make much sense. As you can see in the source code, `interpret is defined in a way that should explicitly exclude `None`:


        d, = self.batch_interpret_multisentence([[input]], discourse_ids, question, verbose)
        if not d:
            raise Exception('Unable to interpret: "%s"' % input)
        return d

Maybe do some debugging to see where things are going wrong?

-Dan

Dan Garrette

unread,
Dec 12, 2013, 10:57:49 AM12/12/13
to T kushwanth naga goutham, nltk-users, miguel.gaspar
On Thu, Dec 12, 2013 at 9:52 AM, Dan Garrette <dhgar...@gmail.com> wrote:
Dont go with development version of boxer.use standard version.

You definitely need the development version straight from the C&C svn repository.

Re-reading, I see you probably meant to not use the super-old linked nltk boxer interface.  So, yes, that.

MS

unread,
Dec 17, 2013, 12:03:38 PM12/17/13
to nltk-...@googlegroups.com
Hello,

So I went back and tried out a few things.
- Prolog was always installed (swi-prolog).
- I was originally on a 64 bit Ubuntu 13.04 (Python 2.7.4). Thinking that it might be a factor, I have since tried 32 bit Ubuntu 12.04 (and Python 2.7.3) - to no avail
- Have installed boxer from the source on the C&C SVN repository

Then debugged the program with the same example as used above ( y = x.interpret("Every man runs") )

It seems to fetch valid values all along, except when in the following line, it never passes the "if" condition.
------------------------------------------------------------------------------------------------------------------
> /usr/lib/python2.7/dist-packages/nltk/sem/boxer.py(163)_parse_to_drs_dict()
-> if line.startswith('id('):
------------------------------------------------------------------------------------------------------------------
So this seems to be the place where the variable 'drs_dict' never gets a value and eventually ends up as an empty list.
Don't have a clue of how it is supposed to be behave - in case it helps, I have attached a txt with the entire manual line-wise trace of the debug.

Regards.
python_trace.txt

MS

unread,
Dec 19, 2013, 2:13:53 PM12/19/13
to nltk-...@googlegroups.com
Gowtham suggested two useful things - to set appropriate env variables and then to try out command line options, as follows.
------------------------------------------------------------------
echo 'Every man runs'|bin/candc --models models/boxer --candc-printer boxer
> /tmp/test.ccg
bin/boxer --input /tmp/test.ccg --box
------------------------------------------------------------------
The first line did not initially work, saying "candc:models/boxer:option does not exist".
However on a second try, the relevant DRS was showing up.

So I need to go back and check what is stopping the same from working in the python interpreter / script.

Regards.

Steven Bird

unread,
Dec 19, 2013, 5:39:27 PM12/19/13
to nltk-users, T kushwanth naga goutham, miguel...@eb23andreresende.net
On 13 December 2013 02:52, Dan Garrette <dhgar...@gmail.com> wrote:
Dont go with development version of boxer.use standard version.

You definitely need the development version straight from the C&C svn repository.  The standard download (version 1.00) is 6 years old, and Boxer has changed dramatically since then.  This old version of C&C will not work with NLTK.  (Unless, I guess, your version of NLTK is also extremely old).


I've opened a new issue concerning this [1] and hope to create more detailed installation instructions for optional dependencies on our installation page [2].


 

MS

unread,
Jan 13, 2014, 4:33:28 AM1/13/14
to nltk-...@googlegroups.com

On Friday, December 20, 2013 12:43:53 AM UTC+5:30, MS wrote:
Gowtham suggested two useful things - to set appropriate env variables and then to try out command line options, as follows.
------------------------------------------------------------------
echo 'Every man runs'|bin/candc --models models/boxer --candc-printer boxer
> /tmp/test.ccg
bin/boxer --input /tmp/test.ccg --box
------------------------------------------------------------------
The first line did not initially work, saying "candc:models/boxer:option does not exist".
However on a second try, the relevant DRS was showing up.

So I need to go back and check what is stopping the same from working in the python interpreter / script.

Regards.

On Tuesday, December 17, 2013 10:33:38 PM UTC+5:30, MS wrote:
Hello,

So I went back and tried out a few things.
- Prolog was always installed (swi-prolog).
- I was originally on a 64 bit Ubuntu 13.04 (Python 2.7.4). Thinking that it might be a factor, I have since tried 32 bit Ubuntu 12.04 (and Python 2.7.3) - to no avail
- Have installed boxer from the source on the C&C SVN repository

Then debugged the program with the same example as used above ( y = x.interpret("Every man runs") )

It seems to fetch valid values all along, except when in the following line, it never passes the "if" condition.
------------------------------------------------------------------------------------------------------------------
> /usr/lib/python2.7/dist-packages/nltk/sem/boxer.py(163)_parse_to_drs_dict()
-> if line.startswith('id('):
------------------------------------------------------------------------------------------------------------------

I have been debugging the same example and am unable to resolve the problem as of yet.
In the above debug output (boxer.py line 163) it seems that boxer is looking for a line starting with "id(" - could anyone please explain what is the reason?
If it helps, the input list called lines (of which line is an element) is as follows:

lines = ['%%% This output was generated by the following command:', '%%% /home/directoryname/candc/bin/boxer --box false --semantics drs --format prolog --flat false --resolve true --elimeq true --input /tmp/boxer-Ogy_ww.in ', '', ':- multifile     sem/3, id/2.', ':- discontiguous sem/3, id/2.', ':- dynamic       sem/3, id/2.', '']

PS: Since the command line example from documentation works, is it possible to achieve all of NLTK Boxer module's capabilities using cmd line alone (e.g. get the output representation as drt.AbstractDrs )?

ni...@userworkstech.com

unread,
Feb 16, 2016, 8:55:30 AM2/16/16
to nltk-users, dhgar...@gmail.com, miguel...@eb23andreresende.net
Hi,
          I trying to use Boxer. At first time, I got "--candc-printer', 'boxer'" error. I fixed that by removing "--candc-printer', 'boxer'" from "args". Then, I run the command. After that, I got this "Assertion Error - assert line.startswith('sem(%s,' % drs_id) " here. I am facing the same issue which you faced. Please help to fix it.

MS

unread,
May 17, 2016, 3:25:38 AM5/17/16
to nltk-users, dhgar...@gmail.com, miguel...@eb23andreresende.net
Could you please post more information so that we can help you - such as, what exactly did you try out?
Also, the example in http://svn.ask.it.usyd.edu.au/trac/candc/wiki/BoxerSimple should work fine if everything else, such as your environments (CANDC) are set correctly.

Regards.
Reply all
Reply to author
Forward
0 new messages