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

Add DisCoCirc extension to lambeq #179

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

nikhilkhatri
Copy link
Collaborator

@nikhilkhatri nikhilkhatri commented Nov 8, 2024

This PR adds the DisCoCirc reader as an addon to lambeq.
The new functionality is included in the lambeq.experimental.discocirc subpackage.

New features include:

  • DisCoCircReader, which provides a text2circuit method to parse text into disco-circuits.
  • A CoreferenceResolver abstract class which returns tokenised text, and associated coref information.
  • A concrete SpacyCoreferenceResolver implementation of the above.
  • A set of TreeRewriteRules, which implementic semantic modification of trees made of PregroupTreeNode.

The DisCoCircReader works by getting the PregroupTreeNode tree for each sentence in a given text, and recursively converting it into a circuital diagram, in a single postorder traversal over the tree.

@dimkart
Copy link
Contributor

dimkart commented Nov 11, 2024

Let's do the following before we merge this:

  • Fix the KeyError bug reported by @AnnaNPearson
  • Report coverage results on the big SimpleBooks datasets created by @neiljdo
  • Add the new packages (experimental, experimental.discocirc) in setup.cfg
  • Add at least a couple of tests: A frame-based diagram translation, a sandwich-based diagram translation


## Installation

Installing the experimental subpackage requires Python 3.10.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Python 3.10 or higher", right?

reader.text2circuit('Alice likes Bob. Bob likes Alice too.').draw()
```

To get DisCoCirc diagrams with frames decomposed into multiple boxes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add a reference here in one of the DisCoCirc papers that mentions Sandwich functor.

@@ -0,0 +1,30 @@
# DisCoCirc extension for lambeq

Functionality to convert text into DisCoCirc string diagrams, using lambeq's grammar backend.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference to original paper.

@nikhilkhatri nikhilkhatri marked this pull request as ready for review November 13, 2024 10:08
@nikhilkhatri nikhilkhatri merged commit ab246ee into CQCL:main Nov 13, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants