The following query seems to hate rex:hasNormalizedText triples that
aren't matched by the initial clause. That is, if we have

  x hasNormalizedText "taliban"
  x sameAs y
  y hasNormalizedText "foo"

all the tuples with y in the subject are returned EXCEPT the
hasNormalizedText tuple. Data follows at bottom.

PREFIX rex:   <http://www.basistech.com/ontologies/2010/6/rex.owl#>
PREFIX owl:   <http://www.w3.org/2002/07/owl#>
PREFIX x-arq: <urn:x-arq:>
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT{
  ?s ?p ?o .
  ?root ?p ?o .
  ?root rex:root "true"
}
WHERE
{
      { ?root rex:hasNormalizedText "Taliban" }
      UNION
      { ?root rex:hasNormalizedText "Taliban" .
        ?s (owl:sameAs|^owl:sameAs)* ?root .
      }
      UNION
      {
        ?root rex:hasNormalizedText "Taliban" .
        ?root ?pred ?s .
        ?pred rdfs:subPropertyOf* rex:relationship .
      }
      UNION
      {
        ?root rex:hasNormalizedText "Taliban" .
        ?root (owl:sameAs|^owl:sameAs)* ?t .
        ?t ?pred ?s .
        ?pred rdfs:subPropertyOf* rex:relationship .
      }
      UNION
      {
        ?root rex:hasNormalizedText "Taliban" .
        ?root ?pred ?t .
        ?pred rdfs:subPropertyOf* rex:relationship .
        ?t (owl:sameAs|^owl:sameAs)* ?s .
      }
      ?root ?p ?o .
      ?s ?p ?o .
}

------------- data ----------------


@prefix x-arq:   <urn:x-arq:> .
@prefix :        <http://www.basistech.com/ontologies/2010/6/rex.owl#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rex:     <http://www.basistech.com/ontologies/2010/6/rex.owl#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<uri:jug:x#notIndia>
      a       rex:Location ;
      rex:hasNormalizedText
              "Not India" .

<uri:jug:taliban#1>
      a       rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
              <uri:jug:pakistan#1> ;
      rex:hasNormalizedText
              "Taliban" ;
      owl:sameAs <uri:jug:taliban#2> , <uri:jug:staliban#1> ,
<uri:jug:taliban#3> .

rdfs:label
      a       owl:AnnotationProperty .

rex:LatitudeLongitude
      a       owl:Class ;
      rdfs:subClassOf rex:GeoLocation .

rex:Nationality
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:hasCustomEntityType
      a       owl:DatatypeProperty ;
      rdfs:comment "This property is set on entity references that are
tagged with a user-defined type."^^xsd:string ;
      rdfs:subPropertyOf owl:topDataProperty .

rex:hasNormalizedText
      a       owl:DatatypeProperty ;
      rdfs:comment "Normalized text of an entity reference"^^xsd:string ;
      rdfs:subPropertyOf owl:topDataProperty .

rex:EntityReference
      a       owl:Class ;
      rdfs:subClassOf
              [ a       owl:Restriction ;
                owl:onDataRange xsd:string ;
                owl:onProperty rex:hasEntityDetectionSource ;
                owl:qualifiedCardinality
                        "1"^^xsd:nonNegativeInteger
              ] ;
      rdfs:subClassOf
              [ a       owl:Restriction ;
                owl:onDataRange xsd:string ;
                owl:onProperty rex:hasContainingDocument ;
                owl:qualifiedCardinality
                        "1"^^xsd:nonNegativeInteger
              ] ;
      rdfs:subClassOf
              [ a       owl:Restriction ;
                owl:onDataRange xsd:string ;
                owl:onProperty rex:hasOriginalText ;
                owl:qualifiedCardinality
                        "1"^^xsd:nonNegativeInteger
              ] ;
      rdfs:subClassOf
              [ a       owl:Restriction ;
                owl:maxQualifiedCardinality
                        "1"^^xsd:nonNegativeInteger ;
                owl:onDataRange xsd:string ;
                owl:onProperty rex:hasCustomEntityType
              ] ;
      rdfs:subClassOf
              [ a       owl:Restriction ;
                owl:onDataRange xsd:string ;
                owl:onProperty rex:hasNormalizedText ;
                owl:qualifiedCardinality
                        "1"^^xsd:nonNegativeInteger
              ] .

rdfs:comment
      a       owl:AnnotationProperty .

<http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
      rdfs:subClassOf rex:relationship .

rex:Location
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:GeoLocation
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:CreditCardNumber
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:Date
      a       owl:Class ;
      rdfs:subClassOf rex:Temporal .

<uri:jug:taliban#2>
      a       rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
              <uri:jug:x#someplace> ;
      rex:hasNormalizedText
              "Taliban" .

<uri:jug:x#someplace>
      a       rex:Location ;
      rex:hasNormalizedText
              "Someplace Else" .

<uri:jug:pakistan#1>
      a       rex:Location ;
      rex:hasNormalizedText
              "Pakistan" ;
      rex:hasOriginalText "Pakistan" ;
      owl:sameAs <uri:jug:x#notIndia> .

rex:Religion
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:hasContainingDocument
      a       owl:DatatypeProperty ;
      rdfs:comment "A reference to the URI of the document where
something was discovered."@en ;
      rdfs:subPropertyOf owl:topDataProperty .

rex:hasOriginalText
      a       owl:DatatypeProperty ;
      rdfs:comment "The original text of a reference."^^xsd:string ;
      rdfs:subPropertyOf owl:topDataProperty .

rex:relationship
      a       owl:ObjectProperty ;
      rdfs:comment "All the relationships in the jape rules are set up
to be sub-properties of this."@en ;
      rdfs:subPropertyOf owl:topObjectProperty .

rex:Number
      a       owl:Class ;
      rdfs:subClassOf rex:Quantity .

rex:UTM
      a       owl:Class ;
      rdfs:subClassOf rex:GeoLocation .

rex:USA_SSN
      a       owl:Class ;
      rdfs:subClassOf rex:PersonalIdNumber .

rex:URL
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:Time
      a       owl:Class ;
      rdfs:subClassOf rex:Temporal .

[]    a       owl:AllDisjointClasses ;
      owl:members (rex:CreditCardNumber rex:Date rex:Distance
rex:DomainName rex:Email rex:Facility rex:FaxNumber rex:GeoLocation
rex:IPAddress rex:Identifier rex:LatitudeLongitude rex:Location
rex:Money rex:Nationality rex:Organization rex:Percent rex:Person
rex:PersonalIdNumber rex:Quantity rex:Religion rex:TelephoneNumber
rex:Temporal rex:URL rex:USA_SSN rex:UTM rex:Vehicle rex:Weapon) .

[]    a       [ a       owl:Restriction ;
                owl:onDataRange xsd:string ;
                owl:onProperty rex:hasOriginalText ;
                owl:qualifiedCardinality
                        "1"^^xsd:nonNegativeInteger
              ] .

rex:Organization
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

<http://www.basistech.com/ontologies/2010/6/rex.owl>
      a       owl:Ontology ;
      rdfs:comment "An ontology for entity references as extracted by
REX, with some base support for relationships."@en .

rex:ruleDataProperty
      a       owl:DatatypeProperty ;
      rdfs:comment "Any data properties discovered in the jape rules
are set up to be subprops of this."@en ;
      rdfs:subPropertyOf owl:topDataProperty .

rex:DomainName
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:PersonalIdNumber
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:TelephoneNumber
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:corefLink
      a       owl:ObjectProperty ;
      rdfs:subPropertyOf owl:sameAs .

rex:crossdocCorefLink
      a       owl:ObjectProperty ;
      rdfs:subPropertyOf rex:corefLink .

rex:indocCorefLink
      a       owl:ObjectProperty ;
      rdfs:subPropertyOf rex:corefLink .

<uri:jug:staliban#1>
      a       rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
              <uri:jug:pakistan#1> ;
      rex:hasNormalizedText
              "STaliban" .

<uri:jug:afghan#1>
      a       rex:Location ;
      rex:hasNormalizedText
              "Afghanistan" ;
      rex:hasOriginalText "Afghanistan" .

<uri:jug:taliban#3>
      a       rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
              <uri:jug:afghan#1> ;
      rex:hasNormalizedText
              "Taliban" .

rex:Distance
      a       owl:Class ;
      rdfs:subClassOf rex:Quantity .

rex:Money
      a       owl:Class ;
      rdfs:subClassOf rex:Quantity .

<uri:jug:unrelated#1>
      a       rex:Person ;
      rex:hasNormalizedText
              "Smith" ;
      rex:hasOriginalText "Smif" .

owl:topDataProperty
      a       owl:DatatypeProperty .

owl:topObjectProperty
      a       owl:ObjectProperty .

rex:IPAddress
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:Temporal
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:Facility
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:Identifier
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:FaxNumber
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:Vehicle
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:Email
      a       owl:Class ;
      rdfs:subClassOf rex:Identifier .

rex:Quantity
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:hasEntityDetectionSource
      a       owl:DatatypeProperty ;
      rdfs:comment "The source of the reference."^^xsd:string ;
      rdfs:subPropertyOf owl:topDataProperty .

rex:Person
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

rex:Weapon
      a       owl:Class ;
      rdfs:subClassOf rex:EntityReference .

[]    a       [ a       owl:Restriction ;
                owl:onDataRange xsd:string ;
                owl:onProperty rex:hasNormalizedText ;
                owl:qualifiedCardinality
                        "1"^^xsd:nonNegativeInteger
              ] .

rex:Percent
      a       owl:Class ;
      rdfs:subClassOf rex:Quantity .

owl:sameAs
      a       owl:ObjectProperty .

Reply via email to