Upgrade torch, replace torchtext with fasttext, add docstrings, fix bugs#6
Open
Copilot wants to merge 2 commits into
Open
Upgrade torch, replace torchtext with fasttext, add docstrings, fix bugs#6Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…rings, fix bugs, pythonic improvements Agent-Logs-Url: https://github.com/AndyTheFactory/RO-Diacritics/sessions/42b8a0f4-b9a9-4152-8b7f-13083dd68e9b Co-authored-by: AndyTheFactory <863810+AndyTheFactory@users.noreply.github.com>
…nizer, rename lines to sentence_spans Agent-Logs-Url: https://github.com/AndyTheFactory/RO-Diacritics/sessions/42b8a0f4-b9a9-4152-8b7f-13083dd68e9b Co-authored-by: AndyTheFactory <863810+AndyTheFactory@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
AndyTheFactory
April 24, 2026 11:23
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drops the
torchtextdependency (deprecated/unmaintained) and replaces it with directfasttext-wheel. Upgrades totorch>=2.0. Adds docstrings throughout and fixes several bugs.Dependency changes
torchtext→fasttext-wheelininstall_requirestorch→torch>=2.0torchtext → fasttext replacement (
diacritics_dataset.py)Old approach iterated over the entire fasttext vocabulary and averaged vectors for diacritics variants. New approach uses
ft.get_word_vector(word)directly per vocab token — simpler, supports OOV via subword composition:Bug fixes
diacritics_inference.py:if device == "cpu"was alwaysFalse(comparingtorch.devicetostr) — GPU warning never fired. Fixed todevice.type == "cpu".diacritics_inference.py: Added explicitweights_only=Falsetotorch.load(checkpoint contains pickled Python objects; omitting this breaks on future PyTorch defaults).diacritics_dataset.py: Unclosed file handle inload_textspickle branch replaced with context manager.Pythonic / optimizations
diacritics_utils.py: Regex patterns pre-compiled at module level (previously recompiled on every call).diacritics_dataset.py:PunktSentenceTokenizerinstantiated once asself._sent_tokenizer;__iter__usesyield from; removed unusedtext_plainvariable.diacritics_inference.py: Extracted inline anonymousDS(IterableDataset)class to module-level_TensorListDataset;.get()for dict access.Docstrings
Added module, class, and method docstrings to all five source files.