Attributes | Values |
---|
type
| |
Date Created
| |
Date Modified
| |
label
| - VirtTipsAndTricksGuideCustomExactDate
|
maker
| |
Title
| - VirtTipsAndTricksGuideCustomExactDate
|
isDescribedUsing
| |
has creator
| |
content
| - %META:TOPICPARENT{name="VirtTipsAndTricksGuide"}%
---+How Can I Get an exact mapping for a date?
Assume a given attempts to get an exact mapping for the literal "1950" using <b>bif:contains</b>:
<verbatim>
SPARQL
SELECT DISTINCT ?s ?o
FROM <http://dbpedia.org>
WHERE
{
?s ?p ?o .
FILTER( bif:contains (?o, '"1950"')
&& isLiteral(?o)
&& ( str(?p) ! = rdfs:label || str(?p) != foaf:name
&& ( ?o='1950')
)
}
</verbatim>
As an <b>integer</b> 1950 or <b>date</b> 1950-01-01 are not texts, they are not in
free-text index and thus invisible for CONTAINS free-text predicate.
A possible way to make them visible that way is to introduce an
additional RDF predicate that will contain objects of the triples in question,
converted to strings via str() function.
Thus better results will be approached: if searches about dates are frequent then a
new predicate can have date/datetime values extracted from texts, eliminating the need for bif:contains.
Therefor, the query from above should be changed to:
<verbatim>
SPARQL
SELECT DISTINCT ?s ?o
FROM <http://dbpedia.org>
WHERE
{
?s ?p ?o .
FILTER ( isLiteral(?o)
&& ( str(?p) != str(rdfs:label) || str(?p) != foaf:name )
&& str(?o) in ("1950", "1950-01-01"))
}
</verbatim>
---+++Related
* [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]]
* [[http://docs.openlinksw.com/virtuoso/rdfsparql.html][SPARQL]]
|
id
| - 04d0ed989d3bb960892130e44cc0c594
|
link
| |
has container
| |
http://rdfs.org/si...ices#has_services
| |
atom:title
| - VirtTipsAndTricksGuideCustomExactDate
|
links to
| |
atom:source
| |
atom:author
| |
atom:published
| |
atom:updated
| |
topic
| |
is made
of | |
is container of
of | |
is link
of | |
is http://rdfs.org/si...vices#services_of
of | |
is creator of
of | |
is atom:entry
of | |
is atom:contains
of | |