Skip to content

Comments

Используется rumorph для ёфикации#16

Open
andreysm wants to merge 1 commit intoDen4ikAI:mainfrom
andreysm:dev/use-rumorph
Open

Используется rumorph для ёфикации#16
andreysm wants to merge 1 commit intoDen4ikAI:mainfrom
andreysm:dev/use-rumorph

Conversation

@andreysm
Copy link

No description provided.

self,
omograph_model_size="turbo2",
use_dictionary=False,
use_dictionary=True,
Copy link
Author

Choose a reason for hiding this comment

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

У use_dictionary было какое-то странное поведение, так что я его немного переделал.
Если так нехорошо, то можно как-то по-другому сделать.
Но надо как-то определить, что этот параметр в итоге делает.

self.workdir = workdir
else:
self.workdir = str(pathlib.Path(__file__).resolve().parent)
self.module_path = str(pathlib.Path(__file__).resolve().parent)
Copy link
Author

Choose a reason for hiding this comment

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

Эти две строчки переехали в init


if not os.path.exists(join_path(self.workdir, "nn", "nn_rumorph")):
assert False, "Missing nn/nn_rumorph"

Copy link
Author

Choose a reason for hiding this comment

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

nn/nn_rumorph по идее должен скачиваться с hugging_face?
Надо его туда выложить и дописать здесь код, чтобы он скачивался.

self.yo_homograph_model = YoHomographModel()
self.fs = HfFileSystem()
self.normalize = re.compile(r"[^a-zA-Z0-9\sа-яА-ЯёЁ—.,!?:;""''(){}\[\]«»„“”-]")
self.normalize = re.compile(r"[^a-zA-Z0-9\sа-яА-ЯёЁ—.,!?:;\"\"''(){}\[\]«»„“”\-\+]")
Copy link
Author

Choose a reason for hiding this comment

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

Здесь был небольшой косяк с кавычками (реально глючило на них).

И ещё разрешил +, чтобы можно было обрабатывать тексты, в которых уже стоят ударения в каких-то словах.


self.yo_rules = json.load(
gzip.open(join_path(self.workdir, "dictionary", "yo_rules.json.gz"))
)
Copy link
Author

Choose a reason for hiding this comment

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

yo_rules тоже надо на hugging_face выложить

text = text.replace(" " + char, char)
text = re.sub(r'\s*-\s*', '-', text)
text = re.sub(r'\s+([!\"#$%&\'()*,\./:;<=>?@\[\\\]^_`{|}])', r' \1', text)
text = re.sub(r'([!\"#$%&\'()*,\./:;<=>?@\[\\\]^_`{|}])\s+', r'\1 ', text)
Copy link
Author

Choose a reason for hiding this comment

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

Тут тоже как-то странно работало, так что регулярки как раз для такого хорошо подходят.

@staticmethod
def split_by_words(string):
string = string.replace(" - ",' ~ ')
string = re.sub(r'(^| )- ', r'\1~ ', string)
Copy link
Author

Choose a reason for hiding this comment

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

Тут был косяк, что "-" не заменялся в начале строки. Особенно часто встречалось в диалогах.

@NickZaitsev
Copy link

А какие результаты использования RuMorph? Он позволяет точнее ставить ё, или разница не очень большая?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants