Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.NLP2RDF:NIF-lib:0.3'
}
dependencies {
implementation("com.github.NLP2RDF:NIF-lib:0.3")
}
<dependency>
<groupId>com.github.NLP2RDF</groupId>
<artifactId>NIF-lib</artifactId>
<version>0.3</version>
</dependency>
libraryDependencies += "com.github.NLP2RDF" % "NIF-lib" % "0.3"
:dependencies [[com.github.NLP2RDF/NIF-lib "0.3"]]
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).
## Jena x NIF Lib versions
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);
2) 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);
3) Add it in an array list
List<NIFBean> beans = new ArrayList<>();
beans.add(entityBean);
4) 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
5) 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.
<a href="http://infai.org"><img src="https://infai.org/wp-content/uploads/2017/08/InfAI-Logo.png" align="left" height="20%" width="20%" ></a>