Java 从Wordnet中提取单词列表
我想为我的搜索引擎从数据库中提取一个基本的同义词列表。这包括常用拼写的名称,如Shaun vs.Shawn、穆罕默德的不同变体、联合国(UN)或严重急性呼吸综合征(SARS)等命名实体的首字母缩略词 提取后,该同义词列表将被放置在服务器中并存储为一个相关术语/同义词字符串 我使用了jaws API,并设法获得了我输入的特定单词的同义词。这是我尝试过的例子之一 NASA的同义词:Java 从Wordnet中提取单词列表,java,database,wordnet,jaws-wordnet,Java,Database,Wordnet,Jaws Wordnet,我想为我的搜索引擎从数据库中提取一个基本的同义词列表。这包括常用拼写的名称,如Shaun vs.Shawn、穆罕默德的不同变体、联合国(UN)或严重急性呼吸综合征(SARS)等命名实体的首字母缩略词 提取后,该同义词列表将被放置在服务器中并存储为一个相关术语/同义词字符串 我使用了jaws API,并设法获得了我输入的特定单词的同义词。这是我尝试过的例子之一 NASA的同义词: 美国国家航空航天局:美国政府负责航空航天的独立机构 下面是我使用的代码 /** * Main entry poin
/**
* 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.");
}
}
/**
*主要入口点。命令行参数连接在一起
*(用空格分隔)用作查找的单词形式。
*/
公共静态void main(字符串[]args)
{
arg[0]=“NASA”;
如果(args.length>0)
{
//连接命令行参数
StringBuffer=新的StringBuffer();
对于(int i=0;i0?“:”)+args[i]);
}
字符串wordForm=buffer.toString();
//获取包含wrod表单的语法集
WordNetDatabase=WordNetDatabase.getFileInstance();
Synset[]synsets=database.getSynsets(wordForm);
//显示检索到的语法集的单词形式和定义
如果(synsets.length>0)
{
System.out.println(“以下语法集包含”+
wordForm+“'或可能的基本形式”+
“在该案文中:”;
for(int i=0;i0?,“:”)+
词形[j];
}
System.out.println(“:”+synsets[i].getDefinition());
}
}
其他的
{
System.err.println(“不存在包含”+
“单词形式“'+单词形式+””);
}
}
其他的
{
System.err.println(“您必须指定”+
“检索语法集的单词形式。”);
}
}
但是,此方法需要我手动输入所有要查询的单词。有没有一种方法可以在整个词典中循环,将所有不同的单词及其同义词存储在单词列表(文本形式)中
谢谢对于我的项目,我也有同感,但我确实找到了一位已经完成了各种WordNet提取的人:
这对我帮助不大,因为WordNet同义词组非常肤浅,但希望它们能为您(或某个同义词组)提供帮助。我的项目也是如此,但我确实发现有人已经完成了各种WordNet提取: 这对我帮助不大,因为WordNet同义词组很肤浅,但希望它们能帮你(或同义词的人)一臂之力