Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Laboratory work #4, Tatiana Zheleznova - 22FPL2 #181

Closed
wants to merge 105 commits into from
Closed
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
2ba3567
Добавила "Привет, мир!"
tanya-iron Sep 14, 2023
5873a93
Merge branch 'fipl-hse:main' into main
artyomtugaryov Sep 15, 2023
6722110
Merge branch 'fipl-hse:main' into main
artyomtugaryov Sep 21, 2023
72ac755
Добавила задание на оценку 4(Шаг 1)
tanya-iron Sep 21, 2023
4cd6517
Merge remote-tracking branch 'origin/main'
tanya-iron Sep 21, 2023
5bf4ccc
Добавила задание на оценку 4(Шаг 1)
tanya-iron Sep 21, 2023
b252215
Добавила задание на оценку 4(Шаг 1)
tanya-iron Sep 21, 2023
e4d37a7
Добавила задание на оценку 4(Шаг 1)
tanya-iron Sep 21, 2023
5b38cd1
Добавила задание на оценку 6.
tanya-iron Sep 27, 2023
c6ca7e8
Добавила шаг 4 и небольшие правки.
tanya-iron Sep 27, 2023
7e3500a
Добавила шаг 4 и небольшие правки.(починенные)
tanya-iron Sep 27, 2023
545386c
Merge branch 'fipl-hse:main' into main
artyomtugaryov Sep 28, 2023
42cfffb
Коммит ради изменений seminars
tanya-iron Sep 29, 2023
aa1bc97
Коммит ради изменений seminars
tanya-iron Sep 29, 2023
e89b14c
Добавила задание на 8 и исправила замеченное преподавателем.
tanya-iron Sep 30, 2023
a38e725
Добавила задание на 8 и исправила замеченное преподавателем.
tanya-iron Sep 30, 2023
8e98a65
Добавила задание на 8 и исправила замеченное преподавателем, а также …
tanya-iron Sep 30, 2023
9aba643
Fixing mypy
tanya-iron Sep 30, 2023
9cc3105
Fixing mypy more
tanya-iron Sep 30, 2023
08fe22b
Добавила задание на 8 и исправила замеченное преподавателем, а также …
tanya-iron Oct 1, 2023
eb8d78d
Добавила задание на 8 и исправила замеченное преподавателем, а также …
tanya-iron Oct 1, 2023
92ac870
Добавила задание на 8 и исправила замеченное преподавателем, а также …
tanya-iron Oct 1, 2023
758cc61
Добавила задание на 8 и исправила замеченное преподавателем, а также …
tanya-iron Oct 1, 2023
7a1ece8
Добавила задание на 8 и исправила замеченное преподавателем, а также …
tanya-iron Oct 1, 2023
b4e2dd3
Добавила задание на 8 и пытаюсь исправить ошибку start.py
tanya-iron Oct 1, 2023
17e826c
Добавила задание на 8 и исправила все ошибки.
tanya-iron Oct 1, 2023
b7aabc2
Добавила задание на 8 и исправила все ошибки. Изменения code style
tanya-iron Oct 1, 2023
7b16ea3
Добавила задание на 8 и исправила все ошибки. Изменения code style
tanya-iron Oct 1, 2023
815141d
Добавила задание на 10.
tanya-iron Oct 3, 2023
b29f114
Добавила задание на 10. Исправила 1 codestyle
tanya-iron Oct 3, 2023
b2894b8
Добавила задание на 10. Исправила 1 codestyle
tanya-iron Oct 3, 2023
0113f94
Добавила задание на 10. Исправила 1 codestyle
tanya-iron Oct 3, 2023
d2c08c6
Добавила задание на 10. Исправила 1 codestyle
tanya-iron Oct 3, 2023
912a7d3
Добавила задание на 10. Исправила 1 codestyle
tanya-iron Oct 3, 2023
d05e2ca
Исправила по комментариям ментора.
tanya-iron Oct 4, 2023
e1f7d55
Исправила по комментариям ментора.
tanya-iron Oct 5, 2023
e44b710
Merge branch 'fipl-hse:main' into main
artyomtugaryov Oct 6, 2023
9feddbf
Merge remote-tracking branch 'upstream/main'
tanya-iron Oct 9, 2023
b1fa5a8
Добавила задание на 4.
tanya-iron Oct 10, 2023
49d8120
Merge remote-tracking branch 'origin/main'
tanya-iron Oct 10, 2023
db57482
Merge remote-tracking branch 'origin/main' into HEAD
artyomtugaryov Oct 11, 2023
9f76368
checkout labs from the origin repository
artyomtugaryov Oct 11, 2023
8e95a86
Merge branch 'fipl-hse:main' into main
artyomtugaryov Oct 13, 2023
ad502e0
Добавила задание на 4.
tanya-iron Oct 13, 2023
3ab90cd
Commit for update
tanya-iron Oct 13, 2023
1dce99b
Merge branch 'fipl-hse:main' into main
artyomtugaryov Oct 19, 2023
d9175fc
Merge branch 'fipl-hse:main' into main
artyomtugaryov Oct 20, 2023
9d5d7e2
merge
tanya-iron Oct 20, 2023
c97972d
Commit for update
tanya-iron Oct 20, 2023
85ca904
Merge branch 'main' of https://github.com/tanya-iron/2023-2-level-labs
tanya-iron Oct 20, 2023
ea58e11
Исравление по комментарием ментора и задание на 6.
tanya-iron Oct 30, 2023
caceee4
Исравление по комментарием ментора и задание на 6.
tanya-iron Oct 30, 2023
89f9304
Задание на 8, которое не работает.
tanya-iron Oct 30, 2023
bc7fccd
Merge branch 'fipl-hse:main' into main
artyomtugaryov Oct 31, 2023
0504bde
Задание на 8, которое работает.
tanya-iron Nov 1, 2023
b70944e
Merge remote-tracking branch 'origin/main'
tanya-iron Nov 1, 2023
d541915
Задание на 8, которое работает.
tanya-iron Nov 1, 2023
58ec43d
Задание на 8, которое работает.
tanya-iron Nov 1, 2023
84be2b9
Коммит 1 лабораторной
tanya-iron Nov 1, 2023
b928797
Коммит импортов
tanya-iron Nov 1, 2023
ab3b48f
Коммит импортов
tanya-iron Nov 2, 2023
09cf847
Изменения для ментора
tanya-iron Nov 2, 2023
fba63e9
Merge remote-tracking branch 'origin/main' into HEAD
artyomtugaryov Nov 3, 2023
d619ff8
checkout labs from the origin repository
artyomtugaryov Nov 3, 2023
97a02a8
checkout labs from the origin repository
artyomtugaryov Nov 3, 2023
0dc2883
Merge branch 'fipl-hse:main' into main
artyomtugaryov Nov 10, 2023
b06bdb6
Задание на 4
tanya-iron Nov 15, 2023
6a29fd7
Задание на 6, которое пока не работает
tanya-iron Nov 15, 2023
cbff581
Merge branch 'fipl-hse:main' into main
artyomtugaryov Nov 17, 2023
1a65d87
Задание на 6, которое пока не работает
tanya-iron Nov 19, 2023
c10daff
Задание на 6, которое пока не работает
tanya-iron Nov 20, 2023
466ccb6
Задание на 6, которое пока не работает. Почему не работает?
tanya-iron Nov 20, 2023
5054a2e
Задание на 6, которое вроде работает
tanya-iron Nov 20, 2023
f6f2e31
Задание на 6, которое вроде работает
tanya-iron Nov 20, 2023
f181d37
Задание на 6, с замечаниями ментора
tanya-iron Nov 22, 2023
bbc3d3b
Задание на 6, с замечаниями ментора
tanya-iron Nov 22, 2023
51b974b
Задание на 8
tanya-iron Nov 22, 2023
ca2eabb
Задание на 8, улучшенное
tanya-iron Nov 22, 2023
b0615f9
Задание на 8, улучшенное
tanya-iron Nov 22, 2023
8169ec4
Задание на 8, улучшенное
tanya-iron Nov 23, 2023
c7a6daa
Задание на 8, улучшенное
tanya-iron Nov 23, 2023
3a5d47d
Задание на 8, улучшенное
tanya-iron Nov 23, 2023
6eb9832
Задание на 8, улучшенное
tanya-iron Nov 23, 2023
48149f2
Задание на 10, господи
tanya-iron Nov 23, 2023
fc9bb16
Задание на 10, господи
tanya-iron Nov 23, 2023
506bf4c
Задание на 10, господи
tanya-iron Nov 23, 2023
411db03
Задание на 10, господи
tanya-iron Nov 23, 2023
3088d64
Задание на 10, господи
tanya-iron Nov 23, 2023
32bcc66
Merge remote-tracking branch 'origin/main' into HEAD
artyomtugaryov Nov 24, 2023
d66832a
checkout labs from the origin repository
artyomtugaryov Nov 24, 2023
a70856a
Unfinished for 6
tanya-iron Nov 29, 2023
f056836
Merge branch 'fipl-hse:main' into main
artyomtugaryov Dec 1, 2023
fbef37d
Merge branch 'fipl-hse:main' into main
artyomtugaryov Dec 4, 2023
c8b1f7e
Merge branch 'fipl-hse:main' into main
tanya-iron Dec 8, 2023
e9b2ed4
Unfinished for 6, commit of mentor's notes
tanya-iron Dec 17, 2023
48036bf
finally 6? will she do more? only time will tell
tanya-iron Dec 17, 2023
2bc8953
imports
tanya-iron Dec 17, 2023
a6e960e
imports
tanya-iron Dec 17, 2023
2a6f6df
imports
tanya-iron Dec 17, 2023
b14b05f
Tasks for 8
tanya-iron Dec 17, 2023
ae5c30d
Tasks for 8
tanya-iron Dec 17, 2023
3fe0586
Tasks for 10!!!!
tanya-iron Dec 17, 2023
f4112e2
Tasks for 10!!!! codestyle
tanya-iron Dec 17, 2023
c838e30
Tasks for 10!!!! codestyle
tanya-iron Dec 17, 2023
b6115cd
ValueError with comments
tanya-iron Dec 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lab_4_fill_words_by_ngrams/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# pylint:disable=too-few-public-methods, too-many-arguments
from lab_3_generate_by_ngrams.main import (BeamSearchTextGenerator, GreedyTextGenerator,
NGramLanguageModel, TextProcessor)
import re


class WordProcessor(TextProcessor):
Expand All @@ -28,6 +29,19 @@ def _tokenize(self, text: str) -> tuple[str, ...]: # type: ignore
Raises:
ValueError: In case of inappropriate type input argument or if input argument is empty.
"""
if not isinstance(text, str) or not text:
return ValueError
new_text = re.sub(r'[!?.]', self._end_of_word_token, text)
clean_text = ''
for symbol in new_text.lower():
if symbol.isalpha or symbol.isspace() or symbol == self._end_of_word_token:
clean_text += symbol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string concatination is a bad way

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, Artyom from the Past

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, both Artyoms

final_text = clean_text.split(' ')
for index, word in enumerate(final_text):
if self._end_of_word_token in word:
word = word[:-len(self._end_of_word_token)]
final_text.insert(index + 1, self._end_of_word_token)
return final_text

def _put(self, element: str) -> None:
"""
Expand All @@ -39,6 +53,10 @@ def _put(self, element: str) -> None:
Raises:
ValueError: In case of inappropriate type input argument or if input argument is empty.
"""
if not isinstance(element, str) or not element:
return ValueError
if element not in self._storage:
self._storage[element] = len(self._storage)

def _postprocess_decoded_text(self, decoded_corpus: tuple[str, ...]) -> str: # type: ignore
"""
Expand All @@ -56,6 +74,10 @@ def _postprocess_decoded_text(self, decoded_corpus: tuple[str, ...]) -> str: #
Raises:
ValueError: In case of inappropriate type input argument or if input argument is empty.
"""
if not isinstance(decoded_corpus, tuple) or not decoded_corpus:
return ValueError
decoded_text = ' '.join(decoded_corpus).replace(self._end_of_word_token, '.').capitalize()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split into 2 lines, please

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

return decoded_text


class TopPGenerator:
Expand All @@ -80,6 +102,9 @@ def __init__(
word_processor (WordProcessor): WordProcessor instance to handle text processing
p_value (float): Collective probability mass threshold
"""
self._word_processor = word_processor
self._language_model = language_model
self._p_value = p_value

def run(self, seq_len: int, prompt: str) -> str: # type: ignore
"""
Expand Down
2 changes: 1 addition & 1 deletion lab_4_fill_words_by_ngrams/target_score.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0
6