Giter Club home page Giter Club logo

Comments (5)

SamueLacombe avatar SamueLacombe commented on July 20, 2024 2

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.

SamueLacombe avatar SamueLacombe commented on July 20, 2024 2

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.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024 1

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.

daniel-jones-deepl avatar daniel-jones-deepl commented on July 20, 2024 1

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.

roland71 avatar roland71 commented on July 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.