thiemowmde added subscribers: Lydia_Pintscher, thiemowmde.
thiemowmde added projects: MediaWiki-extensions-WikibaseRepository, Wikidata-Sprint-2016-08-30, Need-volunteer.
thiemowmde triaged this task as "Normal" priority.
thiemowmde added a comment.

The relevant code is in EntitySearchHelper.php, line 122, getExactMatchForEntityId. The most easiest solution I can think of is a second $this->idParser->parse( … ) try, when the first failed, with a bit of trivial normalization applied. I would do it like this:

if ( preg_match( '/.*(\b\w+)/s', $term ) {
    $lastWord = $matches[1];
    
}

What this does is searching for the last word (assuming all entity IDs are sequences of ASCII word characters) in the input string. This will find the ID number in (Q42), https://www.wikidata.org/wiki/Q42, http://www.wikidata.org/entity/Q42 and many other cases. It's compatible with all entity types we have.

It will not find the number in Q42 (Douglas Adams), which is not different from the status quo. It may behave a bit inconsistent because it will find the number when it's not followed by ASCII word characters, e.g. Q11738 (Ö).

The "worst" case I can think of is a weird input string like Q41 and Q42. It will only suggest the last ID, which is not a big deal in my opinion.

WARNING: Make sure this plays nicely with PropertySuggester. I had a quick look and believe it does, but this needs testing.

TASK DETAIL
https://phabricator.wikimedia.org/T117763

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: thiemowmde
Cc: thiemowmde, Lydia_Pintscher, Nikki, Pigsonthewing, Aklapper, StudiesWorld, agray, D3r1ck01, Izno, Wikidata-bugs, aude, TheDJ, Mbch331
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to