Example #1
0
 def _oracle(self, forest):
     sc, parseval, tr, edgelist = forest_oracle(forest, forest.goldtree)
     forest.oracle_tree = tr
     forest.oracle_fvector = Hyperedge.deriv2fvector(edgelist)
     if Decoder.MAX_NUM_BRACKETS < 0:
         forest.oracle_size_ratio = 1
     else:
         forest.oracle_size_ratio = len(tr.all_label_spans()) / Decoder.MAX_NUM_BRACKETS
Example #2
0
 def recover_oracle(self):
     '''oracle is already stored implicitly in the forest
     returns best_score, best_parseval, best_tree, edgelist
     '''
     edgelist = self.root.get_oracle_edgelist()
     fv = Hyperedge.deriv2fvector(edgelist)
     tr = Hyperedge.deriv2tree(edgelist)
     bleu_p1 = self.bleu.rescore(tr)
     return bleu_p1, tr, fv, edgelist
Example #3
0
def extract_oracle(forest):
    """oracle is already stored implicitly in the forest
       returns best_score, best_parseval, best_tree, edgelist
    """
    global implicit_oracle
    implicit_oracle = True
    edgelist = get_edgelist(forest.root)
    fv = Hyperedge.deriv2fvector(edgelist)
    tr = Hyperedge.deriv2tree(edgelist)
    return fv[0], Parseval(), tr, edgelist