Ejemplo n.º 1
0
 def build_dissimilarity_graph_using_wordnet(self, tokenised_sentence_dict):
     sentence_keys = tokenised_sentence_dict.keys()
     synonyms = Synonyms(tokenised_sentence_dict.values())
     self.dissimilar_sentences.add_nodes(sentence_keys)
     connections = ConnectedNodes()
     edges = list()
     for every_key, tokens in tokenised_sentence_dict.iteritems():
         for other_key, other_tokens in tokenised_sentence_dict.iteritems():
             if connections.not_connected(every_key, other_key):
                 score = synonyms.dissimilarity_score(tokens, other_tokens)
                 if score > self.DISSIMILARITY_THRESHOLD:
                     edge = (every_key, other_key, {"weight": score})
                     edges.append(edge)
                     connections.add((every_key, other_key))
     self.dissimilar_sentences.add_edges(edges)
Ejemplo n.º 2
0
 def build_dissimilarity_graph(self, tokenised_sentence_dict):
     print "Building Dissimilar Sentences Graph"
     sentence_keys = tokenised_sentence_dict.keys()
     transformed_sentences = self.transformation(tokenised_sentence_dict)
     self.dissimilar_sentences.add_nodes(sentence_keys)
     connections = ConnectedNodes()
     edges = list()
     for every_key, tokens in tokenised_sentence_dict.iteritems():
         for other_key, other_tokens in tokenised_sentence_dict.iteritems():
             if connections.not_connected(every_key, other_key):
                 score = transformed_sentences.dissimilarity_score(tokens, other_tokens)
                 if score > self.DISSIMILARITY_THRESHOLD:
                     edge = (every_key, other_key, {"weight": score})
                     edges.append(edge)
                     connections.add((every_key, other_key))
     self.dissimilar_sentences.add_edges(edges)
     print "Dissimilar Sentences Graph build complete"