0

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

Juan Carlos Mendoza
  • 5,736
  • 7
  • 25
  • 50
GeoBeez
  • 920
  • 2
  • 12
  • 20

1 Answers1

0

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

Marc
  • 1,630
  • 1
  • 15
  • 17
  • I usually use this link "https://stackoverflow.com/questions/6104551/java-setting-classpath" to make everything in classpath. but I do not know where I should write in Classaeth. could you please give a hint. – GeoBeez Jan 12 '18 at 10:53
  • Are you using an IDE, like IntelliJ IDEA? Beside this, running the line I indicated above includes all that is needed in the classpath: (1) all `.jar` file in `lib/`; (2) the `babelfy-online-1.0.jar` supposedly placed at the root of the project; (3) the `config/` folder with the 2 property files. – Marc Jan 13 '18 at 13:02