Пример #1
0
    def node_fn(unused_span_begin, unused_span_end, rule, children):
        """Represent nodes as (target string, int count of possible derivations)."""
        target_strings = [target_string for target_string, _ in children]
        new_target_string = qcfg_rule.apply_target(rule, target_strings)

        child_counts = [child_count for _, child_count in children]

        count = _aggregate_counts(child_counts)

        return (new_target_string, count)
Пример #2
0
    def __init__(self, score_fn, span_begin, span_end, rule, children):
        # Get score.
        application_score = score_fn(rule, span_begin, span_end)
        self.score = application_score
        for node in children:
            self.score += node.score

        # Get target string.
        target_string = qcfg_rule.apply_target(
            rule, [node.target_string for node in children])
        self.target_string = target_string

        application = ScoredAnchoredRuleApplication(rule, span_begin, span_end,
                                                    application_score)
        # List of ScoredAnchoredRuleApplication, which can be used to inspect
        # parse tree for a given prediction.
        self.applications = [application]
        for node in children:
            for application in node.applications:
                self.applications.append(application)
Пример #3
0
 def node_fn(unused_span_begin, unused_span_end, rule, children):
     """Represent nodes as target strings."""
     return qcfg_rule.apply_target(rule, children)
Пример #4
0
 def node_fn(span_begin, span_end, rule, children):
     target_string = qcfg_rule.apply_target(
         rule, [node.target_string for node in children])
     return RuleApplicationNode(rule, children, span_begin, span_end,
                                target_string)
Пример #5
0
def _node_fn(unused_span_begin, unused_span_end, rule, children):
  """Nodes will represent target strings."""
  return qcfg_rule.apply_target(rule, children)