Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Bobcat Parser #57

Closed
dancbeaulieu opened this issue Nov 7, 2022 · 2 comments
Closed

Error with Bobcat Parser #57

dancbeaulieu opened this issue Nov 7, 2022 · 2 comments

Comments

@dancbeaulieu
Copy link

Hi,

I am having a relatively difficult to understand error. I am trying to look at the sentence "Senate Advances Bill To Approve Keystone Pipeline Despite Obamas Veto Threat", and can't figure out why it is giving me the error below. Does BobCatParser throw an error if it doesn't recognize a word? I am unclear what I would need to do to fix the sentence.

from lambeq import BobcatParser

parser = BobcatParser()
diagram = parser.sentence2diagram('Senate Advances Bill To Approve Keystone Pipeline Despite Obamas Veto Threat')
diagram.draw()

raceback (most recent call last):

File "/Users/dabeaulieu/opt/anaconda3/envs/qcware/lib/python3.9/site-packages/lambeq/text2diagram/bobcat_parser.py", line 382, in sentences2trees
trees.append(self._build_ccgtree(result[0]))

File "/Users/dabeaulieu/opt/anaconda3/envs/qcware/lib/python3.9/site-packages/lambeq/bobcat/parser.py", line 258, in getitem
return self.root[index]

IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/Users/dabeaulieu/opt/anaconda3/envs/qcware/lib/python3.9/site-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
exec(code, globals, locals)

File "/Users/dabeaulieu/Documents/Initiatives/quantum/machine learning/notebooks/qnlp/ankush/Quantum_NLP/testcode.py", line 12, in
diagram = parser.sentence2diagram('Senate Advances Bill To Approve Keystone Pipeline Despite Obamas Veto Threat')

File "/Users/dabeaulieu/opt/anaconda3/envs/qcware/lib/python3.9/site-packages/lambeq/text2diagram/ccg_parser.py", line 231, in sentence2diagram
return self.sentences2diagrams(

File "/Users/dabeaulieu/opt/anaconda3/envs/qcware/lib/python3.9/site-packages/lambeq/text2diagram/ccg_parser.py", line 161, in sentences2diagrams
trees = self.sentences2trees(sentences,

File "/Users/dabeaulieu/opt/anaconda3/envs/qcware/lib/python3.9/site-packages/lambeq/text2diagram/bobcat_parser.py", line 387, in sentences2trees
raise BobcatParseError(' '.join(sent.words))

BobcatParseError: Bobcat failed to parse 'Senate Advances Bill To Approve Keystone Pipeline Despite Obamas Veto Threat'.

@ianyfan
Copy link
Collaborator

ianyfan commented Nov 22, 2022

This works if you change the sentence to:
Senate Advances Bill To Approve Keystone Pipeline Despite Obama 's Veto Threat (including the extra space)

Omitting the apostrophe changes the semantics of the sentence to something the parser doesn't find grammatical.

Hope that makes sense. Let me know if you want any more explanation.

@dimkart
Copy link
Contributor

dimkart commented Feb 8, 2023

This issue will be close due to inactivity. @dancbeaulieu if you require any more help let us know.

@dimkart dimkart closed this as completed Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants