diff --git a/hyperon_das/pattern_matcher/__init__.py b/hyperon_das/pattern_matcher/__init__.py new file mode 100644 index 00000000..8c207042 --- /dev/null +++ b/hyperon_das/pattern_matcher/__init__.py @@ -0,0 +1 @@ +from .pattern_matcher import * # noqa diff --git a/hyperon_das/pattern_matcher/pattern_matcher.py b/hyperon_das/pattern_matcher/pattern_matcher.py new file mode 100644 index 00000000..f6d0dfba --- /dev/null +++ b/hyperon_das/pattern_matcher/pattern_matcher.py @@ -0,0 +1,116 @@ +from abc import ABC, abstractmethod +from typing import Any, Dict, List, Optional + +from hyperon_das_atomdb import AtomDB + + +class PatternMatchingAnswer: + def __init__(self): + pass + + +class LogicalExpression(ABC): + @abstractmethod + def matched( + self, + db: AtomDB, + answer: PatternMatchingAnswer, + extra_parameters: Optional[Dict[str, Any]] = None, + ) -> bool: + pass + + +class Atom(LogicalExpression, ABC): + def __init__(self, atom_type: str): + pass + + @abstractmethod + def get_handle(self, db: AtomDB) -> str: + pass + + +class Node(Atom): + def __init__(self, node_type: str, node_name: str): + pass + + def get_handle(self, db: AtomDB) -> str: + return "" + + def matched( + self, + db: AtomDB, + answer: PatternMatchingAnswer, + extra_parameters: Optional[Dict[str, Any]] = None, + ) -> bool: + return True + + +class Link(Atom): + def __init__(self, link_type: str, targets: List[Atom], ordered: bool): + pass + + def get_handle(self, db: AtomDB) -> str: + return "" + + def matched( + self, + db: AtomDB, + answer: PatternMatchingAnswer, + extra_parameters: Optional[Dict[str, Any]] = None, + ) -> bool: + return True + + +class Variable(Atom): + def __init__(self, variable_name: str): + pass + + def get_handle(self, db: AtomDB) -> str: + return "" + + def matched( + self, + db: AtomDB, + answer: PatternMatchingAnswer, + extra_parameters: Optional[Dict[str, Any]] = None, + ) -> bool: + return True + + +class Not(LogicalExpression): + def __init__(self, term: LogicalExpression): + pass + + def matched( + self, + db: AtomDB, + answer: PatternMatchingAnswer, + extra_parameters: Optional[Dict[str, Any]] = None, + ) -> bool: + return True + + +class Or(LogicalExpression): + def __init__(self, terms: List[LogicalExpression]): + pass + + def matched( + self, + db: AtomDB, + answer: PatternMatchingAnswer, + extra_parameters: Optional[Dict[str, Any]] = None, + ) -> bool: + return True + + +class And(LogicalExpression): + def __init__(self, terms: List[LogicalExpression]): + pass + + def matched( + self, + db: AtomDB, + answer: PatternMatchingAnswer, + extra_parameters: Optional[Dict[str, Any]] = None, + ) -> bool: + return True