简体   繁体   中英

How to make Java-rdfa api work with Jena Api?

I am trying to write small application which will take the responce of a web -service in xhtml+xml format (Actually i am talking about dbpedia spotlight) and by using an rdf distiller (here comes Java-rdfa api) to extract the rdf triple. I have managed to install jena api (i am using both Netbeans and eclipse IDE's) and works without problem. In order to install java-rdfa api, I made a users library "put" in the java-rdfa-0.4.1.jar and set a classpath to my project(as it is my project depends on 3 libraries java-rdfa, jena-api-2.7.1. and the default java JDK 1.7). Unfortunately when I am ruuning my application i am getting the following exception

  java.lang.NoClassDefFoundError: com/hp/hpl/jena/iri/IRIFactory

I am sure that in the jena api there is a iri-0.9.1 jar .Is the problem caused because i do not use maven?( I understand is a java package manager but i do not know anything about it).Is it even possible to use these two api without maven in an easy way? Or could it be because of my code? I apologise if this question seems trivial or not very well formed, but as i am new to programming any suggestions would be appreciated.

Well, looking at the maven pom.xml file for java-rdfa, it looks like it's using a rather old version of Jena - 2.6.3, whereas the version you're likely to have downloaded for your IDE will be (at a guess) 2.7.0 or 2.7.1.

One course of action would be to fork the project on github and update the pom.xml to point to the latest Jena version. But that's probably too much of an ask if you're new to programming. As it happens, I know the maintainer of java-rdfa, I'll ask if he has time to do a new release that works with modern Jena versions.

Have you checked clj-rdfa-jena which uses the RDFa 1.1 compliant library clj-rdfa ? See an example .

Let me offer an alternative. If you are looking for RDF from DBpedia Spotlight, why not just ask for it in your favorite serialization? You just need to set your Accept header accordingly.

Here an example with cURL.

curl -H "Accept: text/turtle" http://spotlight.dbpedia.org/rest/annotate -d "text=Berlin capital of Germany"

For Java, search for "set http accept header java".

The response to that request will be RDF in NIF

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix itsrdf: <http://www.w3.org/2005/11/its/rdf#> .
@prefix str: <http://nlp2rdf.lod2.eu/schema/string/> .

<http://spotlight.dbpedia.org/rest/document/?text=Berlin%20capital%20of%20Germany#offset_0_25> str:sourceString "Berlin capital of Germany" ;
    str:subString <http://spotlight.dbpedia.org/rest/document/?text=Berlin%20capital%20of%20Germany#offset_0_6> ;
    a str:OffsetBasedString , str:Document .

<http://spotlight.dbpedia.org/rest/document/?text=Berlin%20capital%20of%20Germany#offset_0_6> itsrdf:disambigIdentRef <http://dbpedia.org/resource/West_Berlin> ;
    a str:OffsetBasedString .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM