首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Wordnet中提取单词列表

从Wordnet中提取单词列表
EN

Stack Overflow用户
提问于 2016-07-24 12:10:22
回答 1查看 1.2K关注 0票数 1

我想从我的搜索引擎数据库中提取一个基本的同义词列表。这包括通常拼写的名字,如Shaun与Shawn,穆罕默德的不同变体,命名实体的缩写,如联合国(UN)或严重急性呼吸系统综合症(SARS)。

提取之后,这个同义词列表将被放置在服务器中,并作为服务器存储--一串相关的术语/同义词。

示例

我使用了jaws,并设法获得了我输入的特定单词的同义词。这是我尝试过的例子之一。

美国航天局的同义词:

  1. 国家航空和航天局:美国政府负责航空和航天的一个独立机构。

下面是我使用的代码。

代码语言:javascript
复制
/**
 * Main entry point. The command-line arguments are concatenated together
 * (separated by spaces) and used as the word form to look up.
 */
public static void main(String[] args)
{
    arg[0]="NASA";
    if (args.length > 0)
    {
        //  Concatenate the command-line arguments
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < args.length; i++)
        {
            buffer.append((i > 0 ? " " : "") + args[i]);
        }
        String wordForm = buffer.toString();
        //  Get the synsets containing the wrod form
        WordNetDatabase database = WordNetDatabase.getFileInstance();
        Synset[] synsets = database.getSynsets(wordForm);
        //  Display the word forms and definitions for synsets retrieved
        if (synsets.length > 0)
        {
            System.out.println("The following synsets contain '" +
                    wordForm + "' or a possible base form " +
                    "of that text:");
            for (int i = 0; i < synsets.length; i++)
            {
                System.out.println("");
                String[] wordForms = synsets[i].getWordForms();
                for (int j = 0; j < wordForms.length; j++)
                {
                    System.out.print((j > 0 ? ", " : "") +
                            wordForms[j]);
                }
                System.out.println(": " + synsets[i].getDefinition());
            }
        }
        else
        {
            System.err.println("No synsets exist that contain " +
                    "the word form '" + wordForm + "'");
        }
    }
    else
    {
        System.err.println("You must specify " +
                "a word form for which to retrieve synsets.");
    }
}

但是,此方法将要求我手动输入要查询的所有单词。是否有一种方法循环遍历整个字典,将所有不同的单词及其同义词存储在一个单词列表(文本形式)中?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-02-07 12:04:43

我在同一条船上从事我的项目,但我确实找到了一个已经做过各种WordNet提取的人:https://sourceforge.net/projects/wordnetport/files/?source=navbar

这对我没有多大帮助,因为WordNet同义词组非常肤浅,但希望它们能为您(或同义词)发挥作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38551856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档