0

I am trying to query Wikidata for the uris of entities, given their label. I am passing the label as a string argument in the query like this:

?uri skos:altLabel|skos:prefLabel|rdfs:label \" """+argument+"""\"@en .

However, due to the space that I have to leave between " and """+argument+""" my query does not find any results because the label doesn't match any existing one. If I don't use a space, then all four " stick together and the syntax of the query gets ruined.

Does anybody have any solutions that will allow me to find results for my query?

  • it would be helpful to mention programming language and a self-contained code snippet ... also, for Python we had a similar question yesterday how to use inline strings: https://stackoverflow.com/questions/72143800/how-can-we-use-a-python-string-variable-in-a-sparql-query – UninformedUser May 08 '22 at 06:49
  • by the way in SPARQL you can also use single quotes to denote string literals, i.e. `'somestring'@en` – UninformedUser May 08 '22 at 06:51
  • 1
    @UninformedUser Using single quotes worked. Thank you! – user19063810 May 08 '22 at 13:43

0 Answers0