从Wordnet

时间:2016-07-24 12:10:22

标签: java database wordnet jaws-wordnet

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

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

Example

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

NASA的同义词:

  1. 美国国家航空航天局:负责航空和航天的美国政府的独立机构。
  2. 以下是我使用的代码。

    /**
     * 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.");
        }
    }
    

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

    谢谢

1 个答案:

答案 0 :(得分:0)

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

这对我来说并不是一个很大的帮助,因为WordNet的同义词群体非常浅薄,但希望他们会为你(或某个同义词)做这个伎俩。

相关问题