"Illegal group reference" in Identifiers panel in chemical class
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- Go to http://127.0.0.1:8100/chemical-class/Q61476#identifiers or https://scholia.toolforge.org/chemical-class/Q61476#identifiers
- "This query has timed out"
- Go further on to WD query
- Press blue button
- "Illegal group reference"
Expected behavior Something should be returned
Screenshots
Additional context There is no http://127.0.0.1:8100/chemical-class/Q46995757#identifiers content. Is this because of a Scholia problem or the data?
This seems to work:
PREFIX target: <http://www.wikidata.org/entity/Q61476>
SELECT
?IDpred ?IDpredLabel
?id ?idUrl
?IDpredDescription
{
target: ?IDdir ?id .
?IDpred wikibase:directClaim ?IDdir ;
wdt:P31 wd:Q19833835 .
OPTIONAL {
?IDpred wdt:P1630 ?formatterurl .
BIND(IRI(REPLACE(?formatterurl, '\\$1', str(?id))) AS ?idUrl).
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
ORDER BY ASC(?IDpredLabel)
LIMIT 500
The problems seems to be "OC([*])=O |$;;R;$|" in https://www.wikidata.org/wiki/Q61476. There are several dollar signs in the identifier. This confuses the REPLACE function and one would need to escape the dollar sign.
This seems to work:
PREFIX target: <http://www.wikidata.org/entity/Q61476>
SELECT
(REPLACE(STR(?identifier), "\\$", "\\\\\\\\\\$") AS ?test)
(?identifierLabel AS ?identifier_) ?identifier_Url
?url_pattern
?property_item ?property_itemLabel ?property_itemDescription
WHERE {
target: ?IDdir ?identifier .
?property_item wikibase:directClaim ?IDdir ;
wdt:P31 wd:Q19833835 .
OPTIONAL {
?property_item wdt:P1630 ?url_pattern .
}
BIND(CONCAT(?identifier, " ↗") AS ?identifierLabel)
BIND(REPLACE(STR(?identifier), "\\$", "--ESCAPED DOLLARS SIGN--") AS ?escaped_identifier)
BIND((REPLACE(?url_pattern, "\\$1", ?escaped_identifier)) AS ?identifier_Url_)
BIND(IRI(REPLACE(?identifier_Url_, "--ESCAPED DOLLARS SIGN--", "\\$")) AS ?identifier_Url)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
But it looks crazy.
5. "Illegal group reference"
@fnielsen, sorry, I seem to have missed this bug report. On my radar now.