-
Notifications
You must be signed in to change notification settings - Fork 942
Switch over spice plugins with regex to trigger words (where applicable) #127
Comments
Examples:
should really be:
Also,
should really be:
|
Here's a list of the current Spice using regex triggers: $ grep -irn "triggers query_lc" .
./lib/DDG/Spice/Airlines.pm:21:triggers query_lc => qr/^(\d+)\s*(.*?)(?:[ ]air.*?)?$|^(.*?)(?:[ ]air.*?)?\s*(\d+)$/;
./lib/DDG/Spice/IsItUp.pm:15:triggers query_lc => qr/^((?:is\s|))(?:http:\/\/)?([0-9a-z\-]+(?:\.[0-9a-z\-]+)*?)(?:(\.[a-z]{2,4})|)\s(?:up|down|working)/i;
./lib/DDG/Spice/Lastfm/Album.pm:20:triggers query_lc => qr/^([^\s]+(?:\s+[^\s]+)*)\s+(?:albums?|records?|cds?)\s+(?:by|from)?\s+([^\s]+(?:\s+[^\s]+)*)$/;
./lib/DDG/Spice/Lastfm/ArtistAlbum.pm:20:triggers query_lc => qr/^(?:$synonyms)\s+(?:(?:by|from|of)\s+)?([^\s]+(?:\s+[^\s]+)*)$
./lib/DDG/Spice/Lastfm/ArtistTracks.pm:22:triggers query_lc => qr/^(?:(?:all|the)\s+)?(?:$synonyms)\s+(?:(?:by|from|of)\s+)?([^\s]+(?:\s+[^\s]+)*)$
./lib/DDG/Spice/Lastfm/Song.pm:20:triggers query_lc => qr/ ^
./lib/DDG/Spice/Lastfm/TopTracks.pm:20:triggers query_lc => qr/(?:tops?|popular)\s+(?:10\s)?(?:tracks?|charts?|songs?|musics?)(?:\s+in\s+(?:the\s+)?)?(.*)/;
./lib/DDG/Spice/OpenSNP.pm:18:triggers query_lc => qr/(^rs[0-9]+)$/;
./lib/DDG/Spice/RandNums.pm:21:triggers query_lc => qr/^(?:rand|random) (?:numbers?|nums?)(?: (\-?[0-9]+)\s*(?:-|to)?\s*(\-?[0-9]+))?$/;
./lib/DDG/Spice/RedditSubSearch.pm:18:triggers query_lc => qr#^(?:subreddit|/?r/)\s*(\w+)$|^(\w+)\s+subreddit$#i;
./lib/DDG/Spice/Zipcode.pm:23:triggers query_lc => qr/(?:$zip_string|[a-z\d\-\s]{2,15})/; |
Can we remove RandNums, its using |
@killerfish sounds good, go ahead and make a PR to remove it. |
i looked at the rest, 2/3 doable, maybe, but i dont know what would be the threshold for tradeoff, on speed vs. the times its going to trigger (the words are relatively commonly used in queries). |
@killerfish its definitely beneficial to the system if we can reduce the number of IA's using regex triggers. |
LastFM, Reddit and IsItUp can be switched though |
okay so for reddit, something like this wont work with word triggers, and for isitup, if we consider up|down|working|online|status (from regex) as triggers end, we wont be able to acommodate the random amount of question marks put in the query (which we support currently) so, |
ill look into LastFM |
@killerfish good point about reddit, looks like that'll have to stay. The IsItUp rationale sounds like it's actually a bug though, I think we should be sepearting the question marks from the alpha characters that preceed them. That would require some work in the duckduckgo repo if you're interested. For now though, understood, we'll leave it as is. Really appreciate you digging into those to figure out if we can switch them! |
Plugins that use trigger words are significantly more efficient. We should really move over as many "regex" plugins as possible (especially those that have use a specific trigger word) to rather trigger initially on that word and in the handle statement use a regex to disqualify any inappropriate searches.
The text was updated successfully, but these errors were encountered: