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

Spider tn #157

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lambeq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
'bag_of_words_reader',
'cups_reader',
'spiders_reader',
'spider_chain_reader',
'stairs_reader',
'word_sequence_reader',

Expand Down Expand Up @@ -124,7 +125,7 @@
WebParseError, WebParser,
Reader, LinearReader, TreeReader, TreeReaderMode,
bag_of_words_reader, cups_reader, spiders_reader,
stairs_reader, word_sequence_reader)
spider_chain_reader, stairs_reader, word_sequence_reader)
from lambeq.tokeniser import Tokeniser, SpacyTokeniser
from lambeq.training import (Checkpoint, Dataset, Optimizer,
NelderMeadOptimizer, RotosolveOptimizer,
Expand Down
4 changes: 3 additions & 1 deletion lambeq/text2diagram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
'bag_of_words_reader',
'cups_reader',
'spiders_reader',
'spider_chain_reader',
'stairs_reader',
'word_sequence_reader']

Expand All @@ -53,5 +54,6 @@
stairs_reader,
word_sequence_reader)
from lambeq.text2diagram.spiders_reader import (bag_of_words_reader,
spiders_reader)
spiders_reader,
spider_chain_reader)
from lambeq.text2diagram.tree_reader import TreeReader, TreeReaderMode
5 changes: 4 additions & 1 deletion lambeq/text2diagram/spiders_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__all__ = ['SpidersReader', 'bag_of_words_reader', 'spiders_reader']
__all__ = ['SpidersReader', 'bag_of_words_reader',
'spiders_reader', 'spider_chain_reader']

from lambeq.backend.grammar import Diagram, Id, Spider, Word
from lambeq.core.types import AtomicType
from lambeq.core.utils import SentenceType, tokenised_sentence_type_check
from lambeq.text2diagram.base import Reader
from lambeq.text2diagram.linear_reader import LinearReader

S = AtomicType.SENTENCE

Expand Down Expand Up @@ -46,3 +48,4 @@ def sentence2diagram(self,

spiders_reader = SpidersReader()
bag_of_words_reader = spiders_reader
spider_chain_reader = LinearReader(Spider(AtomicType.SENTENCE, 2, 1))
Copy link
Contributor Author

@kinianlo kinianlo Oct 11, 2024

Choose a reason for hiding this comment

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

LinearReader requires a Diagram type but Spider is a Box. Should LinearReader be modified to also accept Box or we should convert the Spider into a diagram, e.g. using .to_diagram()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just use .to_diagram() for now. Please also note that your branch requires some cleaning.

Loading