Comments (5)
Hello,
I believe your issue is that are providing an Int instead of a string:
Here is my request and it's working. I believe you just have to replace 'ignore' by 'x'
translation = client.translate_text(df['SourceTokenized'].tolist(), target_lang=targetLangDeeplCode, tag_handling='html', ignore_tags='ignore', split_sentences="0", preserve_formatting="1", formality=formality)
from deepl-python.
I believe it depend on your argument: tag_handling
if tag_handling='html' then you need opening and closing.
if tag_handling='xml' then it's just a tag.
from deepl-python.
Hi @roland71, yes @SamueLacombe is right (thank you Samuel!)
The ignore_tags
argument expects either a string (..., ignore_tags='x', ...
) or list of strings (..., ignore_tags=['x', 'another_tag_to_ignore'], ...
).
from deepl-python.
Hi @roland71, apologies that this reply was delayed.
The ignore_tags
parameter is only used if the tag_handling
parameter is set to 'xml'
. If instead tag_handling
is set to 'html'
, then the ignore_tags
parameter is not used and instead DeepL uses predefined tags that suit HTML. However, we do provide a method to ignore HTML tags if necessary, explained here in our documentation.
In @SamueLacombe's example code above, as tag_handling
is set to 'html'
, the ignore_tags
parameter will be ignored. Sorry for the confusion.
Here is a corrected example using XML:
text = "This will be translated.<x>This will not be translated.</x>"
result = translator.translate_text(text, target_lang="de", tag_handling="xml", ignore_tags="x")
print(result.text) # Dies wird übersetzt werden.<x>This will not be translated.</x>
Regarding opening & closing tags, for best results you should ensure you match opening tags with closing tags. We do use some heuristics to try to fix invalid XML/HTML, but the results may be unpredictable.
from deepl-python.
@daniel-jones-deepl
but this only works if an opening tag is followed by a closing tag - right? if, for example, the string that is not to be translated is marked with an opening tag at the beginning and at the end, then this string will still be translated.
from deepl-python.
Related Issues (20)
- [Bug] DeepL Write adds sentences describing chosen style
- DeepL documentation states ZH is supported as target for translate_docs but on execution it errors HOT 2
- translate_document_from_filepath fails to recognise XML files HOT 1
- Error: Bad request, message: Document is empty HOT 4
- [Feature Request] Make auto-retry toggleable HOT 3
- can't use my auth key, and can't sign up to the API plan for free trial HOT 4
- preserve_formatting missing in translate_document() function HOT 5
- In the translation result, the "left" quotation mark is missing. HOT 1
- Convenient request max retries setup HOT 4
- Encoding problem when translating to french. HOT 2
- New feature : customize timeout duration HOT 2
- Glossaries HOT 1
- deepl.Formality.MORE results in untranslated text HOT 1
- Mismatch in the placement of ignore tags and lack of translation HOT 1
- The deepl.Formality is ignored
- Abnormal strings in translation results: ãã£ã£ãç§ã¡ã¡åã HOT 5
- `translate_document()` should `seek(0, 0)` the output file after being done
- Disambiguate homonyms in glossaries / provide alternative translations? HOT 3
- When translating long English fields into Chinese, the last paragraph was lost
- Glossary flexible search
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepl-python.