Skip to content

Commit 82556d8

Browse files
Merge pull request #413 from OSLL/393_FILLERS_RATIO_BUG
393 fillers ratio bug
2 parents 26b426a + 3d0a47a commit 82556d8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/criteria/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from app.root_logger import get_root_logger
22
import math
33
import traceback
4+
import string # to remove punctuation
45
from typing import Optional, Callable
56

67
from app.audio import Audio
@@ -60,13 +61,20 @@ def get_proportional_result(value: float,
6061
else:
6162
return f(upper_bound / value)
6263

63-
6464
def get_fillers(fillers: list, audio: Audio) -> list:
6565
found_fillers = []
66+
# пунктуация + пробелы для str.translate
67+
removable = string.punctuation + string.whitespace
68+
translation_table = str.maketrans('', '', removable)
69+
6670
for audio_slide in audio.audio_slides:
6771
found_slide_fillers = []
72+
# добавлена предобработка слов - перевод в нижний регистр, очистка от пунктуации
6873
audio_slide_words = [
69-
recognized_word.word.value for recognized_word in audio_slide.recognized_words]
74+
recognized_word.word.value.lower().translate(translation_table)
75+
for recognized_word in audio_slide.recognized_words
76+
]
77+
7078
for i in range(len(audio_slide_words)):
7179
for filler in fillers:
7280
filler_split = filler.split()

0 commit comments

Comments
 (0)