def __init__(self, language): assert isinstance(language, dict), language for name, cost in language.iteritems(): assert isinstance(name, str), name assert isinstance(cost, float), cost assert cost > 0, cost language = language.copy() language['HOLE'] = 0.0 self._language = intern_keys(language)
import re from pomagma.compiler.util import intern_keys from pomagma.compiler.util import memoize_arg re_const = re.compile("[A-Z]+$") NARGS_TABLE = intern_keys( { "UnaryRelation": 1, "Equation": 2, "BinaryRelation": 2, "NullaryFunction": 0, "InjectiveFunction": 1, "BinaryFunction": 2, "SymmetricFunction": 2, "Variable": 0, "UnaryMeta": 1, "BinaryMeta": 2, "TernaryMeta": 3, } ) ARITY_TABLE = intern_keys( { "EQUAL": "Equation", "CLOSED": "UnaryRelation", "NCLOSED": "UnaryRelation", "RETURN": "UnaryRelation", "NRETURN": "UnaryRelation", "LESS": "BinaryRelation",
import re from pomagma.compiler.util import intern_keys, memoize_arg re_const = re.compile('[A-Z]+$') NARGS_TABLE = intern_keys({ 'UnaryRelation': 1, 'Equation': 2, 'BinaryRelation': 2, 'NullaryFunction': 0, 'InjectiveFunction': 1, 'BinaryFunction': 2, 'SymmetricFunction': 2, 'Variable': 0, 'UnaryMeta': 1, 'BinaryMeta': 2, 'TernaryMeta': 3, }) ARITY_TABLE = intern_keys({ 'EQUAL': 'Equation', 'CLOSED': 'UnaryRelation', 'NCLOSED': 'UnaryRelation', 'RETURN': 'UnaryRelation', 'NRETURN': 'UnaryRelation', 'LESS': 'BinaryRelation', 'NLESS': 'BinaryRelation', 'CO': 'InjectiveFunction', 'QUOTE': 'InjectiveFunction',