我试图从我的WordNet应用程序中调用C++ call,它可以工作,但并不像预期的那样。这是我的密码:
int search (char* term)
{
results.clear();
SynsetPtr synsets = findtheinfo_ds(term, NOUN, HYPERPTR, ALLSENSES);
SynsetPtr currentSynset = synsets;
// Loop all senses
while (currentSynset != nullptr)
{
SynsetPtr next = currentSynset;
// Iterate up hierarchy for each sense.
while (next != nullptr)
{
String words;
for (int i = 0; i != next->wcount; ++i)
{
String nextWord = next->words[i];
nextWord = nextWord.replaceCharacter('_', ' ');
words += String(nextWord);
if (i != (next->wcount - 1)) words += ", ";
}
results.add (words + " - " + String(next->defn));
next = next->ptrlist;
}
currentSynset = currentSynset->nextss;
}
free_syns(synsets);
return results.size();
}我的程序正确地输出了每种感官的定义,但是对于每种感觉,它只输出直接在层次结构中我的搜索词之上的一个超数列,它不会一直沿着树向‘实体’。换句话说,第二个SynsetPtr->ptrlist始终为NULL,即使我从WordNet CLI中可以看到有许多级别上升。
我是不是遗漏了什么?我是不是打错了findtheinfo_ds()?
发布于 2014-04-14 23:36:50
findtheinfo_ds()只返回一个节点。要想在树中工作,您必须为它找到的每个连接调用findtheinfo_ds()。我找到了此页,它在返回的数据结构上显示了gdb交互会话,我认为您会发现这很有用。
还请看一下traceptrs_ds()函数,它听起来可能是为您想要做的事情而设计的。
https://stackoverflow.com/questions/23066032
复制相似问题