예제 #1
0
 def isControl(self,x_prop_ana, y_prop_ana,a_tree_document,head_rules):
     he = head()
     x_pred_ana = x_prop_ana.predicate
     y_pred_ana = y_prop_ana.predicate
     x_pred_lemma_sense_num, x_pred_type, x_pred_token_index, x_sentence_index, x_document_id = x_pred_ana.id.split("@")[:5]
     y_pred_lemma_sense_num, y_pred_type, y_pred_token_index, y_sentence_index, y_document_id = y_pred_ana.id.split("@")[:5]
     x_pred_token_index = int(x_pred_token_index)
     y_pred_token_index = int(y_pred_token_index)
     x_sentence_index = int(x_sentence_index)
     y_sentence_index = int(y_sentence_index)
     x_pred_node = a_tree_document[x_sentence_index].leaves()[x_pred_token_index]
     y_pred_node = a_tree_document[y_sentence_index].leaves()[y_pred_token_index]
     
     if x_pred_token_index < y_pred_token_index:
         vp_node = self.getVpAntecedent(x_pred_ana, a_tree_document)
         
         if not he.isHeadLeaf(head_rules,vp_node, x_pred_node):
             return False
         first_child = vp_node.children[0]
         x_right_sibling = self.getRightSibling(first_child)
         while x_right_sibling != None and not re.match("S$",x_right_sibling.tag.split("-")[0]):
             x_right_sibling = self.getRightSibling(x_right_sibling)
         if x_right_sibling != None and re.match("S$", x_right_sibling.tag.split("-")[0]) and he.isHeadLeaf(head_rules,x_right_sibling,y_pred_node):
             
             return True
   
     return False
예제 #2
0
def main():
    ssm = semSynMap()
    a_ontonotes = ssm.getAOntonotes()
    #dev_test="/nfs/guest/yaqiny/Dropbox/Code/generation/dev_test_id.txt"
    #dev_test="/home/nlg-01/yy_140/generation/Code/generation/dev_test_id.txt"
    dev_test="/Users/yaqin276/Dropbox/Code/generation/dev_test_id.txt"
    he = head()
    #head_rules = he.loadHeadrules("/nfs/guest/yaqiny/Dropbox/Code/OntonotesUtil/ontonotes-db-tool-v0.999b/data/headrules.txt")
    #head_rules = he.loadHeadrules("/home/nlg-01/yy_140/generation/Code/OntonotesUtil/ontonotes-db-tool-v0.999b/data/headrules.txt")
    head_rules = he.loadHeadrules("/Users/yaqin276/Dropbox/Code/OntonotesUtil/ontonotes-db-tool-v0.999b/data/headrules.txt")
    #output_dir="/nfs/guest/yaqiny/Dropbox/Code/generation/rules/prop-anotation/propbank"
    #output_dir="/home/nlg-01/yy_140/generation/Code/generation/rules/prop-anotation/propbank"
    output_dir="/Users/yaqin276/Dropbox/Code/generation/rules/prop-anotation/propbank"
    ssm.traverseTrees(output_dir,a_ontonotes,dev_test,head_rules)