The NLP Interchange Format (NIF) is an RDF/OWL-based format that aims to achieve interoperability between Natural Language Processing (NLP) tools, language resources and annotations. NIF consists of specifications, ontologies and software (overview).
- 2.0
- 2.1
- JSON-LD
- Turtle
- RDF-xml
- NTriples
- Create a context
NIFBean.NIFBeanBuilder contextBuilder = new NIFBean.NIFBeanBuilder();
contextBuilder.context("http://freme-project.eu", 0, 33).mention("Diego Maradona is from Argentina.").nifType(NIFType.CONTEXT);
NIFBean beanContext = new NIFBean(contextBuilder);
- Create entries for the entities
NIFBean.NIFBeanBuilder entityBuilder = new NIFBean.NIFBeanBuilder();
List<String> types = new ArrayList<String>();
types.add("http://dbpedia.org/ontology/Place");
types.add("http://dbpedia.org/ontology/Location");
types.add("http://dbpedia.org/ontology/PopulatedPlace");
types.add("http://nerd.eurecom.fr/ontology#Location");
types.add("http://dbpedia.org/ontology/Country");
entityBuilder.context("http://freme-project.eu", 23, 32).mention("Argentina").beginIndex(23).endIndex(32)
.taIdentRef("http://dbpedia.org/resource/Argentina").score(0.9804963628413852)
.annotator("http://freme-project.eu/tools/freme-ner")
.types(types);
NIFBean entityBean = new NIFBean(entity);
- Add it in an array list
List<NIFBean> beans = new ArrayList<>();
beans.add(entityBean);
beans.add(contextBuilder);
- Instantiate a NIF version that you like to use,
NIF nif = new NIF20(beans); // For NIF 2.0
NIF nif = new NIF21(beans); // For NIF 2.1
- Finally, get the output with the format that you need
nif.getJSONLD("Path for NIF Context"); //JSON-LD
nif.getTurtle(); //Turtle
nif.getRDFxml(); //RDF-xml
nif.getNTriples(); //NTriples
If you have any problems with or questions about this library, please contact us through a GitHub issue.