我怎样才能提取相似的短语?

时间:2022-10-20 11:45:32

I am using Wordnet database. It gives me just the meanings or synonyms for 1 or 2 words. If I want similar phrases, how to do that? Please, any one help me on this. Also I am making use of Lucene in my code. If there is any way of doing it with lucene?.

我正在使用Wordnet数据库。它给了我1或2个单词的含义或同义词。如果我想要类似的短语,怎么做?拜托,有人帮我这个。我也在我的代码中使用Lucene。如果用lucene有什么方法吗?

    WordNetDatabase database = WordNetDatabase.getFileInstance();
        for (int i1 = 0; i1 < list1.size(); i1++) {

            Synset[] synsets = database.getSynsets(list1.get(i1));
            for (int i = 0; i < synsets.length; i++) {
                String[] wordForms = synsets[i].getWordForms();
                for (int j = 0; j < wordForms.length; j++) {
                    out.print(wordForms[j] + "\n");
                }
                out.println(synsets[i].getDefinition() + "\n");
            }
        }

1 个解决方案

#1


Lucene has similarity scoring, https://lucene.apache.org/core/4_2_0/core/org/apache/lucene/search/similarities/Similarity.html

Lucene有相似性评分,https://lucene.apache.org/core/4_2_0/core/org/apache/lucene/search/similarities/Similarity.html

This should allow you to score two strings against each other and then specify and minimum similarity between the strings, thus allowing you to find similar strings.

这应该允许您相互比较两个字符串,然后指定字符串之间的最小相似性,从而允许您找到类似的字符串。

#1


Lucene has similarity scoring, https://lucene.apache.org/core/4_2_0/core/org/apache/lucene/search/similarities/Similarity.html

Lucene有相似性评分,https://lucene.apache.org/core/4_2_0/core/org/apache/lucene/search/similarities/Similarity.html

This should allow you to score two strings against each other and then specify and minimum similarity between the strings, thus allowing you to find similar strings.

这应该允许您相互比较两个字符串,然后指定字符串之间的最小相似性,从而允许您找到类似的字符串。