通过 MIT Java Wordnet 接口 (JWI) 检索 Synset 的语义关系时,我根本无法获得派生相关的形式。我正在使用 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;
}
}
我做错了什么还是这是一种实际的奇怪行为?我已经使用 MIT JWI 开发了很多类,并且不希望在完成大量工作后不得不更改为另一个 API。
我在 Ubuntu 12 LTS 下使用 Wordnet 3.1 和 MIT JWI 2.2.3
更新:我也尝试使用 Wordnet 3.0 并且发生了同样的事情。