Most specific type and full text search support

1 view
Skip to first unread message

rakefr...@gmail.com

unread,
Oct 31, 2013, 1:45:02 PM10/31/13
to
Hello guys,

I have the following -example- ontology and data: http://www.apaste.info/jyw6, and I'm running the following queries:

---
$ ./stardog query "test;reasoning=SL" "PREFIX sp: <tag:stardog:api:property:> SELECT DISTINCT ?s ?t WHERE { ?s sp:directType ?t. ?s a owl:NamedIndividual. ?t a owl:Class. }"
 
+----------------+------------------+
|       s        |        t         |
+----------------+------------------+
| data:ASmithish | edu:Student      |
| data:JSmith    | net:Person       |
| data:JSmith    | owl:Thing        |
| data:Geeks     | owl:Thing        |
| data:ASmithish | net:Animal       |
| data:PRing     | owl:Thing        |
| data:Class01   | net:Organization |
| data:PRing     | net:Person       |
| data:JSmith    | edu:Student      |
| data:Class01   | edu:Group        |
| data:ASmithish | net:Person       |
| data:ASmithish | owl:Thing        |
| data:PRing     | net:Animal       |
| data:JSmith    | net:Animal       |
| data:Class01   | owl:Thing        |
| data:Geeks     | net:Organization |
+----------------+------------------+
---

What I expected here is to get the the most specific type for each owl:NamedIndividual, that is, just one type for each ?s.

My intention is to use this query together with a full text search filter like this:

---
$ ./stardog query "test;reasoning=SL" "PREFIX sp: <tag:stardog:api:property:>  SELECT DISTINCT ?s ?t ?score ?text WHERE { ?s sp:directType ?t; ?p ?text. ( ?text ?score ) <http://jena.hpl.hp.com/ARQ/property#textMatch> ('smithi~' 0.0 100). ?s a owl:NamedIndividual. ?t a owl:Class. ?p a owl:DatatypeProperty. }"

com.clarkparsia.pellet.api.term.impl.entity.NamedIndividualImpl cannot be cast to com.clarkparsia.pellet.api.term.entity.NamedClass
---

And this is the result I expect in this example:

---
data:JSmith    edu:Student <score1> "Jonh Smithish"
data:ASmithish edu:Student <score2> "Anna Smithish"
---

So, here are my questions for you:

* I was expecting Stardog to return ONLY the most specific types for ?s, it's returning more than one type (even for the same ontology, Animal<-Person). Why and how can I fix that?

* Is it possible to remove the limit (100) in the #textMatch line and bound just the ?score (so I can sort the results)? I want a limit of 100 for the whole query, not for ?text (which I think could result in an empty result even if there are acceptable instances in the DB)

Thank you!

rakefr...@gmail.com

unread,
Nov 1, 2013, 5:27:41 PM11/1/13
to sta...@clarkparsia.com
Could you find something wrong in the ontology/data I sent? I can't find the error..

Héctor Pérez-Urbina

unread,
Nov 4, 2013, 7:57:57 AM11/4/13
to stardog
Hi,

This does look a bit strange. I'll take a closer look today and let you know what I find.


--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en



--
Best,
Héctor

Héctor Pérez-Urbina

unread,
Nov 4, 2013, 7:04:31 PM11/4/13
to stardog
Hi,


Yes, this was a bug in the parsing of the query, which we fixed today. I tried your query with the latest version (not yet released) and it worked as expected. We'll include the fix in the next release.
 

My intention is to use this query together with a full text search filter like this:

---
$ ./stardog query "test;reasoning=SL" "PREFIX sp: <tag:stardog:api:property:>  SELECT DISTINCT ?s ?t ?score ?text WHERE { ?s sp:directType ?t; ?p ?text. ( ?text ?score ) <http://jena.hpl.hp.com/ARQ/property#textMatch> ('smithi~' 0.0 100). ?s a owl:NamedIndividual. ?t a owl:Class. ?p a owl:DatatypeProperty. }"

com.clarkparsia.pellet.api.term.impl.entity.NamedIndividualImpl cannot be cast to com.clarkparsia.pellet.api.term.entity.NamedClass

These exceptions look similar to a former problem we had with determining the type of query variables. In any case, I tried this query and got the expected results (I just needed to make sure my DB was searchable). 
 
---

And this is the result I expect in this example:

---
data:JSmith    edu:Student <score1> "Jonh Smithish"
data:ASmithish edu:Student <score2> "Anna Smithish"
---

So, here are my questions for you:

* I was expecting Stardog to return ONLY the most specific types for ?s, it's returning more than one type (even for the same ontology, Animal<-Person). Why and how can I fix that? 

This is fixed.
 

* Is it possible to remove the limit (100) in the #textMatch line and bound just the ?score (so I can sort the results)? I want a limit of 100 for the whole query, not for ?text (which I think could result in an empty result even if there are acceptable instances in the DB)

I'm not sure about this one. I'll see what I can find and come back to you. 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en



--
Best,
Héctor



--
Best,
Héctor

Mike Grove

unread,
Nov 4, 2013, 7:49:57 PM11/4/13
to stardog
Yeah, the limit is optional.  You can use the normal LIMIT clause in SPARQL to restrict the total number of results, the inline limit is only for the number of results out of the full-text index.

Cheers,

Mike

rakefr...@gmail.com

unread,
Nov 4, 2013, 8:40:11 PM11/4/13
to sta...@clarkparsia.com
Is there any chance to get the new release anytime soon or at least a patch or workaround for this query? I have to do a product demo in 2 weeks and the search module (on wich many other sections are based) use this kind of query heavily together with full text search.

Regarding full text search, I think I tried to remove the limit part but it didn't work, I'll check again just in case.

Thank you guys!

rakefr...@gmail.com

unread,
Nov 4, 2013, 9:59:50 PM11/4/13
to
I just checked the full text search query again without the limit, it's not needed as you said, thanks.

EDITED: never mind about what I wrote here initially, it was due to reasoning.schema.graphs having the value "default" instead of "all" :)

Kendall Clark

unread,
Nov 5, 2013, 9:32:27 AM11/5/13
to stardog

On Mon, Nov 4, 2013 at 8:40 PM, <rakefr...@gmail.com> wrote:
Is there any chance to get the new release anytime soon or at least a patch or workaround for this query? I have to do a product demo in 2 weeks and the search module (on wich many other sections are based) use this kind of query heavily together with full text search.

This kind of prioritization is exactly what distinguishes users from customers, by the way.

Cheers,
Kendall Clark

rakefr...@gmail.com

unread,
Nov 5, 2013, 10:51:07 AM11/5/13
to sta...@clarkparsia.com
I understand your position and completely agree with you, but this project is being developed in an academic environment so before I can ask the University to buy the license I must show it's worth.

I'm now trying to rewrite the query in a way that it's correctly parsed, any information in this matter would be highly appreciated.

Thank you!

Héctor Pérez-Urbina

unread,
Nov 5, 2013, 11:42:34 AM11/5/13
to stardog
Hi,

I did a little test and things worked out as expected. First, I add the TBox to the default graph and the ABox to a named graph:

...

aConn.begin();

aConn.add().io().file(new File("/Users/hector/Desktop/DTTBox.ttl"));

aConn.add().io().context(VF.createURI("urn:context")).file(new File("/Users/hector/Desktop/DTABox.ttl"));

aConn.commit();


Then, I check if I get the expected results from the query:

Value[][] expected = { {VF.createURI("http://edu.com/Student")}, {VF.createURI("http://edu.com/Group")}, {VF.createURI("http://net.com/Person")}, {VF.createURI("http://net.com/Organization")}, {VF.createURI("http://net.com/Animal")}, {OWL.THING} };

String aQuery = "select distinct ?type where { graph ?g { ?s a ?type. ?s a owl:NamedIndividual. } }";

ConnectionTestUtils.assertQueryResults(aConn.select(aQuery1), expected);

...

Is this similar to what you did?



On Mon, Nov 4, 2013 at 9:45 PM, <rakefr...@gmail.com> wrote:
I just checked the full text search query again without the limit, it's not needed as you said, thanks.

I continued testing the system and I found what seems to be another error. Consider the following query for the same ontology and data.

select distinct ?type
where { 
  ?s a ?type.
  ?s a owl:NamedIndividual.
  ?type a owl:Class.
}

This one works fine, it returns all defined types (even those inferred through rdfs:doman and rdfs:name).

Now, put the same data into a graph as my application does (because it deals with many kind of data so I separated it into graphs), the query becomes this:

select distinct ?type
where { 
  graph ?g {
    ?s a ?type.
    ?s a owl:NamedIndividual.
    ?type a owl:Class.
  }
}

And this query returns nothing at all. Shouldn't it be equivalent? I tried putting the ontology on the default graph and the data on a named graph and it didn't help..

Thank you for your time.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en



--
Best,
Héctor
DTABox.ttl
DTTBox.ttl

rakefr...@gmail.com

unread,
Nov 5, 2013, 11:58:20 AM11/5/13
to sta...@clarkparsia.com
Hector,

Yes, that's exactly what I did. After I sent the message I noticed the problem wasn't Stardog or the query, it was the option reasoning.schema.graphs, as I mentioned in the edited message here (quoted below).

EDITED: never mind about what I wrote here initially, it was due to reasoning.schema.graphs having the value "default" instead of "all" :)

Thank you.

rakefr...@gmail.com

unread,
Nov 6, 2013, 12:19:05 PM11/6/13
to sta...@clarkparsia.com
I think I tried everything, even the expanded version of the query (which I pasted below), but I get the same results over and over.

SELECT ?s ?type
WHERE {

  ?s a ?type.
  ?s a owl:NamedIndividual.
  ?type a owl:Class.
  
  FILTER NOT EXISTS {
    ?s a ?type2.
    ?type2 rdfs:subClassOf ?type.
    FILTER NOT EXISTS {
      ?type2 owl:equivalentClass ?type.
    }
  }
}

Same query using "rdfs:subClassOf+":

SELECT ?s ?type
WHERE {

  ?s a ?type.
  ?s a owl:NamedIndividual.
  ?type a owl:Class.
  
  FILTER NOT EXISTS {
    ?s a ?type2.
    ?type2 rdfs:subClassOf+ ?type.
  }
}

I'm clueless. Any idea or workaround for this kind of query?

Thank you guys for your time!

Mike Grove

unread,
Nov 6, 2013, 12:22:03 PM11/6/13
to stardog
What are you trying to accomplish?

Cheers,

Mike
 

Thank you guys for your time!

--

rakefr...@gmail.com

unread,
Nov 6, 2013, 12:40:44 PM11/6/13
to
Hello Mike,

Given the ontology and data of my first post in this thread (http://www.apaste.info/mtml), I want to get all named individuals with their MOST specific type (just one).

I first tried with sp:directType, but as Hector confirmed, there is/was a bug in Stardog so it's not working:

---
$ ./stardog query "test;reasoning=SL" "PREFIX sp: <tag:stardog:api:property:> SELECT DISTINCT ?s ?t WHERE { ?s sp:directType ?t. ?s a owl:NamedIndividual. ?t a owl:Class. }"
 
+----------------+------------------+
|       s        |        t         |
+----------------+------------------+
| data:ASmithish | edu:Student      |
| data:JSmith    | net:Person       |
| data:JSmith    | owl:Thing        |
| data:Geeks     | owl:Thing        |
| data:ASmithish | net:Animal       |
| data:PRing     | owl:Thing        |
| data:Class01   | net:Organization |
| data:PRing     | net:Person       |
| data:JSmith    | edu:Student      |
| data:Class01   | edu:Group        |
| data:ASmithish | net:Person       |
| data:ASmithish | owl:Thing        |
| data:PRing     | net:Animal       |
| data:JSmith    | net:Animal       |
| data:Class01   | owl:Thing        |
| data:Geeks     | net:Organization |
+----------------+------------------+
---

Then I tried with the query of my last message, but it returns the same results.

Here is the expected result:

---
+----------------+------------------+
|       s        |        t         |
+----------------+------------------+
| data:ASmithish | edu:Student      |
| data:PRing     | net:Person       |
| data:JSmith    | edu:Student      |
| data:Class01   | edu:Group        |
| data:Geeks     | net:Organization |
+----------------+------------------+
---

Is that clear?

rakefr...@gmail.com

unread,
Nov 8, 2013, 5:24:59 PM11/8/13
to sta...@clarkparsia.com
This works like a charm in release 2.0.3, you guys are the best!!


On Wednesday, November 6, 2013 3:39:38 PM UTC-2, rakefr...@gmail.com wrote:
Hello Mike,

Given the ontology and data of my first post in this thread (http://www.apaste.info/mtml), I want to get all named individuals with their MOST specific type (just one).

I first tried with sp:directType, but as Hector confirmed, there is/was a bug in Stardog so it's not working:

---
$ ./stardog query "test;reasoning=SL" "PREFIX sp: <tag:stardog:api:property:> SELECT DISTINCT ?s ?t WHERE { ?s sp:directType ?t. ?s a owl:NamedIndividual. ?t a owl:Class. }"
 
+----------------+------------------+
|       s        |        t         |
+----------------+------------------+
| data:ASmithish | edu:Student      |
| data:JSmith    | net:Person       |
| data:JSmith    | owl:Thing        |
| data:Geeks     | owl:Thing        |
| data:ASmithish | net:Animal       |
| data:PRing     | owl:Thing        |
| data:Class01   | net:Organization |
| data:PRing     | net:Person       |
| data:JSmith    | edu:Student      |
| data:Class01   | edu:Group        |
| data:ASmithish | net:Person       |
| data:ASmithish | owl:Thing        |
| data:PRing     | net:Animal       |
| data:JSmith    | net:Animal       |
| data:Class01   | owl:Thing        |
| data:Geeks     | net:Organization |
+----------------+------------------+
---

Then I tried with the query of my last message, but it returns the same results.

Here is the expected result:

---
+----------------+------------------+
|       s        |        t         |
+----------------+------------------+
| data:ASmithish | edu:Student      |
| data:PRing     | net:Person       |
| data:JSmith    | edu:Student      |
| data:Class01   | edu:Group        |
| data:Geeks     | net:Organization |
+----------------+------------------+
---

Is that clear?
Reply all
Reply to author
Forward
0 new messages