def transform(self, relations): for i, relation in enumerate(relations): if relation.rel == 'parataxis': if relation.word == 'mean' \ and len(relation.deps) == 1\ and relations[relation.deps[0]].word == "I": delete_indices(relations, [i, relation.deps[0]])
def transform(self, relations): for index, relation in enumerate(relations): if relation.rel in ('null', 'ROOT', 'xcomp', 'rcmod')\ and relation.tag in ('VBZ', 'VBD', 'VBP', 'VB')\ and relation.word in self.verb_forms: xcomp_indices = Relation.get_children_with_dep( 'xcomp', relations, index) if xcomp_indices == []: continue else: xcomp_index = xcomp_indices[0] if relations[xcomp_index].tag == 'VB': aux_indices = Relation.get_children_with_dep( 'aux', relations, xcomp_index) to_index = [ index for index in aux_indices if relations[index].tag == 'TO' ][0] # Append 'to' and the xcomp head to main verb. relations[index].word += ' to ' + \ relations[xcomp_index].word # Remove 'aux' and 'xcomp' relations. delete_indices(relations, [to_index, xcomp_index]) # Change head of relations pointing to xcomp to point to # the main verb. for i, rel in enumerate(relations): if rel.head == xcomp_index - 2: rel.head = index relations[index].deps.append(i) relations[index].deps.sort()
def transform(self, relations): for index, relation in enumerate(relations): if relation.rel in ('null', 'ROOT', 'xcomp', 'rcmod')\ and relation.tag in ('VBZ', 'VBD', 'VBP', 'VB')\ and relation.word in self.verb_forms: xcomp_indices = Relation.get_children_with_dep('xcomp', relations, index) if xcomp_indices == []: continue else: xcomp_index = xcomp_indices[0] if relations[xcomp_index].tag == 'VB': aux_indices = Relation.get_children_with_dep('aux', relations, xcomp_index) to_index = [index for index in aux_indices if relations[index].tag == 'TO'][0] # Append 'to' and the xcomp head to main verb. relations[index].word += ' to ' + \ relations[xcomp_index].word # Remove 'aux' and 'xcomp' relations. delete_indices(relations, [to_index, xcomp_index]) # Change head of relations pointing to xcomp to point to # the main verb. for i, rel in enumerate(relations): if rel.head == xcomp_index - 2: rel.head = index relations[index].deps.append(i) relations[index].deps.sort()
def transform(self, relations): for i, relation in enumerate(relations): if relation.rel == 'parataxis': if relation.word == 'mean' \ and len(relation.deps) == 1\ and relations[relation.deps[0]].word == "I": delete_indices(relations, [i, relation.deps[0]])
def transform(self, relations): for i, relation in enumerate(relations): if relation.word\ and relation.word.lower() == 'first'\ and i + 2 < len(relations)\ and relations[i + 1].word == 'of'\ and relations[i + 2].word == 'all': relation.word += ' of all' relation.rel = 'advmod' delete_indices(relations, [i + 1, i + 2])
def transform(self, relations): for i, relation in enumerate(relations): if relation.word\ and relation.word.lower() == 'first'\ and i + 2 < len(relations)\ and relations[i + 1].word == 'of'\ and relations[i + 2].word == 'all': relation.word += ' of all' relation.rel = 'advmod' delete_indices(relations, [i + 1, i + 2])
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].tag == "EX": relations[i + 1].word = relations[i].word +\ ' ' + relations[i + 1].word indices_to_delete.append(i) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].tag == "EX": relations[i + 1].word = relations[i].word +\ ' ' + relations[i + 1].word indices_to_delete.append(i) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].word == 'at'\ and i + 1 < len(relations)\ and relations[i + 1].word == 'all'\ and not relations[i + 1].deps: relations[i].word = 'at all' indices_to_delete.append(i + 1) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].word == 'at'\ and i + 1 < len(relations)\ and relations[i + 1].word == 'all'\ and not relations[i + 1].deps: relations[i].word = 'at all' indices_to_delete.append(i + 1) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].word == 'up'\ and i + 1 < len(relations)\ and relations[i + 1].word == 'to': relations[i].word = 'up to' relations[i].tag = 'RB' indices_to_delete.append(i + 1) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].word == 'up'\ and i + 1 < len(relations)\ and relations[i + 1].word == 'to': relations[i].word = 'up to' relations[i].tag = 'RB' indices_to_delete.append(i + 1) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(1, len(relations)): if relations[i].word.lower() in ('up', 'down', 'right')\ and i + 1 < len(relations)\ and relations[i + 1].word == 'there': relations[i + 1].word = relations[i].word +\ ' ' + relations[i + 1].word indices_to_delete.append(i) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(1, len(relations)): if relations[i].word.lower() in ('up', 'down', 'right')\ and i + 1 < len(relations)\ and relations[i + 1].word == 'there': relations[i + 1].word = relations[i].word +\ ' ' + relations[i + 1].word indices_to_delete.append(i) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(1, len(relations)): if relations[i].word.lower() == 'not'\ and relations[i].tag == 'RB'\ and relations[i].head == i + 1\ and relations[i + 1].word == 'even'\ and relations[i + 1].tag == 'RB': relations[i + 1].word = relations[i].word +\ ' ' + relations[i + 1].word indices_to_delete.append(i) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(1, len(relations)): if relations[i].word.lower() == 'not'\ and relations[i].tag == 'RB'\ and relations[i].head == i + 1\ and relations[i + 1].word == 'even'\ and relations[i + 1].tag == 'RB': relations[i + 1].word = relations[i].word +\ ' ' + relations[i + 1].word indices_to_delete.append(i) delete_indices(relations, indices_to_delete)
def transform(self, relations): mwes = {} for relation in relations: if relation.rel == 'mwe': if relation.head not in mwes: mwes[relation.head] = [relation.address] else: mwes[relation.head].append(relation.address) for head, deps in mwes.items(): new_word = ' '.join([relations[i].word for i in sorted(deps + [head])]) relations[head].word = new_word delete_indices(relations, deps)
def transform(self, relations): mwes = {} for relation in relations: if relation.rel == 'mwe': if relation.head not in mwes: mwes[relation.head] = [relation.address] else: mwes[relation.head].append(relation.address) for head, deps in mwes.items(): new_word = ' '.join( [relations[i].word for i in sorted(deps + [head])]) relations[head].word = new_word delete_indices(relations, deps)
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].tag == "IN": if i + 1 < len(relations) and relations[i + 1].tag == "IN": relations[i].word += ' ' + relations[i + 1].word for j in range(i + 1, len(relations)): if relations[j].head == i + 1: relations[j].head = i relations[i].deps.append(j) relations[i].deps.sort() indices_to_delete.append(i + 1) delete_indices(relations, indices_to_delete)
def transform(self, relations): indices_to_delete = [] for i in range(len(relations)): if relations[i].tag == "IN": if i + 1 < len(relations) and relations[i + 1].tag == "IN": relations[i].word += ' ' + relations[i + 1].word for j in range(i + 1, len(relations)): if relations[j].head == i + 1: relations[j].head = i relations[i].deps.append(j) relations[i].deps.sort() indices_to_delete.append(i + 1) delete_indices(relations, indices_to_delete)
def transform(self, relations): for i, relation in enumerate(relations): if relation.word\ and relation.word.lower() == 'a'\ and i + 2 < len(relations)\ and relations[i + 1].word == 'number'\ and relations[i + 2].word == 'of': k = Relation.get_children_with_dep('adpobj', relations, i + 2)[0] relations[i].head = k relations[i].word = 'a number of' relations[k].head = relations[i + 1].head relations[k].rel = relations[i + 1].rel for j in range(i + 4, len(relations)): if relations[j].head == i + 1: relations[j].head = k delete_indices(relations, [i + 1, i + 2])
def transform(self, relations): for i, relation in enumerate(relations): if relation.word\ and relation.word.lower() == 'a'\ and i + 2 < len(relations)\ and relations[i + 1].word == 'couple'\ and relations[i + 2].word == 'of': k = Relation.get_children_with_dep('adpobj', relations, i + 2)[0] relations[i].head = k relations[i].word = 'a couple of' relations[k].head = relations[i + 1].head relations[k].rel = relations[i + 1].rel for j in range(i + 4, len(relations)): if relations[j].head == i + 1: relations[j].head = k delete_indices(relations, [i + 1, i + 2])
def transform(self, relations): for i, relation in enumerate(relations): if relation.word == 'day' and relation.rel == 'nmod'\ and i - 1 >= 0 and relations[i - 1].word.lower() == 'one': relation.word = relations[i - 1].word + ' ' + relation.word delete_indices(relations, [i - 1])
def transform(self, relations): if relations[1].word.lower() in ('and', 'then'): delete_indices(relations, [1])
def transform(self, relations): for i, relation in enumerate(relations): if relation.word == 'day' and relation.rel == 'nmod'\ and i - 1 >= 0 and relations[i - 1].word.lower() == 'one': relation.word = relations[i - 1].word + ' ' + relation.word delete_indices(relations, [i - 1])
def transform(self, relations): if relations[1].word.lower() in ('and', 'then'): delete_indices(relations, [1])
def transform(self, relations): if relations[1].word.lower() in ('e', 'aí', 'ai'): delete_indices(relations, [1])
def transform(self, relations): if relations[1].word.lower() in ('e', 'aí', 'ai'): delete_indices(relations, [1])