[docs]
class Function:
__slots__ = ("name",)
def __init__(self, name: str):
self.name: str = name.lower()
def __str__(self):
return self.name
[docs]
def wrap(self, content: str) -> str:
return f"{self.name}({content})"
[docs]
def pretty_str(self) -> str:
return str(self).capitalize()
def __call__(self, *args, **kwargs):
if len(args) == 0 or args[0] is None:
return self
raise NotImplementedError
[docs]
def is_parametrized(self) -> bool:
return False
[docs]
def get(self):
raise NotImplementedError
[docs]
def rule_head_dependant(self) -> bool:
return False
[docs]
def process_head(self, head) -> "Function":
pass
[docs]
class Combination(Function):
# Aggregation
AVG: "Combination"
MAX: "Combination"
MIN: "Combination"
SUM: "Combination"
COUNT: "Combination"
# Combination
PRODUCT: "Combination"
ELPRODUCT: "Combination"
SOFTMAX: "Combination"
SPARSEMAX: "Combination"
CROSSSUM: "Combination"
CONCAT: "Combination"
COSSIM: "Combination"
[docs]
class Aggregation(Function):
AVG: "Aggregation"
MAX: "Aggregation"
MIN: "Aggregation"
SUM: "Aggregation"
COUNT: "Aggregation"
CONCAT: "Aggregation"
SOFTMAX: "Aggregation"