fix list of matched words
Browse files- handler.py +9 -8
handler.py
CHANGED
|
@@ -376,13 +376,14 @@ class FocusingQuestionModel:
|
|
| 376 |
def load_math_terms():
|
| 377 |
math_regexes = []
|
| 378 |
math_terms_dict = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
for term in MATH_WORDS:
|
| 380 |
-
if term in MATH_PREFIXES:
|
| 381 |
-
math_terms_dict[rf"\b{term}(s|es|d|ed)?\b"] = term
|
| 382 |
-
math_regexes.append(rf"\b{term}(s|es|d|ed)?\b")
|
| 383 |
-
else:
|
| 384 |
-
math_regexes.append(rf"\b{term}\b")
|
| 385 |
math_terms_dict[rf"\b{term}\b"] = term
|
|
|
|
| 386 |
return math_regexes, math_terms_dict
|
| 387 |
|
| 388 |
def run_math_density(transcript):
|
|
@@ -409,9 +410,9 @@ def run_math_density(transcript):
|
|
| 409 |
if math_terms_dict[regex] not in student_math_word_cloud:
|
| 410 |
student_math_word_cloud[math_terms_dict[regex]] = 0
|
| 411 |
student_math_word_cloud[math_terms_dict[regex]] += len(matches)
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
num_matches += len(matches)
|
| 416 |
# print("match group list: ", [match.group(0) for match in matches])
|
| 417 |
utt.num_math_terms = num_matches
|
|
|
|
| 376 |
def load_math_terms():
|
| 377 |
math_regexes = []
|
| 378 |
math_terms_dict = {}
|
| 379 |
+
for term in MATH_PREFIXES:
|
| 380 |
+
math_terms_dict[rf"\b{term}(s|es|d|ed)?\b"] = term
|
| 381 |
+
math_regexes.append(rf"\b{term}(s|es|d|ed)?\b")
|
| 382 |
+
|
| 383 |
for term in MATH_WORDS:
|
| 384 |
+
if not term in MATH_PREFIXES:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
math_terms_dict[rf"\b{term}\b"] = term
|
| 386 |
+
math_regexes.append(rf"\b{term}\b")
|
| 387 |
return math_regexes, math_terms_dict
|
| 388 |
|
| 389 |
def run_math_density(transcript):
|
|
|
|
| 410 |
if math_terms_dict[regex] not in student_math_word_cloud:
|
| 411 |
student_math_word_cloud[math_terms_dict[regex]] = 0
|
| 412 |
student_math_word_cloud[math_terms_dict[regex]] += len(matches)
|
| 413 |
+
for match in matches:
|
| 414 |
+
match_list.append(match.group())
|
| 415 |
+
matched_positions.add((match.start(), match.end()))
|
| 416 |
num_matches += len(matches)
|
| 417 |
# print("match group list: ", [match.group(0) for match in matches])
|
| 418 |
utt.num_math_terms = num_matches
|