99of9 / Entity-Explosion

A Chrome browser extension
GNU General Public License v3.0
26 stars 8 forks source link

Nobelprize API page gives error #16

Closed salgo60 closed 2 years ago

salgo60 commented 3 years ago

I have played around see https://github.com/99of9/Entity-Explosion/issues/15

When on page http://api.nobelprize.org/2.1/laureate/1002 --> I get wrong person

image

cc: @Visbystar

99of9 commented 2 years ago

I'm working on this.

This query demonstrates a clipping problem: (saving it here in case I have to come back to it later)

https://query.wikidata.org/#PREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0A%0ASELECT%20DISTINCT%20%3FiriLabel%20%3Firi%20%3Fprop%20%3Fformatter_url%20%3Ff_url_start%20%3Ff_url_end%20%3Fid_uncut%20%3Fregex%20%3Fid%20WHERE%20%7B%0A%20%20%20%20hint%3AQuery%20hint%3Aoptimizer%20%22None%22.%0A%20%20%20%20VALUES%20%28%20%3Ftest_url0%20%29%20%7B%20%28%22http%3A%2F%2Fapi.nobelprize.org%2F2.1%2Flaureate%2F1002%22%29%20%7D%0A%20%20%20%20%7B%3Fprop%20p%3AP1630%2Fps%3AP1630%20%3Fformatter_url0%20.%7D%20%20UNION%20%20%7B%3Fprop%20p%3AP3303%2Fps%3AP3303%20%3Fformatter_url0%20.%7D%0A%20%20%20%20BIND%20%28REPLACE%28%3Ftest_url0%2C%22%5Ehttps%3A%2F%2F%22%2C%22%22%29%20AS%20%3Ftest_url1%29%0A%20%20%20%20BIND%20%28REPLACE%28%3Ftest_url1%2C%22%5Ehttp%3A%2F%2F%22%2C%22%22%29%20AS%20%3Ftest_url2%29%0A%20%20%20%20BIND%20%28REPLACE%28%3Ftest_url2%2C%22%5Ewww.%22%2C%22%22%29%20AS%20%3Ftest_url%29%0A%20%20%20%20BIND%20%28REPLACE%28%3Fformatter_url0%2C%22%5Ehttps%3A%2F%2F%22%2C%22%22%29%20AS%20%3Fformatter_url1%29%0A%20%20%20%20BIND%20%28REPLACE%28%3Fformatter_url1%2C%22%5Ehttp%3A%2F%2F%22%2C%22%22%29%20AS%20%3Fformatter_url2%29%0A%20%20%20%20BIND%20%28REPLACE%28%3Fformatter_url2%2C%22%5Ewww.%22%2C%22%22%29%20AS%20%3Fformatter_url%29%0A%20%20%20%20FILTER%20%28CONTAINS%28%20%3Fformatter_url%2C%20%22%241%22%20%29%20%29%0A%20%20%20%20BIND%20%28STRBEFORE%28%20%3Fformatter_url%2C%20%22%241%22%20%29%20AS%20%3Ff_url_start%20%29%0A%20%20%20%20BIND%20%28STRAFTER%28%20%3Fformatter_url%2C%20%22%241%22%20%29%20AS%20%3Ff_url_end%20%29%0A%20%20%20%20FILTER%28STRSTARTS%28%20%3Ftest_url%2C%20%3Ff_url_start%20%29%29%0A%20%20%20%20FILTER%28STRENDS%28%20%3Ftest_url%2C%20%3Ff_url_end%20%29%29%0A%20%20%20%20BIND%20%28%20SUBSTR%28%20%3Ftest_url%2C%201%2BSTRLEN%28%3Ff_url_start%29%2C%20STRLEN%28%3Ftest_url%29-STRLEN%28%3Ff_url_start%29-STRLEN%28%3Ff_url_end%29%20%29%20AS%20%3Fid_uncut%20%29%0A%20%20%20%20%7B%3Fprop%20p%3AP1793%2Fps%3AP1793%20%3Fregex%20.%7D%0A%20%20%20%20UNION%0A%20%20%20%20%7B%3Fprop%20p%3AP2302%20%3Fstatement%20.%0A%20%20%20%20%3Fstatement%20%3Fps%20wd%3AQ21502404%20.%0A%20%20%20%20%3Fstatement%20pq%3AP1793%20%3Fregex%20.%7D%0A%20%20%20%20BIND%20%28%20REPLACE%20%28%3Fid_uncut%2C%20CONCAT%28%22%28%22%2C%3Fregex%2C%22%29.%2a%22%29%2C%22%241%22%2C%22i%22%29%20AS%20%3Fid%20%29%0A%20%20%20%20BIND%20%28%20LCASE%28%3Fid%29%20AS%20%3Flcid%29%0A%20%20%20%20%3Fprop%20wikibase%3AdirectClaim%20%3FpropRel%20.%0A%20%20%20%20%7B%3Firi%20%3FpropRel%20%3Fid%20.%7D%20UNION%20%7B%3Firi%20%3FpropRel%20%3Flcid%20.%7D%0A%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%7D%20.%0A%7D%0AORDER%20BY%20ASC%28%3Fname%29

99of9 commented 2 years ago

It's something to do with the regex preferring to stop once it's found an option from the first alternative rather than a longer option from the second alternative: https://regex101.com/r/cZqnVU/1

It looks like the problem will go away if I reverse the order of the alternatives.

99of9 commented 2 years ago

I flipped the order around in the regex: https://www.wikidata.org/w/index.php?title=Property:P8024&diff=prev&oldid=1587705722

It now seems to work. Regex is still a bit mysterious to me.

salgo60 commented 2 years ago

Thanks works for me