GNOME Bugzilla – Bug 732344
search-provider: Make "brno weather" work
Last modified: 2021-07-05 10:59:36 UTC
The idea is to make it work like Google. You type "$NAME_OF_PLACE weather" in gnome-shell and you should get the weather information. Ofcourse, just typing "brno" also works, but then I get other crap in the search results like PDFs of bus or aeroplane tickets from gnome-documents, nautilus, etc. and that pushes the weather information somewhere beyond the first page making it less useful than just using Google. What I am suggesting is that the gnome-weather search-provider should always match keywords like 'temperature' and 'weather'. In most cases this will be good enough to just show the weather information and get rid of all the crap. We can do this for almost all the search providers out there. Say 'documents' for gnome-documents, 'time' for gnome-clocks, etc.. We can go one step further and have all the search providers register these keywords to gnome-shell, which can then use them to sort the search results more cleverly. So even if 'brno weather' returns some other hits, it can put the results from gnome-weather at the top.
Created attachment 279428 [details] [review] search-provider: Fix typo
Created attachment 279429 [details] [review] search-provider: Support search keywords
Created attachment 279430 [details] [review] search-provider: Optimize use of normalizeCasefoldandUnaccent
Review of attachment 279428 [details] [review]: Ugh, definitely
Review of attachment 279429 [details] [review]: ::: src/service/searchProvider.js @@ +53,3 @@ + _isKeyword: function(str) { + if (Util.normalizeCasefoldAndUnaccent('forecast').indexOf(str) >= 0 || The result of Util.normalizeCasefoldAndUnaccent on a lowercase ASCII string is the string itself...
Review of attachment 279430 [details] [review]: Mh, good idea! We should probably keep the normalized-casefolded-unaccented strings for the locations in the model too. Besides, libgweather has get_sort_name() which almost does what we want (and we should probably extend to the usual normalize-casefold-unaccent dance). Not a blocker for this patch, though, just suggestions for the future.
Review of attachment 279430 [details] [review]: g_str_match_string() instead of normalizeCasefoldAndUnaccent?
Review of attachment 279428 [details] [review]: Mention what the typo is in the commit message?
(In reply to comment #7) > Review of attachment 279430 [details] [review]: > > g_str_match_string() instead of normalizeCasefoldAndUnaccent? Yes, I intend to do that too. I remember seeing this normalizeCasefoldAndUnaccent in a few other modules too, so I will replace all of them one by one in subsequent patches.
Created attachment 279460 [details] [review] search-provider: Fix typo Try to describe the typo that we are trying to fix.
Created attachment 279504 [details] [review] search-provider: Support search keywords
Review of attachment 279504 [details] [review]: ::: src/service/searchProvider.js @@ -52,2 +52,4 @@ }, + _isKeyword: function(str) { + if ('forecast'.indexOf(str) >= 0 || These keywords need to be translated. It is probably better to put them in a single comma separated string, since different languages may have a different number of terms and synonyms they want to match
The patch in this bug has bit-rotten a bit since gnome-weather underwent a redesign. I filed bug 741307 for another way to achieve this before I pick this up again.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/gnome-weather/-/issues/ Thank you for your understanding and your help.