按照此page和this中的所有步骤,我已经在Eclipse中为Windows配置了BabelNet。
它工作正常,并从BabelNet加载所有同义词集。然后,它需要KnowldgeBasePathIndex并开始加载。在第一个链接中指定如下:
这开始运行,但是失败了,因为在尝试加载知识库时找不到“路径索引”。可以通过在config / knowledge.var.properties中放置一行来指定路径索引的位置:
Knowledge.graph.pathIndex = C:/程序文件/ BabelNet /数据
我对此有两个疑问:
BabelNet 3.0中没有Knowledge.var.properties文件。因此,我切换到BabelNet 2.5。
BabelNet 2.5中没有这样的文件夹作为数据,但是BabelNet 3.0中没有一个文件夹。但是,它们两个中仍然没有路径索引。
因此,程序停止运行。
有人可以为此提供建议吗?
谢谢。
该程序在这里:
public static void disambiguate(Collection<Word> words, KnowledgeBase kb, KnowledgeGraphScorer scorer)
{
try
{
BabelNet bn = BabelNet.getInstance();
System.out.println("SYNSETS WITH English word: \"bank\"");
List<BabelSynset> synsets = bn.getSynsets(Language.EN, "bank");
for (BabelSynset synset : synsets)
{
System.out.print(" =>(" + synset.getId() + ") SOURCE: " + synset.getSynsetSource() +"; WN SYNSET: " + synset.getWordNetOffsets() +";\n SENSES (EN): { ");
for (BabelSense sense : synset.getSenses(Language.EN))
System.out.print(sense.toString()+" ");
System.out.println("}\n -----");
Map<IPointer, List<BabelSynset>> relatedSynsets = synset.getRelatedMap();
for (IPointer relationType : relatedSynsets.keySet())
{
List<BabelSynset> relationSynsets = relatedSynsets.get(relationType);
for (BabelSynset relationSynset : relationSynsets)
{
System.out.println(" EDGE " + relationType.getSymbol() +" " + relationSynset.getId() +" " + relationSynset.toString(Language.EN));
}
}
System.out.println(" -----");
KnowledgeGraphFactory factory = KnowledgeGraphFactory.getInstance(kb);
KnowledgeGraph kGraph = factory.getKnowledgeGraph(words);
Map<String, Double> scores = scorer.score(kGraph);
for (String concept : scores.keySet())
{
double score = scores.get(concept);
for (Word word : kGraph.wordsForConcept(concept))
word.addLabel(concept, score);
}
for (Word word : words)
{
System.out.println("\n\t" + word.getWord() + " -- ID " + word.getId() +" => SENSE DISTRIBUTION: ");
for (ScoredItem<String> label : word.getLabels())
{
System.out.println("\t [" + label.getItem() + "]:" +Strings.format(label.getScore()));
}
}
}
}
catch(IOException ioe)
{
System.out.println("Trouble: " + ioe.getMessage());
}
}
public static void main(String[] args) {
List<Word> sentence = Arrays.asList(new Word[]{new Word("bank", ’n’, Language.EN), new Word("bonus", ’n’, Language.EN),new Word("pay", ’v’, Language.EN), new Word("stock", ’n’, Language.EN)});
disambiguate(sentence, KnowledgeBase.BABELNET, KnowledgeGraphScorer.DEGREE);
}
最佳答案
BabelNet API 2.5.1中不推荐使用知识工厂,并且“预编译索引捆绑包v2.5.1”不是该工厂的必要索引。在BabelNet 1.1之后,我们尚未发布“ BabelNet路径索引”。
对于WSD任务,请使用Babelfy(babelfy.org)