当通过MIT (JWI)检索同步集的语义关系时,我根本无法获得派生相关的表单。我使用的是ISynset类方法getRelatedSynsets(IPointer p),但是列表只是返回空的。
作为一个简单的测试,我开发了一个类,它迭代wordnet的所有名词同步集,并试图找到任何暴露与派生相关的形式的同步集。令人惊讶的是,代码找不到一个具有这种关系的同步集。以下是代码:
public class DerivationallyTest {
private static IDictionary dict = null;
public static void main(String[] args) throws IOException {
IDictionary dict = dicitionaryFactory();
Iterator<ISynset> it = dict.getSynsetIterator(POS.NOUN);
while(it.hasNext()){
ISynset synset = it.next();
if(synset.getRelatedSynsets(Pointer.DERIVATIONALLY_RELATED).size() > 0){
System.out.println("FOUND ONE!!!");
}
}
}
public static IDictionary dicitionaryFactory() throws IOException{
if(dict == null){
System.out.println("Instanciando Dicionario...");
// construct the URL to the Wordnet dictionary directory
String wnhome = System.getenv("WNHOME");
String path = wnhome + File.separator + "dict";
URL url = new URL("file", null, path);
// construct the dictionary object and open it
dict = new Dictionary(url);
dict.open();
}
return dict;
}
}我是做错什么了还是这是一种奇怪的行为?我已经开发了很多使用麻省理工学院JWI的类,并且在做了很多工作之后,我不想改变成另一个API。
我在Ubuntu 12 LTS下使用Wordnet 3.1和MIT JWI 2.2.3
更新:我也尝试过使用WordNET3.0,同样的事情也发生了。
发布于 2014-05-31 02:51:50
只有语义指针附加到同步集。词法指针只附加在单词上。尝试: IWord.getRelatedWords(IPointer ptr)
http://projects.csail.mit.edu/jwi/api/edu/mit/jwi/item/ISynset.html#getRelatedSynsets(edu.mit.jwi.item.IPointer)
发布于 2014-05-31 02:57:11
正如@ others所指出的,Pointer.DERIVATIONALLY_RELATED似乎是一个词汇指针,而其他如Pointer.HYPERNYM和Pointer.HOLONYM则是语义指针。我在这个问题上写的这门课应该改写成下面这样的一篇。
public class DerivationallyTest {
private static IDictionary dict = null;
public static void main(String[] args) throws IOException {
IDictionary dict = dicitionaryFactory();
Iterator<ISynset> it = dict.getSynsetIterator(POS.NOUN);
while(it.hasNext()){
ISynset synset = it.next();
//HERE COMES THE CHANGE!!!! (the ".getWords().get(0).getRelatedWords()")
if(synset.getWords().get(0).getRelatedWords(Pointer.DERIVATIONALLY_RELATED).size()>0){
System.out.println("FOUND ONE!!!");
}
}
}
public static IDictionary dicitionaryFactory() throws IOException{
if(dict == null){
System.out.println("Instanciando Dicionario...");
// construct the URL to the Wordnet dictionary directory
String wnhome = System.getenv("WNHOME");
String path = wnhome + File.separator + "dict";
URL url = new URL("file", null, path);
// construct the dictionary object and open it
dict = new Dictionary(url);
dict.open();
}
return dict;
}
}https://stackoverflow.com/questions/23965781
复制相似问题