我为我的项目使用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. 寻找同义词和倾斜词的基本形式
- 2. 维基词典:获取给定单词的页面列表
- 3. 获取模式后的特定单词
- 4. 获取完整的单词
- 5. 读取单词格式的文本文件(单个单词排成一列)
- 6. Python对单词的表示形式
- 7. 如何使用Wordnet获取单词的变形
- 8. 基本HTTP形式发布
- 9. Vibe.d基本形式验证
- 10. 基本的HTML文本形式
- 11. 单词的名词,动词,形容词等的单独列表
- 12. 获取单词类别
- 13. 在文本文件中的特定单词之前和之后获取单词
- 14. 获取实际的形式
- 15. Symfony的:获取对象的形式是基于的
- 16. 根据单词的矢量(不是单词本身)获得与本词最相似的单词
- 17. 获取URL的“基本URL”
- 18. 获取某个单词之前和之后的单词吗?
- 19. 获取GNU makefile中最后一个单词前的单词
- 20. 获取Ruby字符串中特定单词后的单词吗?
- 21. 获取单词的计数TinyMCE的
- 22. 通过单击获取单词
- 23. 单词列表的词形化
- 24. 更改从脚本获取的特定单词的颜色
- 25. 浮点数的基本输入形式?
- 26. rails形式的基本错误消息
- 27. 如何返回词的副词形式
- 28. Django的基本形式 - 从views.py读取一个变量
- 29. 以明文形式获取文件版本的脚本
- 30. 获取已编辑的UITextView单词
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