Skip to content
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

fix: Remove full stops and commas at the end of queries #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ordia/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ def show_search():
or search string and `language` as the ISO language code.

"""
query = request.args.get('q', '').strip()
# Remove end punctuation
# For full stop see https://query.wikidata.org/#%23%20Lexemes%20in%20English%20that%20match%20an%20expression%0ASELECT%20%3FlexemeId%20%3Flemma%20WHERE%20%7B%0A%20%20%3FlexemeId%20dct%3Alanguage%20wd%3AQ1860%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3Alemma%20%3Flemma.%0A%20%20FILTER%20%28regex%28%3Flemma%2C%20%27.%2a%5C%5C.%24%27%29%29%0A%7D
# For comma see https://query.wikidata.org/#%23%20Lexemes%20in%20English%20that%20match%20an%20expression%0ASELECT%20%3FlexemeId%20%3Flemma%20WHERE%20%7B%0A%20%20%3FlexemeId%20dct%3Alanguage%20wd%3AQ1860%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3Alemma%20%3Flemma.%0A%20%20FILTER%20%28regex%28%3Flemma%2C%20%27.%2a%2C%24%27%29%29%0A%7D
# We don't remove question marks because they are used in some idioms like this https://www.wikidata.org/wiki/Lexeme:L1221121
query = request.args.get('q', '').strip().replace(".", "").replace(",", "")
language = request.args.get('language', '').strip()

if len(query) == 0:
Expand Down