Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 0 deletions textworld/generator/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def __getitem__(self, item):


def assign_new_matching_names(obj1_infos, obj2_infos, grammar, exclude):
if obj1_infos.name is not None or obj2_infos.name is not None:
return False # One of the objects has already a name assigned to it.

tag = "#({}<->{})_match#".format(obj1_infos.type, obj2_infos.type)
if not grammar.has_tag(tag):
return False
Expand Down
16 changes: 8 additions & 8 deletions textworld/logic/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ def test_multi_closure():
pairs = list(hier.multi_ancestors((d, d)))

expected = {
(b, d), (c, d), (d, b), (d, c),
(a, d), (b, b), (b, c), (c, b), (c, c), (d, a),
(b, d), (c, d), (d, b), (d, c), # noqa: E126
(a, d), (b, b), (b, c), (c, b), (c, c), (d, a), # noqa: E131
(a, b), (a, c), (b, a), (c, a),
(a, a),
} # noqa: E131
(a, a), # noqa: E131
}

assert len(pairs) == len(expected)
assert set(pairs) == expected

pairs = list(hier.multi_descendants((a, a)))

expected = {
(a, b), (a, c), (b, a), (c, a),
(a, d), (b, b), (b, c), (c, b), (c, c), (d, a),
(a, b), (a, c), (b, a), (c, a), # noqa: E126
(a, d), (b, b), (b, c), (c, b), (c, c), (d, a), # noqa: E131
(b, d), (c, d), (d, b), (d, c),
(d, d),
} # noqa: E131
(d, d), # noqa: E131
}

assert len(pairs) == len(expected)
assert set(pairs) == expected
Expand Down