lambeq icon indicating copy to clipboard operation
lambeq copied to clipboard

Implement ASCII drawing for all lambeq diagrams

Open nikhilkhatri opened this issue 9 months ago • 2 comments

Task description

lambeq has a rich interface for drawing diagrams using matplotlib and tikz. it also has an interface for drawing diagrams as ASCII text to a CLI interface. Presently, this text drawing is limited to pregroup diagrams, such as those created by the DisCoCat model.

This task asks for the text drawing feature to be extended to arbitrary diagrams, including the grammar, tensor and quantum diagrams which lambeq provides.

The current implementation assumes that diagrams have a pregroup structure. That is, they consist of a single layer of Word boxes, followed by layers consisting of swaps, identities or cups. In general, lambeq's backend can represent arbitrary string diagrams which do not have this constraint.

Completing this task requires providing an implementation of diagram2str in the DiagramTextPrinter class which can draw arbitrary string diagrams.

Notes

  • The text drawing feature is expected to work on all 3 diagram backends provided by lambeq:
  • It is necessary to ensure that boxes are wide enough to fit the text content in them.
  • Handling of foliation (collapsing boxes into fewer layers when possible) is optional.

References

nikhilkhatri avatar May 07 '24 11:05 nikhilkhatri