def _build_and_run(self, tree, source_string, file_name, similarity=None): assert self is not None # for the annotator (!) from prolog.interpreter.parsing import TermBuilder builder = TermBuilder() term = builder.build_query(tree) if isinstance(term, Callable) and term.signature().eq(callsig): self.run_query_in_current(term.argument_at(0)) else: term = self._term_expand(term) rule = self.add_rule(term) if similarity is not None: rule.scores = similarity.get_initial_rule_scores(term) else: rule.scores = [1.0] rule.file_name = file_name rule._init_source_info(tree, source_string) if len(rule.source.split(':-')) < 2: source = rule.source startArgs = source.find('(') + 1 pred = source[:startArgs-1] endArgs = source.find(')') nargs = len(source[startArgs:endArgs].split(',')) key = pred + '/' + str(nargs) if key in self.rule2index: rule_index = self.rule2index[key] self.index2rule[rule_index] = key else: if rule.source in self.rule2index: rule_index = self.rule2index[rule.source] self.index2rule[rule_index] = rule
def _build_and_run(self, tree, source_string, file_name): assert self is not None # for the annotator (!) from prolog.interpreter.parsing import TermBuilder builder = TermBuilder() term = builder.build_query(tree) if isinstance(term, Callable) and term.signature().eq(callsig): self.run_query_in_current(term.argument_at(0)) else: term = self._term_expand(term) rule = self.add_rule(term) rule.file_name = file_name rule._init_source_info(tree, source_string)
def _build_and_run(self, tree, source_string, file_name): assert self is not None # for the annotator (!) from prolog.interpreter.parsing import TermBuilder builder = TermBuilder() term = builder.build_query(tree) if isinstance(term, Callable) and term.signature().eq(callsig): self.run_query_in_current(term.argument_at(0)) else: term = self._term_expand(term) rule = self.add_rule(term) rule.file_name = file_name rule._init_source_info(tree, source_string)
def _build_and_run(self, tree, source_string, file_name, similarity=None): assert self is not None # for the annotator (!) from prolog.interpreter.parsing import TermBuilder builder = TermBuilder() term = builder.build_query(tree) if isinstance(term, Callable) and term.signature().eq(callsig): self.run_query_in_current(term.argument_at(0)) else: term = self._term_expand(term) rule = self.add_rule(term) if similarity is not None: rule.scores = similarity.get_initial_rule_scores(term) else: rule.scores = [1.0] rule.file_name = file_name rule._init_source_info(tree, source_string) rule_index = self.rule2index[rule.source] self.index2rule[rule_index] = rule