Introduced ParserInput
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept, ConceptParts, DoNotResolve, DEFINITION_TYPE_DEF, CC
|
||||
from core.sheerka.services.SheerkaExecute import ParserInput
|
||||
from parsers.BaseNodeParser import CNC, UTN, CN
|
||||
from parsers.BnfNodeParser import BnfNodeParser, StrMatch, TerminalNode, NonTerminalNode, Sequence, OrderedChoice, \
|
||||
Optional, ZeroOrMore, OneOrMore, ConceptExpression
|
||||
@@ -95,7 +96,7 @@ class TestBnfNodeParser(TestUsingMemoryBasedSheerka):
|
||||
|
||||
parser = BnfNodeParser()
|
||||
parser.init_from_concepts(context, updated)
|
||||
parser.reset_parser(context, text)
|
||||
parser.reset_parser(context, ParserInput(text))
|
||||
|
||||
bnf_parsers_helpers = parser.get_concepts_sequences()
|
||||
|
||||
@@ -113,34 +114,11 @@ class TestBnfNodeParser(TestUsingMemoryBasedSheerka):
|
||||
my_map, text, expected, multiple_result, post_init_concepts
|
||||
)
|
||||
return sequences
|
||||
# sheerka, context, *updated = self.init_concepts(*my_map.values(), create_new=False, singleton=True)
|
||||
# if not multiple_result:
|
||||
# expected_array = [compute_expected_array(my_map, text, expected)]
|
||||
# else:
|
||||
# expected_array = [compute_expected_array(my_map, text, e) for e in expected]
|
||||
#
|
||||
# if post_init_concepts:
|
||||
# post_init_concepts(sheerka, context)
|
||||
#
|
||||
# parser = BnfNodeParser()
|
||||
# parser.init_from_concepts(context, updated)
|
||||
# parser.reset_parser(context, text)
|
||||
#
|
||||
# bnf_parsers_helpers = parser.get_concepts_sequences()
|
||||
#
|
||||
# assert len(bnf_parsers_helpers) == len(expected_array)
|
||||
# for parser_helper, expected_sequence in zip(bnf_parsers_helpers, expected_array):
|
||||
# assert parser_helper.sequence == expected_sequence
|
||||
#
|
||||
# if len(bnf_parsers_helpers) == 1:
|
||||
# return bnf_parsers_helpers[0].sequence
|
||||
# else:
|
||||
# return [pe.sequence for pe in bnf_parsers_helpers]
|
||||
|
||||
def test_i_cannot_parse_empty_strings(self):
|
||||
sheerka, context, parser = self.init_parser({}, singleton=True)
|
||||
|
||||
res = parser.parse(context, "")
|
||||
res = parser.parse(context, ParserInput(""))
|
||||
|
||||
assert not res.status
|
||||
assert sheerka.isinstance(res.body, BuiltinConcepts.NOT_FOR_ME)
|
||||
@@ -738,7 +716,7 @@ class TestBnfNodeParser(TestUsingMemoryBasedSheerka):
|
||||
sheerka, context, parser = self.init_parser(my_map, singleton=True)
|
||||
parser.init_from_concepts(context, my_map.values())
|
||||
|
||||
parser.reset_parser(context, "one three")
|
||||
parser.reset_parser(context, ParserInput("one three"))
|
||||
sequences = parser.get_concepts_sequences()
|
||||
sequence = parser.get_valid(sequences)
|
||||
|
||||
@@ -756,7 +734,7 @@ class TestBnfNodeParser(TestUsingMemoryBasedSheerka):
|
||||
def test_i_can_parse(self, parser_input, expected_status, expected):
|
||||
sheerka, context, parser = self.init_parser(init_from_sheerka=True)
|
||||
|
||||
res = parser.parse(context, parser_input)
|
||||
res = parser.parse(context, ParserInput(parser_input))
|
||||
expected_array = compute_expected_array(cmap, parser_input, expected)
|
||||
parser_result = res.value
|
||||
concepts_nodes = res.value.value
|
||||
@@ -771,7 +749,7 @@ class TestBnfNodeParser(TestUsingMemoryBasedSheerka):
|
||||
parser_input = "def one"
|
||||
expected = [CNC("def number", source="def one", number="one", one="one")]
|
||||
|
||||
res = parser.parse(context, parser_input)
|
||||
res = parser.parse(context, ParserInput(parser_input))
|
||||
expected_array = compute_expected_array(cmap, parser_input, expected)
|
||||
expected_array[0].compiled["def"] = cmap["def_only"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user