Skip to content

Commit

Permalink
[fix] update stop words to support special Chinese chars in search query
Browse files Browse the repository at this point in the history
  • Loading branch information
bojieli committed Aug 23, 2024
1 parent 735560f commit 07e0d0b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/searchcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# "数据分析与实践" -> "数据分析及实践"
# "概率论和数理统计" -> "概率论与数理统计"
def is_chinese_stop_char(c: str) -> bool:
STOP = ["与", "和", "及"]
STOP = ["与", "和", "及", ",", "、", "。", ":", "(", ")", "【", "】"]
return c in STOP


Expand Down
2 changes: 1 addition & 1 deletion app/views/search/sqlcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# from app.utils import print_sqlalchemy_statement


filter = lambda x: re.sub(r"""[~`!@#$%^&*{}\[\]\\:\";'<>,/\+\-\~\(\)><\x00-\x1F\x7F]""", " ", x)
filter = lambda x: re.sub(r"""[~`!@#$%^&*{}\[\]\\:\";'<>,/\+\-\~\(\)><,、。:【】()?“”「」·\x00-\x1F\x7F]""", " ", x)


def init() -> None:
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/sqllike.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import re


filter = lambda x: re.sub(r'''[~`!@#$%^&*{}[]|\\:";'<>?,./]''', ' ', x)
filter = lambda x: re.sub(r'''[~`!@#$%^&*{}[]|\\:";'<>?,./,、。:【】()?“”「」·]''', ' ', x)


def init() -> None:
Expand Down
4 changes: 4 additions & 0 deletions tests/import_courses_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from app.models import *
from datetime import datetime


def parse_file(filename):
data = []
with open(filename) as f:
Expand Down Expand Up @@ -250,6 +251,9 @@ def load_courses(insert=True):
course_class.term = term
course_class.cno = class_code

# update course search cache
CourseSearchCache.update(course, commit=False)

print('load complete, committing changes to database')
db.session.commit()
print('%d new teachers loaded' % new_teacher_count)
Expand Down

0 comments on commit 07e0d0b

Please sign in to comment.