Skip to content

Commit

Permalink
Merge pull request #347 from singnet/senna-hotfix-4
Browse files Browse the repository at this point in the history
[HOTFIX] Create empty implementation of pattern_matcher package
  • Loading branch information
andre-senna authored Sep 24, 2024
2 parents 7e323e8 + ae445fb commit cc916ed
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
1 change: 1 addition & 0 deletions hyperon_das/pattern_matcher/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .pattern_matcher import * # noqa
116 changes: 116 additions & 0 deletions hyperon_das/pattern_matcher/pattern_matcher.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cc916ed

Please sign in to comment.