Update handler.py
Browse files- handler.py +0 -10
handler.py
CHANGED
|
@@ -326,7 +326,6 @@ class UptakeModel:
|
|
| 326 |
class FocusingQuestionModel:
|
| 327 |
def __init__(self, device, tokenizer, input_builder, max_length=128, path=FOCUSING_QUESTION_MODEL):
|
| 328 |
print("Loading models...")
|
| 329 |
-
print("TEST IN FOCUSING QUESTION MODEL")
|
| 330 |
self.device = device
|
| 331 |
self.tokenizer = tokenizer
|
| 332 |
self.input_builder = input_builder
|
|
@@ -373,7 +372,6 @@ def load_math_terms():
|
|
| 373 |
return math_terms, math_terms_dict
|
| 374 |
|
| 375 |
def run_math_density(transcript, uptake_speaker=None):
|
| 376 |
-
print("IN MATH DENSITY")
|
| 377 |
math_terms, math_terms_dict = load_math_terms()
|
| 378 |
sorted_terms = sorted(math_terms, key=len, reverse=True)
|
| 379 |
math_word_cloud = {}
|
|
@@ -384,7 +382,6 @@ def run_math_density(transcript, uptake_speaker=None):
|
|
| 384 |
match_list = []
|
| 385 |
for term in sorted_terms:
|
| 386 |
matches = list(re.finditer(term, text, re.IGNORECASE))
|
| 387 |
-
print("math term matches: ", matches)
|
| 388 |
# Filter out matches that share positions with longer terms
|
| 389 |
matches = [match for match in matches if not any(match.start() in range(existing[0], existing[1]) for existing in matched_positions)]
|
| 390 |
if len(matches) > 0:
|
|
@@ -395,8 +392,6 @@ def run_math_density(transcript, uptake_speaker=None):
|
|
| 395 |
# Update matched positions
|
| 396 |
matched_positions.update((match.start(), match.end()) for match in matches)
|
| 397 |
num_matches += len(matches)
|
| 398 |
-
print("num matches: ", num_matches)
|
| 399 |
-
print("math terms: ", match_list)
|
| 400 |
utt.num_math_terms = num_matches
|
| 401 |
utt.math_terms = match_list
|
| 402 |
dict_list = []
|
|
@@ -425,13 +420,8 @@ class EndpointHandler():
|
|
| 425 |
"""
|
| 426 |
# get inputs
|
| 427 |
utterances = data.pop("inputs", data)
|
| 428 |
-
print("utterances: ", utterances)
|
| 429 |
params = data.pop("parameters", None)
|
| 430 |
|
| 431 |
-
print("EXAMPLES")
|
| 432 |
-
for utt in utterances[:3]:
|
| 433 |
-
print("speaker %s: %s" % (utt["speaker"], utt["text"]))
|
| 434 |
-
|
| 435 |
transcript = Transcript(filename=params.pop("filename", None))
|
| 436 |
for utt in utterances:
|
| 437 |
transcript.add_utterance(Utterance(**utt))
|
|
|
|
| 326 |
class FocusingQuestionModel:
|
| 327 |
def __init__(self, device, tokenizer, input_builder, max_length=128, path=FOCUSING_QUESTION_MODEL):
|
| 328 |
print("Loading models...")
|
|
|
|
| 329 |
self.device = device
|
| 330 |
self.tokenizer = tokenizer
|
| 331 |
self.input_builder = input_builder
|
|
|
|
| 372 |
return math_terms, math_terms_dict
|
| 373 |
|
| 374 |
def run_math_density(transcript, uptake_speaker=None):
|
|
|
|
| 375 |
math_terms, math_terms_dict = load_math_terms()
|
| 376 |
sorted_terms = sorted(math_terms, key=len, reverse=True)
|
| 377 |
math_word_cloud = {}
|
|
|
|
| 382 |
match_list = []
|
| 383 |
for term in sorted_terms:
|
| 384 |
matches = list(re.finditer(term, text, re.IGNORECASE))
|
|
|
|
| 385 |
# Filter out matches that share positions with longer terms
|
| 386 |
matches = [match for match in matches if not any(match.start() in range(existing[0], existing[1]) for existing in matched_positions)]
|
| 387 |
if len(matches) > 0:
|
|
|
|
| 392 |
# Update matched positions
|
| 393 |
matched_positions.update((match.start(), match.end()) for match in matches)
|
| 394 |
num_matches += len(matches)
|
|
|
|
|
|
|
| 395 |
utt.num_math_terms = num_matches
|
| 396 |
utt.math_terms = match_list
|
| 397 |
dict_list = []
|
|
|
|
| 420 |
"""
|
| 421 |
# get inputs
|
| 422 |
utterances = data.pop("inputs", data)
|
|
|
|
| 423 |
params = data.pop("parameters", None)
|
| 424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
transcript = Transcript(filename=params.pop("filename", None))
|
| 426 |
for utt in utterances:
|
| 427 |
transcript.add_utterance(Utterance(**utt))
|