intermediate commit

This commit is contained in:
2024-09-22 09:27:20 +02:00
parent a729d98a0d
commit 3be854d34c
14 changed files with 441 additions and 108 deletions
+56 -4
View File
@@ -29,13 +29,65 @@ class TestSyaConceptsParser(BaseTest):
with comparable_tokens():
assert actual == resolved_expected_list
def test_i_can_parse_a_simple_case(self, context, parser):
@pytest.mark.parametrize("concept", [
get_concept("a plus b", variables=["a", "b"]),
get_concept("add a b", variables=["a", "b"]),
get_concept("a b add", variables=["a", "b"]),
])
def test_i_can_parse_a_simple_case(self, context, parser, concept):
with NewOntology(context, "test_i_can_parse_a_simple_case"):
get_concepts(context, get_concept("a plus b", variables=["a", "b"]), use_sheerka=True)
get_concepts(context, concept, use_sheerka=True)
pi = get_parser_input("1 plus 2")
res = parser.parse(context, pi)
error_sink = []
res = parser.parse(context, pi, error_sink)
expected = [_mt("1001", a="1 ", b=" 2")]
assert res == MultipleChoices([expected])
assert not parser.error_sink
assert not error_sink
def test_i_can_parse_long_names_concept(self, context, parser):
with NewOntology(context, "test_i_can_parse_a_simple_case"):
get_concepts(context, get_concept("a long named concept b", variables=["a", "b"]), use_sheerka=True)
pi = get_parser_input("1 long named concept 2")
error_sink = []
res = parser.parse(context, pi, error_sink)
expected = [_mt("1001", a="1 ", b=" 2")]
assert res == MultipleChoices([expected])
assert not error_sink
def test_i_can_parse_sequence(self, context, parser):
with NewOntology(context, "test_i_can_parse_sequence"):
get_concepts(context, get_concept("a plus b", variables=["a", "b"]), use_sheerka=True)
pi = get_parser_input("1 plus 2 3 plus 7")
error_sink = []
res = parser.parse(context, pi, error_sink)
expected = [[_mt("1001", a="1 ", b=" 2")], [_mt("1001", a=" 3 ", b=" 7")]]
assert res == MultipleChoices(expected)
assert not error_sink
def test_not_enough_parameters(self, context, parser):
with NewOntology(context, "test_not_enough_parameters"):
get_concepts(context, get_concept("a plus b", variables=["a", "b"]), use_sheerka=True)
pi = get_parser_input("1 plus 2 3 plus 7")
error_sink = []
res = parser.parse(context, pi, error_sink)
expected = [[_mt("1001", a="1 ", b=" 2")], [_mt("1001", a=" 3 ", b=" 7")]]
assert res == MultipleChoices(expected)
assert not error_sink
def test_i_can_detect_when_name_does_not_match(self, context, parser):
with NewOntology(context, "test_i_can_detect_when_name_does_not_match"):
get_concepts(context, get_concept("a long named concept b", variables=["a", "b"]), use_sheerka=True)
pi = get_parser_input("1 long named mismatch 2")
error_sink = []
res = parser.parse(context, pi, error_sink)
assert error_sink