Hi, thanks for the suggestion! I didn't think of property paths.
So in case of just optional list /list:member? works fine. And for my
more complicated case as you wrote.
On 12/12/2022 17.08, Lorenz Buehmann wrote:
I don't know your full query restrictions, but without given
properties it would be a "simple" property path, no? Something like
owl:someValuesFrom/((owl:intersectionOf|owl:unionOf)/list:member)?
where the list closure is optional and if you want to make it nestested
(owl:someValuesFrom/((owl:intersectionOf|owl:unionOf)/list:member)?)*
So a query like
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix list: <http://jena.apache.org/ARQ/list#>
select * {
?subclass rdfs:subClassOf|owl:equivalentClass
[(owl:intersectionOf|owl:unionOf)/list:member/(owl:someValuesFrom/((owl:intersectionOf|owl:unionOf)/list:member)?)*
?m]
FILTER(isIRI(?m))
}
could work. You could even try to make it more generic.
But maybe you have different requirements, in that case it would be
easier to help with sample data. My sample data now was
@prefix :
<http://www.semanticweb.org/user/ontologies/2022/11/untitled-ontology-100#>
.
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:Foo rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Class ;
owl:unionOf ( :A
[ rdf:type owl:Restriction ;
owl:onProperty :p ;
owl:someValuesFrom [
rdf:type owl:Class ;
owl:unionOf ( :B
[ rdf:type owl:Restriction ;
owl:onProperty :q ;
owl:someValuesFrom :C
]
)
]
]
)
] .
Cheers,
Lorenz
On 12.12.22 13:49, Mikael Pesonen wrote:
Is there a shortcut for making queries where a data value can be
single item or list of items?
For example this is how I do a query now using UNION. Both parts are
identical except for the single/list section in owl:someValuesFrom
[]. This is still somewhat readable but if there are multiple
occurences, query lenght and complexity grows exponentially.
{
?finding owl:equivalentClass|rdfs:subClassOf [
owl:intersectionOf [
list:member [
rdf:type owl:Restriction ;
owl:onProperty id:609096000 ;
owl:someValuesFrom [
rdf:type owl:Restriction ;
owl:onProperty id:363698007 ;
owl:someValuesFrom ?site
]
]
]
]
}
UNION
{
?finding owl:equivalentClass|rdfs:subClassOf [
owl:intersectionOf [
list:member [
rdf:type owl:Restriction ;
owl:onProperty id:609096000 ;
owl:someValuesFrom [
owl:intersectionOf [
list:member [
rdf:type owl:Restriction ;
owl:onProperty id:363698007 ;
owl:someValuesFrom ?site
]
]
]
]
]
]
}
The data is not ours so we can't make everything lists.
--
Lingsoft - 30 years of Leading Language Management
www.lingsoft.fi
Speech Applications - Language Management - Translation - Reader's and Writer's
Tools - Text Tools - E-books and M-books
Mikael Pesonen
Semantic Technologies
e-mail: mikael.peso...@lingsoft.fi
Tel. +358 2 279 3300
Time zone: GMT+2
Helsinki Office
Eteläranta 10
FI-00130 Helsinki
FINLAND
Turku Office
Kauppiaskatu 5 A
FI-20100 Turku
FINLAND