0

我正在尝试使用 BabelFy 消除单词列表的歧义。我从 Babelfy 的 API 页面中提供的示例开始。但我从 Babelfy 得到了关于“密钥”的错误。我已经用密钥填充了文件。但它说它是空的。

Nov 02, 2017 4:23:03 PM it.uniroma1.lcl.babelfy.commons.BabelfyConfiguration <init>
INFO: babelfy.properties is missing. Please check that the file is available 
in the config folder.
Nov 02, 2017 4:23:03 PM it.uniroma1.lcl.babelfy.commons.BabelfyConfiguration 
<init>
INFO: Babelfy starts with empty configuration
Exception in thread "main" java.lang.IllegalArgumentException: Please define 
the parameter babelfy.key in babelfy.properties in the config folder.

这是我的代码:

public class WSDBabelfy {
    public static void main (String args[]){
        String inputText = "BabelNet is both a multilingual encyclopedic dictionary and a semantic network";
        BabelfyConstraints constraints = new BabelfyConstraints();
        SemanticAnnotation a = new SemanticAnnotation(new TokenOffsetFragment(0, 0), "<the key>",
                "http://dbpedia.org/resource/BabelNet", SemanticAnnotation.Source.OTHER);

        constraints.addAnnotatedFragments(a);
        BabelfyParameters bp = new BabelfyParameters();
        bp.setAnnotationResource(BabelfyParameters.SemanticAnnotationResource.BN);
        bp.setMCS(BabelfyParameters.MCS.ON_WITH_STOPWORDS);
        bp.setScoredCandidates(BabelfyParameters.ScoredCandidates.ALL);
        Babelfy bfy = new Babelfy(bp);
        List<SemanticAnnotation> bfyAnnotations = bfy.babelfy(inputText, Language.EN, constraints);
    //bfyAnnotations is the result of Babelfy.babelfy() call
        for (SemanticAnnotation annotation : bfyAnnotations)
        {
            //splitting the input text using the CharOffsetFragment start and end anchors
            String frag = inputText.substring(annotation.getCharOffsetFragment().getStart(),
                    annotation.getCharOffsetFragment().getEnd() + 1);
            System.out.println(frag + "\t" + annotation.getBabelSynsetID());
            System.out.println("\t" + annotation.getBabelNetURL());
            System.out.println("\t" + annotation.getDBpediaURL());
            System.out.println("\t" + annotation.getSource());
        }
    }
}

这是属性文件

babelfy.key=<the key>

在此处输入图像描述

4

1 回答 1

0

我确实遇到了同样的问题,该config文件夹是否位于项目的根目录?此外,您是否将其包含在classpath下面的示例中(或您的 IDE)中?

java -classpath lib/*:babelfy-online-1.0.jar:config it.uniroma1.lcl.babelfy.demo.BabelfyDemo

于 2017-11-15T09:10:05.143 回答