按照此page和this中的所有步骤,我在Eclipse中配置了BabelNet for Windows。
它工作正常并加载来自BabelNet的所有同义词。然后它需要knowldgeBasePathIndex并开始加载。在第一个链接中指定了:
这开始运行,但失败了,因为它找不到名为"路径索引的东西"当试图加载知识库时。可以通过在config / knowledge.var.properties中添加一行来指定路径索引的位置: knowledge.graph.pathIndex = C:/ Program Files / BabelNet / data
我对此有两个疑问:
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);
}
答案 0 :(得分:1)
知识工厂在BabelNet API 2.5.1中已弃用,“预编译索引包v2.5.1”不是该工厂的必要索引。我们还没有在BabelNet 1.1之后发布“BabelNet路径索引”。
对于WSD任务,请使用Babelfy(babelfy.org)