Fuzzy entity query in Wikidata with Sparql times out

后端 未结 3 2069
灰色年华
灰色年华 2021-01-07 03:41

I\'m trying to do a fuzzy (ie.. partial or case-insensitive) entity label lookup in Wikidata with Sparql (via the online endpoint). Unfortunately these return a \"Query

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-07 03:51

    You can do this online if you change your filter to use the "contains" function.

    Example:

     SELECT ?item WHERE {
                ?item rdfs:label ?label .
                FILTER( contains(lcase(?label), 'arles lin' ))
     }
     LIMIT 20
    

    Reference: contains is listed as one of the XPath functions you can use in SPARQL. See: https://www.w3.org/2009/sparql/wiki/Feature:FunctionLibrary#XQuery_1.0_and_XPath_2.0_Functions_and_Operators

    Example 2: (with more triples to optimise results)

    PREFIX skos: 
    SELECT ?item  ?label WHERE {
                ?item rdfs:label ?label .
                ?item rdf:type dbo:Person   #Works with our without this too, also try skos:Category
                FILTER( contains(lcase(?label), 'arles lin' ) && LANGMATCHES(LANG(?label), "en")) 
     }
     LIMIT 20
    

提交回复
热议问题