Fixed #43 : BnfNodeParser: I can recognize when multiple level of ISA
Fixed #44 : BnfNodeParser: I must simplify results when multiple levels of ISA Fixed #45 : Dynamic variables cannot be parsed at restart Fixed #46 : Concepts variables values are transformed into list by default Fixed #47 : SheerkaAdmin. Add min, max, mean time when restoring files
This commit is contained in:
@@ -1889,6 +1889,44 @@ class TestBnfNodeParser(TestUsingMemoryBasedSheerka):
|
||||
assert isinstance(resolved.nodes[1], VariableExpression)
|
||||
assert resolved.nodes[0].nodes == []
|
||||
|
||||
def test_i_can_simplify_unordered_choices_that_refer_to_the_same_isa(self):
|
||||
my_map = {
|
||||
"light_red": Concept("light red"),
|
||||
"dark_red": Concept("dark red"),
|
||||
"red colors": Concept("red colors"),
|
||||
"color": Concept("color"),
|
||||
"adjective": Concept("adjective"),
|
||||
"qualified table": Concept("qualified table", definition="adjective 'table'"),
|
||||
}
|
||||
|
||||
sheerka, context, parser = self.init_parser(my_map, init_from_sheerka=True, create_new=True)
|
||||
sheerka.set_isa(context, my_map["light_red"], my_map["adjective"])
|
||||
sheerka.set_isa(context, my_map["dark_red"], my_map["adjective"])
|
||||
sheerka.set_isa(context, my_map["light_red"], my_map["color"])
|
||||
sheerka.set_isa(context, my_map["dark_red"], my_map["color"])
|
||||
sheerka.set_isa(context, my_map["light_red"], my_map["red colors"])
|
||||
sheerka.set_isa(context, my_map["dark_red"], my_map["red colors"])
|
||||
sheerka.set_isa(context, my_map["color"], my_map["adjective"])
|
||||
sheerka.set_isa(context, my_map["red colors"], my_map["color"])
|
||||
sheerka.set_isa(context, my_map["red colors"], my_map["adjective"])
|
||||
|
||||
text = "light red table"
|
||||
|
||||
expected = CNC("qualified table",
|
||||
source=text,
|
||||
body=DoNotResolve(text),
|
||||
adjective=CC("adjective",
|
||||
source="light red",
|
||||
body=CC("light_red", source="light red"),
|
||||
light_red=CC("light_red", source="light red")))
|
||||
expected_array = compute_expected_array(my_map, text, [expected])
|
||||
|
||||
res = parser.parse(context, ParserInput(text))
|
||||
# there should be only one result !!
|
||||
assert not isinstance(res, list)
|
||||
assert res.status
|
||||
compare_with_test_object(res.value.value, expected_array)
|
||||
|
||||
# @pytest.mark.parametrize("parser_input, expected", [
|
||||
# ("one", [
|
||||
# (True, [CNC("bnf_one", source="one", one="one", body="one")]),
|
||||
|
||||
Reference in New Issue
Block a user