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

Ty('P') Error #18

Closed
ACE07-Sev opened this issue Jun 17, 2022 · 3 comments
Closed

Ty('P') Error #18

ACE07-Sev opened this issue Jun 17, 2022 · 3 comments

Comments

@ACE07-Sev
Copy link
Contributor

Traceback (most recent call last):
File "C:\Users\elmm\Desktop\CQM\QNLP Depression.py", line 141, in
train_circuits = [ansatz(diagram) for diagram in train_diagrams]
File "C:\Users\elmm\Desktop\CQM\QNLP Depression.py", line 141, in
train_circuits = [ansatz(diagram) for diagram in train_diagrams]
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\ansatz\circuit.py", line 59, in call
return self.functor(diagram)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\discopy\rigid.py", line 651, in call
return super().call(diagram)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\discopy\monoidal.py", line 900, in call
result = result >> id_l @ self(box) @ id_r
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\discopy\rigid.py", line 642, in call
return super().call(diagram)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\discopy\monoidal.py", line 894, in call
return super().call(diagram)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\discopy\cat.py", line 911, in call
return self.ar[arrow]
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\discopy\cat.py", line 961, in getitem
return self._func(box)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\ansatz\circuit.py", line 118, in _ar
dom, cod = self._ob(box.dom), self._ob(box.cod)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\ansatz\circuit.py", line 63, in _ob
return sum(self.ob_map[Ty(factor.name)] for factor in pg_type)
File "C:\Users\elmm\AppData\Local\Programs\Python\Python39\lib\site-packages\lambeq\ansatz\circuit.py", line 63, in
return sum(self.ob_map[Ty(factor.name)] for factor in pg_type)
KeyError: Ty('p')

How can I resolve this?

@ACE07-Sev
Copy link
Contributor Author

This issue can be resolved by adding a AtomicType.PREPOSITIONAL_PHRASE to the IQP ansatz. for versions under 0.2.3 it will be AtomicType.PREPOSITION, and for 0.2.3 AtomicType.PREPOSITIONAL_PHRASE.

@y-richie-y
Copy link
Collaborator

Thanks for the issue! Yes, it is necessary in general to provide mappings for noun, sentence and propositional phrase types in the Ansatz mapping. We will update the examples in the documentation to reflect this.

@dimkart
Copy link
Contributor

dimkart commented Jun 20, 2022

This will be now closed.

@dimkart dimkart closed this as completed Jun 20, 2022
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