-
-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Most of the search terms are not bold in Chinese results #904
Comments
I managed to duplicate this issue on my local and other public instances of Whoogle. I think the problem stems from the regex expression on this line: whoogle-search/app/utils/results.py Line 74 in ccf9f06
Basically what this regex does is it looks for words matching the query, but only if the words stand on their own or there are no other characters before or after it (other than whitespaces). Then, if it found matches, the function will modify those matches with bold text. This is why the characters I think a simple fix would be removing the Comparison with the search result from a public instance with the original regex expression: The implication of this change would be, of course, modifying other words/queries to bold even if they are not standing on their own. For example: with the query I would like your opinion, @benbusby, on this subject. if you agree with this modification, I can push it and open a PR. What do you think? |
@ahmad-alkadri I think the best approach would be to look up the user's configured language and use a separate regex command if that language is part of predefined list of languages (Chinese, Japanese, etc) that should ignore whitespace on either side of the search term (your proposed solution). Otherwise it should continue to use the existing regex. I'm not a language expert by any stretch, but at least with English searches, I don't think the expected behavior would be to bold every search term on the result page regardless of where it appears (i.e. a search containing "a" or "the" would bold a lot of terms that the user probably wouldn't care about). The way around this would be to support separate, language-dependent behaviors. |
Thank you for your reply @benbusby and yes I agree with you on this part:
On the other hand, taking into account merely the user's configured language might not be enough I think. There could be certain scenarios where the user's using English as their configured language but the query isn't. Example: I sometimes searched for things like On that page, as you see, if we want to modify the instances of the queries to bold we need to apply the normal regex and the one that ignores the whitespace. Ideally, the app should detect whether each word on the result page contains Chinese characters or not, probably by using some kind of Unicode detection. The app should then implement the normal regex for the words that do not contain Chinese characters (thus, not ignoring whitespace) while for the words that contain Chinese characters, it would use the regex that ignores the whitespace. What do you think? |
That sounds great. Rather than searching the result page though, you could actually just check if |
@benbusby completely agree with this approach of yours. I'll try to implement this and push for a PR ASAP. I'll tag you once it's done. Thanks! |
Describe the bug
Most of the search terms are not bold in Chinese results.
Whoogle results:
![Screenshot 2022-12-11 at 6 43 14 PM](https://user-images.githubusercontent.com/33184148/206899969-b2d72332-7eee-44ca-88ec-b126492d361e.png)
Google results for reference:
![Screenshot 2022-12-11 at 6 43 21 PM](https://user-images.githubusercontent.com/33184148/206899990-c2edcc1f-399a-4624-8e94-a3fe589db406.png)
To Reproduce
Search "新聞" or any other term in Chinese.
Deployment Method
Version of Whoogle Search
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: