我爲我的項目使用java wordnet庫(jwnl)。我需要在處理之前找到一個單詞的基本形式。例如,如果我給「發送」基本形式的單詞應該是「發送」。 「派遣」的基本詞應該是「派遣」。我已閱讀jwnl文檔,但它使我困惑。請爲我提供一段代碼以查找基本詞。感謝您的期望。獲取單詞的基本形式?
2
A
回答
0
我會建議使用波特詞幹算法,而不是WordNet的努力,你可以找到大多數語言實現 - including java here
這應該得到你想要的東西
1
我用JAWS因爲我發現它更好然後JWNL通過讀取jwnl.Using形態處理器的文檔檢查這個代碼以查找有關它基和光澤
import java.io.*;
import edu.smu.tspell.wordnet.*;
/**
* Displays word forms and definitions for synsets containing the word form
* specified on the command line. To use this application, specify the word
* form that you wish to view synsets for, as in the following example which
* displays all synsets containing the word form "airplane":
* <br>
* java TestJAWS airplane
*/
public class start
{
/**
* 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)
{
while(true)
{
if (args.length == 0)
{
StringBuffer buffer = new StringBuffer();
String wordForm = null;//"fast";//buffer.toString();
System.out.print("\n");
System.out.print("Enter your query: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
wordForm = br.readLine();
} catch (IOException e) {
System.out.println("Error!");
System.exit(1);
}
System.out.println("Your looking for: " + wordForm);
System.setProperty("wordnet.database.dir", "/home/dell/workspace/wordnet/WordNet-3.0/dict");
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. 在Java中將單詞轉化爲其基本形式
- 2. 尋找同義詞和傾斜詞的基本形式
- 3. 動詞/名詞/形容詞形式之間的單詞轉換
- 4. 獲取序列形式的所有單詞在句子
- 5. 維基詞典:獲取給定單詞的頁面列表
- 6. 獲取模式後的特定單詞
- 7. 從文本中獲取3個單詞
- 8. Rails的基本形式
- 9. 獲取非基本單位的方法?
- 10. 獲取完整的單詞
- 11. 使用wordnet獲取單詞的詞條
- 12. 獲取單詞的同義詞
- 13. 獲取形式
- 14. 讀取單詞格式的文本文件(單個單詞排成一列)
- 15. Python對單詞的表示形式
- 16. Vibe.d基本形式驗證
- 17. 基本形式[Javascript/HTML]
- 18. 基本HTTP形式發佈
- 19. 基本的HTML文本形式
- 20. 如何使用Wordnet獲取單詞的變形
- 21. 獲取文本和其他形式
- 22. XPath來獲取文本形式
- 23. 單詞的名詞,動詞,形容詞等的單獨列表
- 24. 使用StringTokenizer獲取單詞
- 25. 獲取單詞類別
- 26. 獲取多個單詞
- 27. 獲取形式值
- 28. 獲取從形式
- 29. 在文本文件中的特定單詞之前和之後獲取單詞
- 30. 如何分別獲取名詞,動詞,形容詞synset?
Thanx.Actually我解決了這個問題,我可以得到=的word.for例如發送鹼形式>送,孩子=> CH ild..etc – KNsiva 2011-03-09 08:08:23
列表baseforms = dict.getMorphologicalProcessor()。lookupAllBaseForms(POS.VERB,「sent」);是一個代碼示例 – KNsiva 2011-03-09 08:09:21