def extractor(node,firsthit,leaf): """ Returns node representation """ if leaf: return tibFormat(node.label[1][0]).lower() #.replace('"','') #if leaf: return tibFormat(node.label[1][1] + "(" + node.label[2] + ")") else: return tibFormat(node.label[1][0])
def extractor(node, firsthit, leaf): ''' Returns node representation ''' global magicCount if leaf: # Alignment magic: boy-2 -> int(2), combine this with the magicCount (for lack of a better name) alignments = [ "%d-%d" % (magicCount, int(align)) for align in node.align ] #alignments = ["%d-%d"%(magicCount,int(align.split("-")[1])-1) for align in node.align] magicCount += 1 return (tibFormat("%s" % node.label[1][0]), alignments, "child") #return (tibFormat("%s"%node.label[1][1]),alignments,"child") else: state = "q" if node.rule == "DL": #state = ("".join([y.tags[x] for y in node.children for x in sorted(y.tags.keys())])).lower() if state == "": state = "delex" if node.label[1][0] == "root" and node.rule != "DL": state = "root" return ("%s" % tibFormat(node.label[1][0]), [], state)
def extractor(node,firsthit,leaf): ''' Returns node representation ''' global magicCount if leaf: # Alignment magic: boy-2 -> int(2), combine this with the magicCount (for lack of a better name) alignments = ["%d-%d"%(magicCount,int(align)) for align in node.align] #alignments = ["%d-%d"%(magicCount,int(align.split("-")[1])-1) for align in node.align] magicCount += 1 return (tibFormat("%s"%node.label[1][0]),alignments,"child") #return (tibFormat("%s"%node.label[1][1]),alignments,"child") else: state = "q" if node.rule == "DL": #state = ("".join([y.tags[x] for y in node.children for x in sorted(y.tags.keys())])).lower() if state == "": state = "delex" if node.label[1][0] == "root" and node.rule != "DL": state = "root" return ("%s"%tibFormat(node.label[1][0]),[],state)