Skip to content

Latest commit

 

History

History
103 lines (63 loc) · 3.41 KB

README.md

File metadata and controls

103 lines (63 loc) · 3.41 KB

NIF library

maven-central Build Status Coverage Status Codacy Badge codebeat badge Project Stats

What is NIF (NLP Interchange Format) ?

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).

Documentation

NIF Documentation

Supported NIF versions

  • 2.0
  • 2.1

Jena x NIF Lib versions

  • Jena 2.13.0 - 0.2.x ; 0.3.x
  • Jena 3.1.0 - 0.4.x

Supported formats

  • JSON-LD
  • Turtle
  • RDF-xml
  • NTriples

Usage

  1. 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);

  1. 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(contextBuilder);

  1. Add it in an array list
    List<NIFBean> beans = new ArrayList<>();
    
    beans.add(entityBean);
    
  1. 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
  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

Issues

If you have any problems with or questions about this library, please contact us through a GitHub issue.

Maintainers