Skip to content

Commit 3d0a47a

Browse files
committed
added whitespaces to trans table
1 parent 935915d commit 3d0a47a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/criteria/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,18 @@ def get_proportional_result(value: float,
6363

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 = []
6872
# добавлена предобработка слов - перевод в нижний регистр, очистка от пунктуации
6973
audio_slide_words = [
70-
recognized_word.word.value.strip().lower().translate(str.maketrans('', '', string.punctuation))
74+
recognized_word.word.value.lower().translate(translation_table)
7175
for recognized_word in audio_slide.recognized_words
7276
]
77+
7378
for i in range(len(audio_slide_words)):
7479
for filler in fillers:
7580
filler_split = filler.split()

0 commit comments

Comments
 (0)