Implemented SheerkaOntology
This commit is contained in:
@@ -5,23 +5,26 @@ from parsers.RuleParser import RuleParser, RuleNotFoundError
|
||||
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
my_rules = {("__rets", "list(__rets)")}
|
||||
my_rules = [("__rets", "list(__rets)")]
|
||||
|
||||
|
||||
class TestRuleParser(TestUsingMemoryBasedSheerka):
|
||||
sheerka = None
|
||||
shared_ontology = None
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
t = cls()
|
||||
cls.sheerka, context, _ = t.init_parser(my_rules)
|
||||
init_test_helper = cls().init_test(cache_only=False, ontology="#TestRuleParser#")
|
||||
sheerka, context, *updated = init_test_helper.with_rules(*my_rules).unpack()
|
||||
|
||||
def init_parser(self, rules=None):
|
||||
if rules is not None:
|
||||
sheerka, context, *concepts = self.init_format_rules(*rules)
|
||||
cls.shared_ontology = sheerka.get_ontology(context)
|
||||
sheerka.pop_ontology()
|
||||
|
||||
def init_parser(self, rules=None, **kwargs):
|
||||
if rules is None:
|
||||
sheerka, context = self.init_test().unpack()
|
||||
sheerka.add_ontology(context, self.shared_ontology)
|
||||
else:
|
||||
sheerka = TestRuleParser.sheerka
|
||||
context = self.get_context(sheerka)
|
||||
sheerka, context, *updated = self.init_test().with_rules(*rules, **kwargs).unpack()
|
||||
|
||||
parser = RuleParser()
|
||||
return sheerka, context, parser
|
||||
|
||||
Reference in New Issue
Block a user