java 怎么把结果显示在TextArea中,急求!!! 15
下面是部分代码:publicclassSynonyms{publicstaticvoidmain(String[]args)throwsIOException{Strin...
下面是部分代码:
public class Synonyms {
public static void main(String[] args) throws IOException{
String wnhome = System.getenv("WNHOME"); //获取WordNet根目录环境变量WNHOME
String path = "C:\\Program Files\\WordNet" + File.separator+ "dict";
File wnDir=new File(path);
URL url=new URL("file", null, path);
Scanner scan = new Scanner(path);
System.out.println("请输入查找的词:");
IDictionary dict=new Dictionary(url);
dict.open();//打开词典
getSynonyms(dict); //检测同义词
}
public static void getSynonyms(IDictionary dict){
//查看"table"的第一个意思
//IIndexWord idxWord =dict.getIndexWord("table",POS.NOUN);
//输入固定词语,进行索引
Scanner scan = new Scanner(System.in);
String keyword = scan.next();
IIndexWord idxWord =dict.getIndexWord(keyword , POS.NOUN);
for(int i=0;i<idxWord.getWordIDs().size();i++){
IWordID wordID = idxWord.getWordIDs().get(i) ; // 多个意义的ID号
IWord word = dict.getWord(wordID);
ISynset synset = word.getSynset();
//ISynset是一个词的同义词集的接口
System.out.println("IWord----"+i+":"+word.toString());
System.out.println("Gloss----"+i+":"+word.getSynset().getGloss());//通俗英语解释
for(IWord w : synset.getWords())
System.out.println(w.getLemma());
//打印同义词集中的每个同义词
}
在界面上用的是private void jButton1ActionPerformed(ActionEvent evt) {
System.out.println("jButton1.actionPerformed,event= " + evt); 展开
public class Synonyms {
public static void main(String[] args) throws IOException{
String wnhome = System.getenv("WNHOME"); //获取WordNet根目录环境变量WNHOME
String path = "C:\\Program Files\\WordNet" + File.separator+ "dict";
File wnDir=new File(path);
URL url=new URL("file", null, path);
Scanner scan = new Scanner(path);
System.out.println("请输入查找的词:");
IDictionary dict=new Dictionary(url);
dict.open();//打开词典
getSynonyms(dict); //检测同义词
}
public static void getSynonyms(IDictionary dict){
//查看"table"的第一个意思
//IIndexWord idxWord =dict.getIndexWord("table",POS.NOUN);
//输入固定词语,进行索引
Scanner scan = new Scanner(System.in);
String keyword = scan.next();
IIndexWord idxWord =dict.getIndexWord(keyword , POS.NOUN);
for(int i=0;i<idxWord.getWordIDs().size();i++){
IWordID wordID = idxWord.getWordIDs().get(i) ; // 多个意义的ID号
IWord word = dict.getWord(wordID);
ISynset synset = word.getSynset();
//ISynset是一个词的同义词集的接口
System.out.println("IWord----"+i+":"+word.toString());
System.out.println("Gloss----"+i+":"+word.getSynset().getGloss());//通俗英语解释
for(IWord w : synset.getWords())
System.out.println(w.getLemma());
//打印同义词集中的每个同义词
}
在界面上用的是private void jButton1ActionPerformed(ActionEvent evt) {
System.out.println("jButton1.actionPerformed,event= " + evt); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询