2016-07-24 4 views
1

検索エンジン用のデータベースからシノニムの基本リストを抽出したいと思います。これには、Shaun vs. Shawn、Muhammadのさまざまなバリエーション、国連(UN)や重症急性呼吸器症候群(SARS)などの有名人の頭字語のような一般的に綴られた名前が含まれます。ワードネットから単語リストを抽出する

抽出後、このシノニムのリストはサーバーに配置され、関連用語/同義語の文字列として格納されます。

Example

私はあごのAPIを使用して、私が入力した特定の単語の同義語を取得するために管理しています。これは私が試した例の一つです。 NASAの

同義語:

  1. 国立航空宇宙局:航空および宇宙飛行を担当する米国政府の独立機関。

以下は私が使用したコードです。

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

しかし、この方法では、質問したいすべての単語を手動で入力する必要があります。単語リスト(テキスト形式)にすべてのさまざまな単語とその同義語を格納する辞書全体をループする方法はありますか? https://sourceforge.net/projects/wordnetport/files/?source=navbar

それは以来、私にとって大きな助けませんでした:

は、私は私のプロジェクトのために同じ船に乗ってんだけど、私はすでに、さまざまなWordNetの抽出を行っていた人を見つけたあなたに

答えて

0

ありがとうございましたWordNetシノニムグループはかなり浅いですが、うまくいけば彼らはあなた(または誰かの同義語)のためのトリックをやります。

関連する問題