-
Notifications
You must be signed in to change notification settings - Fork 288
Add exclude_words parameter to translation methods #1216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
8
commits into
dev
Choose a base branch
from
copilot/exclude-words-in-translation
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+433
−20
Conversation
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
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add functionality to exclude words during translation
Add exclude_words parameter to translation methods
Jan 19, 2026
Member
|
@copilot move test to tests/extra |
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Contributor
Author
Member
|
@copilot There are changes in dev branch to fix the errors occured in Python 3.13. Merge the changes and run the tests again. |
…ilot/exclude-words-in-translation
Contributor
Author
|
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.



What does this changes
Adds optional
exclude_wordsparameter to all translation methods, allowing users to preserve specific words (proper nouns, technical terms, brand names) in their original form during translation.What was wrong
The translation module had no mechanism to exclude specific words from translation. Users needed to preserve certain terms like brand names, technical jargon, or proper nouns but had to manually post-process translations.
How this fixes it
Core Implementation:
_prepare_text_with_exclusions()and_restore_excluded_words()helper functions incore.py<<<PYTHAINLP_EXCLUDE_N>>>) to mark excluded words before translationAPI Changes:
Translate.translate()withexclude_words: list[str] | None = NoneparameterEnThTranslator,ThEnTranslator,ThZhTranslator,ZhThTranslator,ThFrTranslator,Small100TranslatorTesting:
tests/extra/testx_translate_helpers.pywith 12 unit tests covering all edge casestests/extra/testx_translate.pyto verify end-to-end functionalityCompatibility:
Example:
Your checklist for this pull request
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.