Re: Q. about RDFDataMgr & BadURIException

2014-10-10 Thread Rouquette, Nicolas F (313D)


On 10/9/14 3:39 AM, "Andy Seaborne"  wrote:

>Nicolas,
>
>Which version of Jena are you referring to? (the line number for
>RDFDataMgr does not seem to line up).

This is from the 2.11.2 version of jena-arq
In the git master branch, the corresponding code is at line 1331:


private static void write$(OutputStream out, DatasetGraph dataset,
RDFFormat serialization)
{
WriterDatasetRIOT w = createDatasetWriter$(serialization) ;
w.write(out, dataset, RiotLib.prefixMap(dataset), null, null) ; //
line 1331
}


>And what's the data being serialized?  There is some BananaDRF
>processing applied to the data read in teh example.  Could you provide
>(N-Triples is quite forgiving) the data or a short, standalone program
>that can produce it?

The test was originally written like this:

  "write simple graph as TURTLE string" in {
val turtleString = writer.asString(referenceGraph,
"http://www.w3.org/2001/sw/RDFCore/";).get
turtleString should not be ('empty)
val graph = Await.result(reader.read(turtleString, rdfCore),
Duration(1, SECONDS))
assert(referenceGraph isIsomorphicWith graph)
  }


At this point, "referenceGraph" is well-formed: every URI is absolute

 {http://www.w3.org/2001/sw/RDFCore/ntriples/
@http://purl.org/dc/elements/1.1/publisher http://www.w3.org/;
  http://www.w3.org/2001/sw/RDFCore/ntriples/
@http://purl.org/dc/elements/1.1/creator "Art Barstow";
  http://www.w3.org/2001/sw/RDFCore/ntriples/
@http://purl.org/dc/elements/1.1/creator "Dave Beckett"}



When writer.asString() executes, it calls this:

def asString(graph: Jena#Graph, base: String): Try[String] = Try {
  val result = new StringWriter()
  import org.w3.banana.jena.Jena.ops._
  val relativeGraph : Jena#Graph = graph.relativize(URI(base))
  RDFDataMgr.write(result, relativeGraph, lang)
  result.toString()
}


graph.relativize() is a banana-rdf API -- it constructs a new Jena Graph:

 {ntriples/ @http://purl.org/dc/elements/1.1/creator "Dave Beckett";
  ntriples/ @http://purl.org/dc/elements/1.1/creator "Art Barstow";
  ntriples/ @http://purl.org/dc/elements/1.1/publisher http://www.w3.org/}


As I mentioned above, the Jena API RDFDataMgr.write() does not provide a
way to pass a base URI for the graph.
So given a relative Jena Graph as input, we get the serialization of that
graph which is also relative (as the value of the "result" string writer:

  "Dave Beckett" ,
"Art Barstow" ;
 
 .


>
>There is some confusion about relative URIs here.

Possibly

>
>The RDF data model is defined in terms of absolute URIs.  A relative URI
>should never occur in an RDF graph.  They can occur in RDF syntax.

However, the Jena API -- specifically RDFDataMgr.write() -- seems to
exepect that all URIs in the input graph are absolute since it does not
provide support for specifying a base URI for relative URIs in the graph.


>
>A base URI on writing is used to convert an absolute URI to a relative
>one in the output syntax.  As the base URI is also written out, the
>whole RDF Graph still has absolute URIs when read back in again.

I think the problem is the following:

- it is possible to construct a Jena Graph where some URIs are relative.
- some of Jena's "write" APIs do not provide a way to specify the base URI
for converting relative URIs in the graph into absolute URIs in the output
syntax (whether it is using a "@base" or not)

>
>The report you reference was caused by "" as a subject URI.  That's not
>legal RDF. <> is not "".

Sorry -- I don't understand what you're referring to.

>
>Supplying the baseURI on writing only affects the abbreviation of URIs
>in the data. They must be absolute in the data in the first place.

I agree with you except that, as I explained above, it *is* possible to
construct Jena Graphs where some URIs are relative.
Perhaps writing such graphs (regardless of the output format) should throw
an exception unless one is supplying a base URI.

>
>BananaRDF has some way to use Jena so that it creates the output it
>wants.  I thought BananaRDF achieved this by adding some sort of
>identifiable maker to URIs as the initial part of the URI.

No.

Here's my understanding of the design & goal of the banana-rdf API (I'm a
recent user)

banana-rdf is effectively a parameterized API for RDF.
The API parameter "binds" the generic banana-rdf API types & operations to
the types & operations of a particular API library (e.g. Jena, Sesame,
etcŠ)

So normally, it shouldn't matter which library one uses -- Jena, Sesame,
etc.. -- the results should be consistent.

For example, reading a graph with one API and reading the same graph with
another API should result in 2 API-specific graphs
that should be isomorphic to each other as far as the W3 RDF spec is
concerned.

Banana-rdf provides a generic API for constructing RDF graphs -- I.e., the
same code ca

Re: jena-text and persistent lucene index

2014-10-10 Thread Phillip Rhodes
On Fri, Oct 10, 2014 at 4:01 AM, Andy Seaborne  wrote:
>
> How do you know it does not work? The code (groovy?) does not read the
> index.

Hey Andy, I had written a separate reader program to test using the
index for queries.  I did
it that way to make sure I was seeing results from using the index,
and not accidentally getting
something that was cached in RAM or something.

Anyway, as it turns out, I managed to solve the problem.  As best as I
can tell, the issue
was this, or something close:   The first time(s) I ran this program,
I didn't yet have a
dir.close() line in there to close the Lucene Directory.  As a result,
I was getting
an incomplete Lucene index.  Later, after I fixed that, I kept running
the program
but since I was creating the exact same triples (and not deleting the
TDB dir between
runs) Jena-Text didn't reindex those triples since they already existed.

Perhaps you (or someone) can confirm if this is the way Jena Text would behave
in that regard?

Anyway, once I deleted my TDB store and started from scratch,
everything worked exactly
as expected.


Thanks!


Phil


Re: How to get all leaf subclass nodes in class view

2014-10-10 Thread Deyan Chen

在 2014年10月10日 22:25, Joshua TAYLOR 写道:

Are you asking how to get classes that don't have any (declared,
nontrivial, etc.) subclasses?  You could do that with the Jena Model
API, but a SPARQL query here would be *very* simple:

select ?class where {
   ?leaf a rdfs:Class .
   filter not exists { ?subleaf rdfs:subClassOf ?leaf }
}

Yes.
I don't find a convenient Jena Model API to do that. But the above 
SPARQL query is really very simple.

Thank you very much.



On Fri, Oct 10, 2014 at 10:11 AM, Deyan Chen  wrote:

在 2014年10月10日 19:40, Joshua TAYLOR 写道:

On Thu, Oct 9, 2014 at 11:23 PM, Deyan Chen  wrote:

class view

What is class view?

Maybe my expression is not right. It means class hierarchical structure in
an ontology schema.

---
Confidentiality Notice: The information contained in this e-mail and any
accompanying attachment(s) is intended only for the use of the intended
recipient and may be confidential and/or privileged of Neusoft Corporation,
its subsidiaries and/or its affiliates. If any reader of this communication
is not the intended recipient, unauthorized use, forwarding, printing,
storing, disclosure or copying is strictly prohibited, and may be
unlawful.If you have received this communication in error,please immediately
notify the sender by return e-mail, and delete the original message and all
copies from your system. Thank you.
---





---
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---


Re: How to get all leaf subclass nodes in class view

2014-10-10 Thread Joshua TAYLOR
Are you asking how to get classes that don't have any (declared,
nontrivial, etc.) subclasses?  You could do that with the Jena Model
API, but a SPARQL query here would be *very* simple:

select ?class where {
  ?leaf a rdfs:Class .
  filter not exists { ?subleaf rdfs:subClassOf ?leaf }
}


On Fri, Oct 10, 2014 at 10:11 AM, Deyan Chen  wrote:
> 在 2014年10月10日 19:40, Joshua TAYLOR 写道:
>>
>> On Thu, Oct 9, 2014 at 11:23 PM, Deyan Chen  wrote:
>>>
>>> class view
>>
>> What is class view?
>
> Maybe my expression is not right. It means class hierarchical structure in
> an ontology schema.
>
>>
>
> ---
> Confidentiality Notice: The information contained in this e-mail and any
> accompanying attachment(s) is intended only for the use of the intended
> recipient and may be confidential and/or privileged of Neusoft Corporation,
> its subsidiaries and/or its affiliates. If any reader of this communication
> is not the intended recipient, unauthorized use, forwarding, printing,
> storing, disclosure or copying is strictly prohibited, and may be
> unlawful.If you have received this communication in error,please immediately
> notify the sender by return e-mail, and delete the original message and all
> copies from your system. Thank you.
> ---



-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/


Re: How to get all leaf subclass nodes in class view

2014-10-10 Thread Deyan Chen

在 2014年10月10日 19:40, Joshua TAYLOR 写道:

On Thu, Oct 9, 2014 at 11:23 PM, Deyan Chen  wrote:

class view

What is class view?
Maybe my expression is not right. It means class hierarchical structure 
in an ontology schema.




---
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---


RE: Using Fuseki 2 as a web application

2014-10-10 Thread John A. Fereira
I had done a git clone from the jena project on github.  It looks like the last 
commit was on Oct. 3.   I just did a new fetch so I'll see if it makes any 
difference.

I haven't tried starting the server with a dataset that uses TDB.  When I try 
to "Add New Dataset" clicking on the button just turns the background of the 
button white (I’m running a recent version of Chrome).

I won't really be able to much more testing until next week but we're hosting a 
VIVO hackathon on Monday/Tuesday so I think there will be some interest.

-Original Message-
From: Andy Seaborne [mailto:a...@apache.org] 
Sent: Friday, October 10, 2014 5:43 AM
To: users@jena.apache.org
Subject: Re: Using Fuseki 2 as a web application

On 09/10/14 20:35, John A. Fereira wrote:
> Hijacking an old thread
>
> I've been playing around with the jena-fuseki2 code (from a recent clone of 
> the jena git repository) and have made pretty good progress getting it to 
> work with SDB, using the ReconnectingSDB jar file 
> (https://github.com/shellac/ReconnectingSDB).   On my laptop (windows 7),  I 
> have a configuration which connects to a SDB and deploys successfully into 
> Tomcat.  Although there are quite a few broken links in the UI, I can execute 
> sparql select queries and get valid results.  Now here's the weird part.  If 
> I copy all the code over to a linux box, everything seems to work.  It 
> deploys into tomcat but when I go to the web app it doesn't seem to recognize 
> that any datasets are available.  The logger output looks identical to what I 
> am seeing on my laptop (no errors, /ds was registered as a dataset) but 
> the app doesn't think it's available.
>
> Any ideas?
>

Hi John,

What happens if you start empty, and create a dataset? Then restart the 
server ... is that dataset still there?   i.e without SDB, do things 
work?  (and which code are you running from? )

Andy

PS I'm just in the process of adding Fuseki2 the nightly development builds.



Re: How to get all leaf subclass nodes in class view

2014-10-10 Thread Joshua TAYLOR
On Thu, Oct 9, 2014 at 11:23 PM, Deyan Chen  wrote:
> class view

What is class view?

-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/


Re: Using Fuseki 2 as a web application

2014-10-10 Thread Andy Seaborne

On 09/10/14 20:35, John A. Fereira wrote:

Hijacking an old thread

I've been playing around with the jena-fuseki2 code (from a recent clone of the 
jena git repository) and have made pretty good progress getting it to work with 
SDB, using the ReconnectingSDB jar file 
(https://github.com/shellac/ReconnectingSDB).   On my laptop (windows 7),  I 
have a configuration which connects to a SDB and deploys successfully into 
Tomcat.  Although there are quite a few broken links in the UI, I can execute 
sparql select queries and get valid results.  Now here's the weird part.  If I 
copy all the code over to a linux box, everything seems to work.  It deploys 
into tomcat but when I go to the web app it doesn't seem to recognize that any 
datasets are available.  The logger output looks identical to what I am seeing 
on my laptop (no errors, /ds was registered as a dataset) but the app 
doesn't think it's available.

Any ideas?



Hi John,

What happens if you start empty, and create a dataset? Then restart the 
server ... is that dataset still there?   i.e without SDB, do things 
work?  (and which code are you running from? )


Andy

PS I'm just in the process of adding Fuseki2 the nightly development builds.



Re: jena-text and persistent lucene index

2014-10-10 Thread Andy Seaborne

Phil,

How do you know it does not work? The code (groovy?) does not read the 
index.  Could you provide a complete example (I don't have groovy 
installed ATM).


(which version are you using?)

Andy

On 10/10/14 01:50, Phillip Rhodes wrote:

Jena crew:

I have Jena-Text pretty much working for what I want to do, but with
one caveat... it only seems to work with the Lucene RamDirectory.  If
I use a persistent dir, I don't find any documents being written to
the Lucene index.  Any help or suggestions are greatly appreciated.
Code sample follows:


---CODE---


package org.fogbeam.example.jenatext

import org.apache.jena.query.text.EntityDefinition
import org.apache.jena.query.text.TextDatasetFactory
import org.apache.jena.query.text.TextQuery
import org.apache.lucene.store.Directory
import org.apache.lucene.store.FSDirectory

import com.hp.hpl.jena.query.Dataset
import com.hp.hpl.jena.query.ReadWrite
import com.hp.hpl.jena.rdf.model.Model
import com.hp.hpl.jena.rdf.model.Resource
import com.hp.hpl.jena.rdf.model.Statement
import com.hp.hpl.jena.tdb.TDBFactory
import com.hp.hpl.jena.vocabulary.RDFS

class JenaTextMain6Write
{

 static main(args)
 {

 TextQuery.init();

 EntityDefinition entDef = new EntityDefinition("uri", "text",
RDFS.label.asNode()) ;

 // Lucene, in memory.
 Directory dir =  FSDirectory.open( new File( "jenastore/index" ) );

 // Join together into a dataset
 Dataset tdbDataset = TDBFactory.createDataset("jenastore/triples");
 Dataset ds = TextDatasetFactory.createLucene(tdbDataset, dir, entDef);


 try
 {

 ds.begin(ReadWrite.WRITE);

 Model m = ds.getDefaultModel();

 Resource rSubject = m.createResource(
"http://ontology.fogbeam.com/example/TestResource1"; );
 Resource rSubject2 = m.createResource(
"http://ontology.fogbeam.com/example/TestResource2"; );


 Statement s = m.createStatement(rSubject, RDFS.label,
"This is a Test Resource" );

 m.add( s );

 Statement s2 = m.createStatement(rSubject2, RDFS.label,
"Bratwurst Test" );

 m.add( s2 );

 ds.commit();

 dir.close();

 }
 catch( Exception e )
 {
 e.printStackTrace();
 ds.abort();
 }
 finally
 {
 if( ds != null )
 {
 ds.end();
 }
 }

 println "done";
 }

}

--- END CODE---



Phil
---
This message optimized for indexing by NSA PRISM