def get_synonyms(self, threshold=0.3, return_similarity_measure=False):
        synonyms = collections.defaultdict(list)
        words = filter(lambda w: len(w) > 2 and
                                 self.word_frequencies[w] > self.number_of_texts / 50,
                       self.words)
        combs = itertools.combinations(words, 2)
        for w1, w2 in combs:
            sim = self.similarity(w1, w2)
            if sim > threshold:
                if return_similarity_measure:
                    synonyms[w1].append((w2, sim))
                    synonyms[w2].append((w1, sim))
                else:
                    synonyms[w1].append(w2)
                    synonyms[w2].append(w1)
        return synonyms
dataset/ETHPy150Open mikhaildubov/AST-text-analysis/east/synonyms/synonyms.py/SynonymExtractor.get_synonyms/original