Skip to content
forked from NLP2RDF/NIF-lib

A small library for NLP Interchange Format (NIF)

Notifications You must be signed in to change notification settings

edgardmarx/NIF-lib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 versions

  • 2.0
  • 2.1

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

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

About

A small library for NLP Interchange Format (NIF)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%