简体   繁体   English

如何将名词Synset数据类型转换为字符串?

[英]How to convert noun Synset datatype into string?

how to convert the word noun synset datatype into string in java ? 如何在Java中将单词名词同义词集数据类型转换为字符串?

 nounSynset = (NounSynset)(synsets[j]);

since I need to pass the meaning of the query to the search engine which have the method that accepts only string I tried to store it in a string variable,but I couldn't able to store. 由于我需要将查询的含义传递给具有仅接受字符串的方法的搜索引擎,因此我尝试将其存储在字符串变量中,但无法存储。 here comes the error of type mismatch:cannot convert nounSynset to string. 出现类型不匹配的错误:无法将nounSynset转换为字符串。 the string which I tried was given bellow 我尝试过的琴弦已被吼叫

String s= nounSynset

只需调用toString()方法:

String nounSynset = synsets[j].toString();

首先在您的NounSynset对象中覆盖toString方法,并从那里返回一些有意义的字符串,这将对您的搜索引擎有所帮助,然后仅在需要时调用toString方法。

(NounSynset(synsets[j])).toString():

Assuming you're talking about the JAWS WordNet library here, then the "meaning of the query" most likely corresponds to the .getDefinition() method (defined on the Synset superclass). 假设您在这里讨论的是JAWS WordNet库 ,那么“查询的含义”很可能对应于.getDefinition()方法(在Synset超类上定义)。 Or you may need to build up a search query using the array returned from .getWordForms() (the list of synonymous words in the synset). 或者,您可能需要使用从.getWordForms() (同义词集中的同义词列表.getWordForms()返回的数组构建搜索查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM