You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Neubert Joachim <J....@zbw.eu> on 2013/08/09 10:12:14 UTC
Case study for Jena Text: Thesaurus-augmented search
I just published a blog post:
http://zbw.eu/labs/en/blog/thesaurus-augmented-search-with-jena-text
Re: Reading RDF/XML file with jena beguineer
Posted by Andy Seaborne <an...@apache.org>.
On 12/08/13 10:05, Samir Hamitouche wrote:
Please don't reply to some unrelated message on the list. People
reading by threads may not see your message.
> $ javac web1.java
> web1.java:1: error: package com.hp.hpl.jena.rdf.model does not exist
> import com.hp.hpl.jena.rdf.model.ModelFactory;
> ^
You must set the classpath for compilation. Search the web for general
instructions for doing this. It is not Jena-specific.
It is easier to use an IDE such as Eclipse. It is much easier and
productive than doing everything on the command line.
Andy
> Hello,
>
> i write a small java program to read an XML/RDF file in my desktop in eclipse using the jena library this is the program:
>
> import com.hp.hpl.jena.rdf.model.ModelFactory;
> import com.hp.hpl.jena.rdf.model.Model;
> import java.io.PrintWriter;
> import java.util.Iterator;
>
>
> public class web1 {
>
> private String etudNS ="path .. /resDoc.rdf";
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> web1 etudRDF = new web1();
> }
> public void load() {
> Model model = ModelFactory.createDefaultModel();
> model.read(etudNS);
> model.write(System.out);
> model.write (new PrintWriter(System.out));
> }
> }
>
>
>
>
> when i compile i had this:
>
>
> $ javac web1.java
> web1.java:1: error: package com.hp.hpl.jena.rdf.model does not exist
> import com.hp.hpl.jena.rdf.model.ModelFactory;
> ^
> web1.java:2: error: package com.hp.hpl.jena.rdf.model does not exist
> import com.hp.hpl.jena.rdf.model.Model;
> ^
> web1.java:18: error: cannot find symbol
> Model model = ModelFactory.createDefaultModel();
> ^
> symbol: class Model
> location: class web1
> web1.java:18: error: cannot find symbol
> Model model = ModelFactory.createDefaultModel();
> ^
> symbol: variable ModelFactory
> location: class web1
> 4 errors
>
>
> Anyone can help me
>
> Thank you
>
> Best regards
>
> Samir
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
RE: Reading RDF/XML file with jena beguineer
Posted by David Jordan <Da...@sas.com>.
Samir,
Andy already answered your question. Do you have a CLASSPATH set up that includes all the jars necessary for Jena? You may be using Eclipse, but you still need to set up the jar files to be included with the build. I am guessing you are new to Java and Eclipse?
-----Original Message-----
From: Samir Hamitouche [mailto:21209178@etu.unicaen.fr]
Sent: Monday, August 12, 2013 10:23 AM
To: users@jena.apache.org
Cc: dev-subscribe@jena.apache.org
Subject: Reading RDF/XML file with jena beguineer
Hello,
i write a small java program to read an XML/RDF file in my desktop using the IDE eclipse the jena library this is the program:
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Model;
import java.io.PrintWriter;
import java.util.Iterator;
public class web1 {
private String etudNS ="path .. /resDoc.rdf";
/**
* @param args
*/
public static void main(String[] args) {
web1 etudRDF = new web1();
}
public void load() {
Model model = ModelFactory.createDefaultModel();
model.read(etudNS);
model.write(System.out);
model.write (new PrintWriter(System.out));
}
}
when i compile i had this:
$ javac web1.java
web1.java:1: error: package com.hp.hpl.jena.rdf.model does not exist import com.hp.hpl.jena.rdf.model.ModelFactory;
^
web1.java:2: error: package com.hp.hpl.jena.rdf.model does not exist import com.hp.hpl.jena.rdf.model.Model;
^
web1.java:18: error: cannot find symbol
Model model = ModelFactory.createDefaultModel();
^
symbol: class Model
location: class web1
web1.java:18: error: cannot find symbol
Model model = ModelFactory.createDefaultModel();
^
symbol: variable ModelFactory
location: class web1
4 errors
Anyone can help me
Thank you
Best regards
Samir
Reading RDF/XML file with jena beguineer
Posted by Samir Hamitouche <21...@etu.unicaen.fr>.
Hello,
i write a small java program to read an XML/RDF file in my desktop using the IDE eclipse the jena library this is the program:
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Model;
import java.io.PrintWriter;
import java.util.Iterator;
public class web1 {
private String etudNS ="path .. /resDoc.rdf";
/**
* @param args
*/
public static void main(String[] args) {
web1 etudRDF = new web1();
}
public void load() {
Model model = ModelFactory.createDefaultModel();
model.read(etudNS);
model.write(System.out);
model.write (new PrintWriter(System.out));
}
}
when i compile i had this:
$ javac web1.java
web1.java:1: error: package com.hp.hpl.jena.rdf.model does not exist
import com.hp.hpl.jena.rdf.model.ModelFactory;
^
web1.java:2: error: package com.hp.hpl.jena.rdf.model does not exist
import com.hp.hpl.jena.rdf.model.Model;
^
web1.java:18: error: cannot find symbol
Model model = ModelFactory.createDefaultModel();
^
symbol: class Model
location: class web1
web1.java:18: error: cannot find symbol
Model model = ModelFactory.createDefaultModel();
^
symbol: variable ModelFactory
location: class web1
4 errors
Anyone can help me
Thank you
Best regards
Samir
Reading RDF/XML file with jena beguineer
Posted by Samir Hamitouche <21...@etu.unicaen.fr>.
Hello,
i write a small java program to read an XML/RDF file in my desktop in eclipse using the jena library this is the program:
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Model;
import java.io.PrintWriter;
import java.util.Iterator;
public class web1 {
private String etudNS ="path .. /resDoc.rdf";
/**
* @param args
*/
public static void main(String[] args) {
web1 etudRDF = new web1();
}
public void load() {
Model model = ModelFactory.createDefaultModel();
model.read(etudNS);
model.write(System.out);
model.write (new PrintWriter(System.out));
}
}
when i compile i had this:
$ javac web1.java
web1.java:1: error: package com.hp.hpl.jena.rdf.model does not exist
import com.hp.hpl.jena.rdf.model.ModelFactory;
^
web1.java:2: error: package com.hp.hpl.jena.rdf.model does not exist
import com.hp.hpl.jena.rdf.model.Model;
^
web1.java:18: error: cannot find symbol
Model model = ModelFactory.createDefaultModel();
^
symbol: class Model
location: class web1
web1.java:18: error: cannot find symbol
Model model = ModelFactory.createDefaultModel();
^
symbol: variable ModelFactory
location: class web1
4 errors
Anyone can help me
Thank you
Best regards
Samir
AW: Case study for Jena Text: Thesaurus-augmented search
Posted by Neubert Joachim <J....@zbw.eu>.
Hi Andy,
Thank you very much for your suggestions, that makes it a lot more elegant (and with the BIND variable consistently some milliseconds faster). I've added the code as a comment in order to make it useful for others who stop by.
Cheers, Joachim
-----Ursprüngliche Nachricht-----
Von: Andy Seaborne [mailto:andy@apache.org]
Gesendet: Samstag, 10. August 2013 16:01
An: users@jena.apache.org
Betreff: Re: Case study for Jena Text: Thesaurus-augmented search
On 09/08/13 09:12, Neubert Joachim wrote:
> I just published a blog post:
>
> http://zbw.eu/labs/en/blog/thesaurus-augmented-search-with-jena-text
>
Nice.
I think you can rewrite to avoid multiple text:query using a temporary variable ?x, say, and BIND:
...
?x text:query ('telework' 2)
{ BIND ( ?x AS ?concept ) }
UNION { ?x skos:exactMatch ?concept }
UNION { BIND ( ?x AS ?concept ) ?concept skos:narrower ?narrower } UNION { ?x skos:narrower ?concept } UNION { BIND ( ?x AS ?concept ) skos:related ?related } UNION { ?x skos:related ?concept } ...
but if you observe it making no difference, it could be that internal Lucene caching means repeat use of the same query is fast.
Is ?altLabel intended, it's in the SELECT but not in the query. If it's
?label every where you could use more property paths:
# To specifically get ?prefLabel
{ ?concept skos:prefLabel ?prefLabel }
UNION
{ ?concept (skos:prefLabel |
skos:altLabel |
skos:hiddenLabel ) ?label . }
UNION { ?concept skos:exactMatch / (skos:prefLabel |
skos:altLabel |
skos:hiddenLabel ) ?label .
because | in property paths is the same as a UNION.
In the extreme: ? is "zero or one of" so ....
?concept skos:exactMatch? /
(skos:prefLabel |
skos:altLabel |
skos:hiddenLabel ) ?label .
but there comes a point where just because you can, does not mean that
you should :-)
Andy
Re: Case study for Jena Text: Thesaurus-augmented search
Posted by Andy Seaborne <an...@apache.org>.
On 09/08/13 09:12, Neubert Joachim wrote:
> I just published a blog post:
>
> http://zbw.eu/labs/en/blog/thesaurus-augmented-search-with-jena-text
>
Nice.
I think you can rewrite to avoid multiple text:query using a temporary
variable ?x, say, and BIND:
...
?x text:query ('telework' 2)
{ BIND ( ?x AS ?concept ) }
UNION { ?x skos:exactMatch ?concept }
UNION { BIND ( ?x AS ?concept ) ?concept skos:narrower ?narrower }
UNION { ?x skos:narrower ?concept }
UNION { BIND ( ?x AS ?concept ) skos:related ?related }
UNION { ?x skos:related ?concept }
...
but if you observe it making no difference, it could be that internal
Lucene caching means repeat use of the same query is fast.
Is ?altLabel intended, it's in the SELECT but not in the query. If it's
?label every where you could use more property paths:
# To specifically get ?prefLabel
{ ?concept skos:prefLabel ?prefLabel }
UNION
{ ?concept (skos:prefLabel |
skos:altLabel |
skos:hiddenLabel ) ?label . }
UNION { ?concept skos:exactMatch / (skos:prefLabel |
skos:altLabel |
skos:hiddenLabel ) ?label .
because | in property paths is the same as a UNION.
In the extreme: ? is "zero or one of" so ....
?concept skos:exactMatch? /
(skos:prefLabel |
skos:altLabel |
skos:hiddenLabel ) ?label .
but there comes a point where just because you can, does not mean that
you should :-)
Andy