Skip to content

Commit

Permalink
Create empty implementation of pattern_matcher package for back-compa…
Browse files Browse the repository at this point in the history
…bibility with DAS Gate
  • Loading branch information
Andre Senna committed Sep 24, 2024
1 parent 7e323e8 commit cd8e89b
Show file tree
Hide file tree
Showing 2 changed files with 121 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
120 changes: 120 additions & 0 deletions hyperon_das/pattern_matcher/pattern_matcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
from abc import ABC, abstractmethod
from typing import Any, Dict, FrozenSet, List, Optional, Set, Union

from hyperon_das_atomdb import WILDCARD, 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 cd8e89b

Please sign in to comment.