Skip to content
Sandro edited this page Aug 7, 2017 · 3 revisions

NIF Lib usage examples

import org.nlp2rdf.NIF;
import org.nlp2rdf.bean.NIFBean;
import org.nlp2rdf.bean.NIFType;
import org.nlp2rdf.nif21.impl.NIF21;

import java.util.ArrayList;
import java.util.List;


public class NIFDemo {

    public static void main(String args[]) {
        String TEXT = "The two-feedback-loop regulatory module of nuclear factor kB (NF-kB) signaling pathway is modeled by means of ordinary\n" +
                "differential equations.";

        String ANNOTATOR = "http://gerbil.aksw.org";
        Integer START = 0;
        Integer END =  TEXT.length();


        List<NIFBean> beans = new ArrayList<NIFBean>();

        NIFBean.NIFBeanBuilder builderContext = new NIFBean.NIFBeanBuilder();
        builderContext.context(ANNOTATOR, START, END).mention(TEXT).nifType(NIFType.CONTEXT);
        NIFBean beanContext = new NIFBean(builderContext);
        beans.add(beanContext);



        NIFBean.NIFBeanBuilder builderMention1 = new NIFBean.NIFBeanBuilder();

        List<String> typesMention1 = new ArrayList<String>();
        typesMention1.add("http://dbpedia.org/ontology/Thing");
        builderMention1.context(ANNOTATOR, START, END).mention("signaling pathway").beginIndex(69).endIndex(86)
                .taIdentRef("http://dbpedia.org/page/Cell_signaling").score(0.9804963628413852)
                .annotator(ANNOTATOR)
                .types(typesMention1);

        NIFBean bean = new NIFBean(builderMention1);

        beans.add(bean);


        NIF nif21 = new NIF21(beans);
        System.out.println(nif21.getTurtle());
    }
}

Clone this wiki locally