Пример #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)