babelfy.properties is missing in Java

234 Views Asked by At

I am trying to disambiguate a list of words using BabelFy. I started with the example provided in API page of Babelfy. but I got the Error about the "key" that I got from Babelfy. I already filled the file with the key. but it says it it empty.

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.

here is my code:

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());
        }
    }
}

and here is properties file

babelfy.key=<the key>

enter image description here

1

There are 1 best solutions below

2
Marc On

I did experience the same issue, is the config folder well at the root of the project? Also, do you include it in the classpath as in the example below (or in your IDE)?

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