ExactConceptParser can now recognize concepts by their names
This commit is contained in:
+10
-2
@@ -98,7 +98,15 @@ class BaseTest:
|
||||
try_parsed=concept))
|
||||
|
||||
@staticmethod
|
||||
def create_concept_lite(sheerka, name, variables=None, bnf=None):
|
||||
def create_and_add_in_cache_concept(sheerka, name, variables=None, bnf=None):
|
||||
"""
|
||||
Create a concept using parameters and add it in cache
|
||||
:param sheerka:
|
||||
:param name:
|
||||
:param variables:
|
||||
:param bnf:
|
||||
:return:
|
||||
"""
|
||||
concept = Concept(name) if isinstance(name, str) else name
|
||||
if variables:
|
||||
for v in variables:
|
||||
@@ -124,7 +132,7 @@ class BaseTest:
|
||||
return concept
|
||||
|
||||
@staticmethod
|
||||
def def_concept(name, definition, variables=None, **kwargs):
|
||||
def from_def_concept(name, definition, variables=None, **kwargs):
|
||||
concept = Concept(name=name, definition=definition, definition_type=DEFINITION_TYPE_DEF)
|
||||
if variables:
|
||||
for v in variables:
|
||||
|
||||
@@ -142,7 +142,7 @@ class TestSheerkaCreateNewConcept(TestUsingMemoryBasedSheerka):
|
||||
def test_i_can_get_by_name_when_created_with_def_definition(self):
|
||||
sheerka = self.get_sheerka(cache_only=False)
|
||||
context = self.get_context(sheerka)
|
||||
concept = self.def_concept("plus", "a plus b", ["a", "b"])
|
||||
concept = self.from_def_concept("plus", "a plus b", ["a", "b"])
|
||||
|
||||
res = sheerka.create_new_concept(context, concept)
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.body == "do not resolve"
|
||||
assert evaluated.metadata.is_evaluated
|
||||
|
||||
def test_i_can_evaluate_property_using_do_not_resolve(self):
|
||||
def test_i_can_evaluate_variable_using_do_not_resolve(self):
|
||||
sheerka, context, concept = self.init_concepts(Concept("foo").def_var("a"), eval_body=True)
|
||||
concept.compiled["a"] = DoNotResolve("do not resolve")
|
||||
|
||||
@@ -181,7 +181,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert sheerka.objvalue(evaluated) == CB("a", None)
|
||||
assert evaluated.metadata.is_evaluated
|
||||
|
||||
def test_i_can_evaluate_concept_when_properties_reference_others_concepts(self):
|
||||
def test_i_can_evaluate_concept_when_variables_reference_others_concepts(self):
|
||||
sheerka, context, concept_a, concept = self.init_concepts(
|
||||
Concept("a"),
|
||||
Concept("foo", body="a").def_var("a", "a"),
|
||||
@@ -194,7 +194,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.body == concept_a
|
||||
|
||||
def test_i_can_evaluate_concept_when_properties_reference_others_concepts_2(self):
|
||||
def test_i_can_evaluate_concept_when_variables_reference_others_concepts_2(self):
|
||||
"""
|
||||
Same test,
|
||||
but the name of the property and the name of the concept are different
|
||||
@@ -208,7 +208,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.body == concept_a
|
||||
|
||||
def test_i_can_evaluate_concept_when_properties_reference_others_concepts_with_body(self):
|
||||
def test_i_can_evaluate_concept_when_variables_reference_others_concepts_with_body(self):
|
||||
sheerka, context, *concepts = self.init_concepts(
|
||||
Concept(name="a", body="1"),
|
||||
Concept(name="b", body="2"),
|
||||
@@ -221,7 +221,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.body == 3
|
||||
|
||||
def test_i_can_evaluate_concept_when_properties_is_a_concept(self):
|
||||
def test_i_can_evaluate_concept_when_variables_is_a_concept(self):
|
||||
sheerka, context, concept_a = self.init_concepts(Concept(name="a", body="'a'"), eval_body=True)
|
||||
|
||||
concept = Concept("foo").def_var("a")
|
||||
@@ -231,7 +231,29 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.get_value("a") == CB("a", "a")
|
||||
|
||||
def test_i_can_evaluate_when_property_asts_is_a_list(self):
|
||||
def test_i_can_evaluate_concept_when_variable_is_a_concept_token(self):
|
||||
sheerka, context, concept_a, concept_b = self.init_concepts(
|
||||
"a",
|
||||
Concept("b").def_var("var_name", "c:a:"), # c:a: means concept 'a'
|
||||
eval_body=True)
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, concept_b)
|
||||
|
||||
assert evaluated.key == concept_b.key
|
||||
assert evaluated.get_value("var_name") == concept_a
|
||||
|
||||
def test_i_can_evaluate_concept_when_body_isa_concept_token(self):
|
||||
sheerka, context, concept_a, concept_b = self.init_concepts(
|
||||
"a",
|
||||
Concept("b", body="c:a:"), # c:a: means concept 'a'
|
||||
eval_body=True)
|
||||
|
||||
evaluated = sheerka.evaluate_concept(context, concept_b)
|
||||
|
||||
assert evaluated.key == concept_b.key
|
||||
assert evaluated.body == concept_a
|
||||
|
||||
def test_i_can_evaluate_when_variable_asts_is_a_list(self):
|
||||
sheerka = self.get_sheerka()
|
||||
foo = Concept("foo", body="1")
|
||||
|
||||
@@ -270,7 +292,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.body == sheerka.test()
|
||||
|
||||
def test_properties_values_takes_precedence_over_the_outside_world(self):
|
||||
def test_variables_values_takes_precedence_over_the_outside_world(self):
|
||||
sheerka, context, concept_a, concept_b = self.init_concepts(
|
||||
Concept(name="a", body="'concept_a'"),
|
||||
Concept(name="b", body="'concept_b'"),
|
||||
@@ -294,7 +316,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.body == CB("b", "concept_b")
|
||||
|
||||
def test_properties_values_takes_precedence(self):
|
||||
def test_variables_values_takes_precedence(self):
|
||||
sheerka, context, concept_a, concept_b = self.init_concepts(
|
||||
Concept(name="a", body="'concept_a'"),
|
||||
Concept(name="b", body="'concept_b'"),
|
||||
@@ -306,7 +328,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
assert evaluated.key == concept.key
|
||||
assert evaluated.body == 'prop_aconcept_b'
|
||||
|
||||
def test_i_can_reference_sub_property_of_a_property(self):
|
||||
def test_i_can_reference_sub_property_of_a_variable(self):
|
||||
sheerka, context, concept_a = self.init_concepts(
|
||||
Concept(name="concept_a").def_var("subProp", "'sub_a'"),
|
||||
eval_body=True
|
||||
@@ -316,7 +338,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
evaluated = sheerka.evaluate_concept(context, concept)
|
||||
assert evaluated == CB(concept.key, "sub_a")
|
||||
|
||||
def test_i_cannot_evaluate_concept_if_property_is_in_error(self):
|
||||
def test_i_cannot_evaluate_concept_if_variable_is_in_error(self):
|
||||
sheerka = self.get_sheerka()
|
||||
|
||||
concept = Concept(name="concept_a").def_var("subProp", "undef_concept")
|
||||
@@ -344,7 +366,7 @@ class TestSheerkaEvaluateConcept(TestUsingMemoryBasedSheerka):
|
||||
sheerka, context, concept = self.init_concepts(
|
||||
Concept("foo", body="10", where=where_clause).def_var("a", "20"),
|
||||
)
|
||||
|
||||
|
||||
evaluated = sheerka.evaluate_concept(self.get_context(sheerka, False, True), concept)
|
||||
|
||||
if expected:
|
||||
|
||||
@@ -279,7 +279,6 @@ class TestSheerkaUsingMemoryBasedSheerka(TestUsingMemoryBasedSheerka):
|
||||
(None, None),
|
||||
("foo", ["foo", "foo2"]),
|
||||
("bar", "bar"),
|
||||
("1001", "foo"), # by id take precedence over by name
|
||||
("plus", "plus"),
|
||||
("a mult b", "mult"),
|
||||
("unknown", None),
|
||||
@@ -298,13 +297,17 @@ class TestSheerkaUsingMemoryBasedSheerka(TestUsingMemoryBasedSheerka):
|
||||
(Token(TokenKind.CONCEPT, (None, None), 0, 0, 0), None),
|
||||
(Token(TokenKind.CONCEPT, ("foo", None), 0, 0, 0), ["foo", "foo2"]),
|
||||
|
||||
# by concept token str
|
||||
("c:foo:", ["foo", "foo2"]),
|
||||
("c:unknown:", None),
|
||||
|
||||
])
|
||||
def test_i_can_resolve_concept(self, concept, expected):
|
||||
sheerka, context, *concepts = self.init_concepts(
|
||||
"foo",
|
||||
Concept("foo", body="another one"),
|
||||
"bar",
|
||||
self.def_concept("plus", "a plus b", ["a", "b"]),
|
||||
self.from_def_concept("plus", "a plus b", ["a", "b"]),
|
||||
Concept("a mult b").def_var("a").def_var("b"),
|
||||
Concept("1001"),
|
||||
)
|
||||
@@ -319,7 +322,7 @@ class TestSheerkaUsingMemoryBasedSheerka(TestUsingMemoryBasedSheerka):
|
||||
|
||||
def test_i_can_resolve_when_searching_by_definition(self):
|
||||
sheerka, context, plus = self.init_concepts(
|
||||
self.def_concept("plus", "a plus b", ["a", "b"]),
|
||||
self.from_def_concept("plus", "a plus b", ["a", "b"]),
|
||||
create_new=True
|
||||
)
|
||||
|
||||
|
||||
@@ -170,14 +170,14 @@ def test_i_can_str_concept():
|
||||
assert core.utils.str_concept((None, "id")) == "c:|id:"
|
||||
assert core.utils.str_concept(("key", None)) == "c:key:"
|
||||
assert core.utils.str_concept((None, None)) == ""
|
||||
assert core.utils.str_concept(("key", "id"), skip_key=True) == "c:|id:"
|
||||
assert core.utils.str_concept(("key", "id"), drop_name=True) == "c:|id:"
|
||||
|
||||
concept = Concept("foo").init_key()
|
||||
assert core.utils.str_concept(concept) == "c:foo:"
|
||||
|
||||
concept.metadata.id = "1001"
|
||||
assert core.utils.str_concept(concept) == "c:foo|1001:"
|
||||
assert core.utils.str_concept(concept, skip_key=True) == "c:|1001:"
|
||||
assert core.utils.str_concept(concept, drop_name=True) == "c:|1001:"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text, expected", [
|
||||
|
||||
@@ -137,8 +137,8 @@ class TestPythonEvaluator(TestUsingMemoryBasedSheerka):
|
||||
|
||||
def test_i_can_call_function_with_complex_concepts(self):
|
||||
sheerka, context, plus, mult = self.init_concepts(
|
||||
self.def_concept("plus", "a plus b", ["a", "b"]),
|
||||
self.def_concept("mult", "a mult b", ["a", "b"]),
|
||||
self.from_def_concept("plus", "a plus b", ["a", "b"]),
|
||||
self.from_def_concept("mult", "a mult b", ["a", "b"]),
|
||||
)
|
||||
|
||||
parsed = PythonParser().parse(context, "is_greater_than(BuiltinConcepts.PRECEDENCE, mult, plus)")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept, PROPERTIES_TO_SERIALIZE, simplec
|
||||
from core.concept import Concept, PROPERTIES_TO_SERIALIZE, simplec, CMV
|
||||
from evaluators.MutipleSameSuccessEvaluator import MultipleSameSuccessEvaluator
|
||||
from parsers.BaseNodeParser import SyaAssociativity
|
||||
from parsers.BnfNodeParser import Sequence, StrMatch, OrderedChoice, Optional, ConceptExpression
|
||||
@@ -226,9 +226,9 @@ as:
|
||||
|
||||
def test_i_can_recognize_duplicate_concepts_with_same_value(self):
|
||||
sheerka = self.get_sheerka()
|
||||
self.create_concept_lite(sheerka, Concept(name="hello a", body="'hello ' + a"), variables=["a"])
|
||||
self.create_concept_lite(sheerka, Concept(name="hello foo", body="'hello foo'"))
|
||||
self.create_concept_lite(sheerka, Concept(name="foo", body="'foo'"))
|
||||
self.create_and_add_in_cache_concept(sheerka, Concept(name="hello a", body="'hello ' + a"), variables=["a"])
|
||||
self.create_and_add_in_cache_concept(sheerka, Concept(name="hello foo", body="'hello foo'"))
|
||||
self.create_and_add_in_cache_concept(sheerka, Concept(name="foo", body="'foo'"))
|
||||
|
||||
res = sheerka.evaluate_user_input("hello foo")
|
||||
assert len(res) == 1
|
||||
@@ -238,9 +238,9 @@ as:
|
||||
|
||||
def test_i_cannot_manage_duplicate_concepts_when_the_values_are_different(self):
|
||||
sheerka = self.get_sheerka()
|
||||
self.create_concept_lite(sheerka, Concept(name="hello a", body="'hello ' + a"), variables=["a"])
|
||||
self.create_concept_lite(sheerka, Concept(name="hello foo", body="'hello foo'"))
|
||||
self.create_concept_lite(sheerka, Concept(name="foo", body="'another value'"))
|
||||
self.create_and_add_in_cache_concept(sheerka, Concept(name="hello a", body="'hello ' + a"), variables=["a"])
|
||||
self.create_and_add_in_cache_concept(sheerka, Concept(name="hello foo", body="'hello foo'"))
|
||||
self.create_and_add_in_cache_concept(sheerka, Concept(name="foo", body="'another value'"))
|
||||
|
||||
res = sheerka.evaluate_user_input("hello foo")
|
||||
assert len(res) == 1
|
||||
@@ -894,9 +894,31 @@ as:
|
||||
res = sheerka.evaluate_user_input("eval four > three")
|
||||
assert res[0].status
|
||||
|
||||
res = sheerka.evaluate_user_input("get_concepts_weights('some_prop')")
|
||||
assert sheerka.get_concepts_weights("some_prop") == {'1001': 1, '1002': 2, '1003': 3, '1004': 4}
|
||||
|
||||
def test_i_can_evaluate_expression_when_using_token_concept(self):
|
||||
sheerka, context, one, two, plus = self.init_concepts(
|
||||
Concept("one", body="1"),
|
||||
Concept("two", body="2"),
|
||||
self.from_def_concept("<", "a < b", ["a", "b"], body="is_less_than('some_prop', a, b)")
|
||||
)
|
||||
|
||||
expression = "c:one: < c:two:"
|
||||
res = sheerka.evaluate_user_input(expression)
|
||||
assert res[0].status
|
||||
assert res[0].body == {'1001': 1, '1002': 2, '1003': 3, '1004': 4}
|
||||
assert res[0].body == CMV(plus, a="c:one:", b="c:two:")
|
||||
assert res[0].body.a is None # concept is not evaluated
|
||||
assert res[0].body.b is None # concept is not evaluated
|
||||
|
||||
expression = "eval c:one: < c:two:"
|
||||
res = sheerka.evaluate_user_input(expression)
|
||||
assert res[0].status
|
||||
assert sheerka.isinstance(res[0].body, BuiltinConcepts.SUCCESS)
|
||||
assert sheerka.get_concepts_weights("some_prop") == {'1001': 1, '1002': 2}
|
||||
|
||||
expression = "eval one < two"
|
||||
res = sheerka.evaluate_user_input(expression)
|
||||
assert not res[0].status
|
||||
|
||||
|
||||
class TestSheerkaNonRegFile(TestUsingFileBasedSheerka):
|
||||
|
||||
@@ -163,10 +163,10 @@ class TestBaseNodeParser(TestUsingMemoryBasedSheerka):
|
||||
def test_concepts_are_defined_once(self):
|
||||
sheerka = self.get_sheerka()
|
||||
context = self.get_context(sheerka)
|
||||
good = self.create_concept_lite(sheerka, "good")
|
||||
foo = self.create_concept_lite(sheerka, "foo", bnf=ConceptExpression("good"))
|
||||
bar = self.create_concept_lite(sheerka, "bar", bnf=ConceptExpression("good"))
|
||||
baz = self.create_concept_lite(sheerka, "baz", bnf=OrderedChoice(
|
||||
good = self.create_and_add_in_cache_concept(sheerka, "good")
|
||||
foo = self.create_and_add_in_cache_concept(sheerka, "foo", bnf=ConceptExpression("good"))
|
||||
bar = self.create_and_add_in_cache_concept(sheerka, "bar", bnf=ConceptExpression("good"))
|
||||
baz = self.create_and_add_in_cache_concept(sheerka, "baz", bnf=OrderedChoice(
|
||||
ConceptExpression("foo"),
|
||||
ConceptExpression("bar")))
|
||||
|
||||
@@ -183,8 +183,8 @@ class TestBaseNodeParser(TestUsingMemoryBasedSheerka):
|
||||
sheerka = self.get_sheerka()
|
||||
context = self.get_context(sheerka)
|
||||
|
||||
a = self.create_concept_lite(sheerka, "a", bnf=Sequence("one", "two"))
|
||||
b = self.create_concept_lite(sheerka, "b", bnf=Sequence(ConceptExpression("a"), "two"))
|
||||
a = self.create_and_add_in_cache_concept(sheerka, "a", bnf=Sequence("one", "two"))
|
||||
b = self.create_and_add_in_cache_concept(sheerka, "b", bnf=Sequence(ConceptExpression("a"), "two"))
|
||||
|
||||
concepts_by_first_keywords = BaseNodeParser.get_concepts_by_first_keyword(
|
||||
context, [a, b]).body
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept
|
||||
from core.concept import Concept, CMV
|
||||
from core.tokenizer import Tokenizer
|
||||
from parsers.ExactConceptParser import ExactConceptParser
|
||||
|
||||
@@ -49,10 +49,10 @@ class TestExactConceptParser(TestUsingMemoryBasedSheerka):
|
||||
('__var__1', '__var__0', '__var__1')}
|
||||
# TODO: the last tuple is not possible, so the algo can be improved
|
||||
|
||||
def test_i_can_recognize_a_simple_concept(self):
|
||||
def test_i_can_parse_a_simple_concept(self):
|
||||
sheerka = self.get_sheerka(singleton=True)
|
||||
context = self.get_context(sheerka)
|
||||
concept = self.create_concept_lite(sheerka, "hello world")
|
||||
concept = self.create_and_add_in_cache_concept(sheerka, "hello world")
|
||||
|
||||
source = "hello world"
|
||||
results = ExactConceptParser().parse(context, source)
|
||||
@@ -62,12 +62,13 @@ class TestExactConceptParser(TestUsingMemoryBasedSheerka):
|
||||
assert results[0].status
|
||||
assert concept_found == concept
|
||||
assert not concept_found.metadata.need_validation
|
||||
assert not concept_found.metadata.is_evaluated
|
||||
|
||||
def test_i_can_recognize_concepts_defined_several_times(self):
|
||||
def test_i_can_parse_concepts_defined_several_times(self):
|
||||
sheerka = self.get_sheerka(singleton=True)
|
||||
context = self.get_context(sheerka)
|
||||
self.create_concept_lite(sheerka, "hello world")
|
||||
self.create_concept_lite(sheerka, "hello a", variables=["a"])
|
||||
self.create_and_add_in_cache_concept(sheerka, "hello world")
|
||||
self.create_and_add_in_cache_concept(sheerka, "hello a", variables=["a"])
|
||||
|
||||
source = "hello world"
|
||||
results = ExactConceptParser().parse(context, source)
|
||||
@@ -84,10 +85,10 @@ class TestExactConceptParser(TestUsingMemoryBasedSheerka):
|
||||
assert results[1].value.value.name == "hello world"
|
||||
assert not results[1].value.value.metadata.need_validation
|
||||
|
||||
def test_i_can_recognize_a_concept_with_variables(self):
|
||||
def test_i_can_parse_a_concept_with_variables(self):
|
||||
sheerka = self.get_sheerka(singleton=True)
|
||||
context = self.get_context(sheerka)
|
||||
concept = self.create_concept_lite(sheerka, "a + b", ["a", "b"])
|
||||
concept = self.create_and_add_in_cache_concept(sheerka, "a + b", ["a", "b"])
|
||||
|
||||
source = "10 + 5"
|
||||
results = ExactConceptParser().parse(context, source)
|
||||
@@ -96,15 +97,14 @@ class TestExactConceptParser(TestUsingMemoryBasedSheerka):
|
||||
assert results[0].status
|
||||
|
||||
concept_found = results[0].value.value
|
||||
assert concept_found.key == concept.key
|
||||
assert variable_def(concept_found, "a") == "10"
|
||||
assert variable_def(concept_found, "b") == "5"
|
||||
assert concept_found == CMV(concept, a="10", b="5")
|
||||
assert concept_found.metadata.need_validation
|
||||
assert not concept_found.metadata.is_evaluated
|
||||
|
||||
def test_i_can_recognize_a_concept_with_duplicate_variables(self):
|
||||
def test_i_can_parse_a_concept_with_duplicate_variables(self):
|
||||
sheerka = self.get_sheerka(singleton=True)
|
||||
context = self.get_context(sheerka)
|
||||
concept = self.create_concept_lite(sheerka, "a + b + a", ["a", "b"])
|
||||
concept = self.create_and_add_in_cache_concept(sheerka, "a + b + a", ["a", "b"])
|
||||
|
||||
source = "10 + 5 + 10"
|
||||
results = ExactConceptParser(max_word_size=5).parse(context, source)
|
||||
@@ -113,11 +113,54 @@ class TestExactConceptParser(TestUsingMemoryBasedSheerka):
|
||||
assert results[0].status
|
||||
|
||||
concept_found = results[0].value.value
|
||||
assert concept_found.key == concept.key
|
||||
assert variable_def(concept_found, "a") == "10"
|
||||
assert variable_def(concept_found, "b") == "5"
|
||||
assert concept_found == CMV(concept, a="10", b="5")
|
||||
assert concept_found.metadata.need_validation
|
||||
|
||||
def test_i_can_parse_concept_when_defined_using_from_def(self):
|
||||
sheerka, context, plus = self.init_concepts(
|
||||
self.from_def_concept("+", "a + b", ["a", "b"])
|
||||
)
|
||||
|
||||
source = "10 + 5"
|
||||
results = ExactConceptParser().parse(context, source)
|
||||
concept_found = results[0].value.value
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0].status
|
||||
assert concept_found == CMV(plus, a="10", b="5")
|
||||
assert concept_found.metadata.need_validation
|
||||
assert not concept_found.metadata.is_evaluated
|
||||
|
||||
def test_i_can_parse_concept_token(self):
|
||||
sheerka, context, foo = self.init_concepts("foo")
|
||||
|
||||
source = "c:foo:"
|
||||
results = ExactConceptParser().parse(context, source)
|
||||
concept_found = results[0].value.value
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0].status
|
||||
assert concept_found == foo
|
||||
assert not concept_found.metadata.need_validation
|
||||
assert concept_found.metadata.is_evaluated
|
||||
|
||||
def test_i_can_parse_concept_with_concept_tokens(self):
|
||||
sheerka, context, one, two, plus = self.init_concepts(
|
||||
"one",
|
||||
"two",
|
||||
self.from_def_concept("plus", "a plus b", ["a", "b"])
|
||||
)
|
||||
|
||||
source = "c:one: plus c:two:"
|
||||
results = ExactConceptParser().parse(context, source)
|
||||
concept_found = results[0].value.value
|
||||
|
||||
assert len(results) == 1
|
||||
assert results[0].status
|
||||
assert concept_found == CMV(plus, a="c:one:", b="c:two:")
|
||||
assert concept_found.metadata.need_validation
|
||||
assert not concept_found.metadata.is_evaluated
|
||||
|
||||
def test_i_can_manage_unknown_concept(self):
|
||||
context = self.get_context(self.get_sheerka(singleton=True))
|
||||
source = "def concept hello" # this is not a concept by itself
|
||||
|
||||
Reference in New Issue
Block a user