def __call__(self, item): from .interpretator import Chain assert_type(item, Chain) if item.key: return item.key else: return join_normalized_tokens(item.tokens)
def prepare_terms(items): main = None terms = [] for index, item in enumerate(items): assert_type(item, (Predicate, Rule, Main)) if isinstance(item, Main): if main is not None: raise ValueError('>1 main') main = index item = item.term terms.append(item) if main is None: main = 0 return terms, main
def __call__(self, item): from .interpretator import Chain assert_type(item, Chain) return join_inflected_tokens(item.tokens, self.grams)
def __init__(self, term): from yargy_uk.rule import Rule from yargy_uk.predicates import Predicate assert_type(term, (Rule, Predicate)) self.term = term
def __init__(self, relation): super(NotRelation, self).__init__() assert_type(relation, Relation) self.relation = relation
def __init__(self, relations): super(RelationsComposition, self).__init__() relations = list(relations) for relation in relations: assert_type(relation, Relation) self.relations = relations
def __init__(self, productions): productions = list(productions) for production in productions: assert_type(production, Production) self.productions = productions
def __init__(self, rule, relation): from yargy_uk.relations import Relation super(RelationRule, self).__init__(rule) assert_type(relation, Relation) self.relation = relation
def __init__(self, rule, interpretator): from yargy_uk.interpretation import Interpretator super(InterpretationRule, self).__init__(rule) assert_type(interpretator, Interpretator) self.interpretator = interpretator
def __init__(self, rule, name): super(NamedRule, self).__init__(rule) assert_type(name, string_type) self.name = name
def __init__(self, rule, reverse_repeatable, reverse_optional): WrapperRule.__init__(self, rule) assert_type(reverse_repeatable, bool) assert_type(reverse_optional, bool) self.reverse_repeatable = reverse_repeatable self.reverse_optional = reverse_optional
def __init__(self, rule, reverse): WrapperRule.__init__(self, rule) assert_type(reverse, bool) self.reverse = reverse
def __init__(self, rule): assert_type(rule, Rule) self.rule = rule
def __init__(self, rules): rules = list(rules) for rule in rules: assert_type(rule, Rule) self.rules = rules
def __init__(self, predicate): assert_type(predicate, Predicate) self.predicate = predicate
def __init__(self, predicates): predicates = list(predicates) for predicate in predicates: assert_type(predicate, Predicate) self.predicates = predicates