SPARQL Matching literals with ** ANY ** Language tags without timeout

I need to select an object that has a "taxon rank (P105)" from "species (Q7432)" that have a label that matches an alphabetic string, such as Jerusalem artichoke.

I am testing queries https://query.wikidata.org ; this request goes well and returns the object to me with a satisfactory response time:

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE {
  ?entity rdfs:label "Topinambur"@de . 
  ?entity wdt:P105 wd:Q7432.
}
LIMIT 100 

The problem is that my attribute is not to specify the language , but the lexical forms of labels in the basic dataset (wikidata) have language tags , so I need a way to get Literal equality for any language .

I tried some possible solution, but I did not find any query that would not lead to the following: TIMEOUT messagecom.bigdata.bop.engine.QueryTimeoutException: Query deadline is expired

Here is a list of what I tried (..and always get TIMEOUT):

1) based on this answer I tried:

SELECT * WHERE {
  ?entity rdfs:label ?label FILTER ( str( ?label ) = "Topinambur") . 
  ?entity wdt:P105 wd:Q7432.
}
LIMIT 100

2) based on other documentation that I tried:

SELECT * WHERE {
  ?entity wdt:P105 wd:Q7432.
  ?entity rdfs:label ?label FILTER regex(?label, "^Topinambur")  .  
}
LIMIT 100

3) and

   SELECT * WHERE {
      ?entity wdt:P105 wd:Q7432.
      ?entity rdfs:label ?label .
      FILTER langMatches( lang(?label), "*" )
      FILTER (?label = "Topinambur")
   }
   LIMIT 100

What I'm looking for is a solution for performers or some kind of SPARQL syntax that does not end with a TIMEOUT message .

PS: with reference to http://www.rfc-editor.org/rfc/bcp/bcp47.txt I do not understand if language rangesor `` wildcards '' could have been in any way.

EDIT

( ) DbPedia : https://dbpedia.org/sparql ( IRI): http://dbpedia.org

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/> 

SELECT ?resource 
WHERE { 
 ?resource rdfs:label ?label .  FILTER ( str( ?label ) = "Topinambur").
 ?resource rdf:type dbo:Species
 }
LIMIT 100

, Wikidata, .

+4
2

:

  • .
    ?entity wdt:P171+ wd:Q25314 .

  • , .

  • Quarry ( ).


- Virtuoso wikidata.dbpedia.org:

SELECT ?s WHERE { 
   ?resource rdfs:label ?label .
   ?label bif:contains "'topinambur'" .
   BIND ( IRI ( REPLACE ( STR(?resource),
                          "http://wikidata.dbpedia.org/resource",
                          "http://www.wikidata.org/entity"
                        )
              ) AS ?s
        )
}

!


, - wikidata.dbpedia.org, :

PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT ?resource WHERE { 
   ?resource rdfs:label ?label .
   FILTER ( STR(?label) = "Topinambur" ) .
}

!


:

wd:Q161378 rdfs:label "topinambur"@ru .

, "topinambur" Russian.

+2

- string . FILTER, . UNION :

SELECT ?entity WHERE {
  ?entity wdt:P105 wd:Q7432.
  { ?entity rdfs:label "Topinambur"@de . }
  UNION { ?entity rdfs:label "Topinambur"@en . }
  UNION { ?entity rdfs:label "Topinambur"@fr . }
}
GROUP BY ?entity
LIMIT 100 

!

, , . .

+2

Source: https://habr.com/ru/post/1658846/


All Articles