previous examples work flawlessly:anonymizer = PresidioReversibleAnonymizer(    analyzed_fields=["PERSON"],    languages_config=nlp_config,)print(    anonymizer.anonymize("Me llamo Sof√≠a", language="es"))  # "My name is Sof√≠a" in Spanishprint(anonymizer.anonymize("Yo soy Sof√≠a", language="es"))  # "I am Sof√≠a" in Spanish    Me llamo Christopher Smith    Yo soy Joseph JenkinsBy default, the language indicated first in the configuration will be used when anonymising text (in this case English):print(anonymizer.anonymize("My name is John"))    My name is Shawna BennettUsage with other frameworks‚ÄãLanguage detection‚ÄãOne of the drawbacks of the presented approach is that we have to pass the language of the input text directly. However, there is a remedy for that - language detection libraries.We recommend using one of the following frameworks:fasttext (recommended)langdetectFrom our exprience fasttext performs a bit better, but you should verify it on your use case.# Install necessary packages# ! pip install fasttext langdetectlangdetect‚Äãimport langdetectfrom langchain.schema import runnabledef detect_language(text: str) -> dict:    language = langdetect.detect(text)    print(language)    return {"text": text, "language": language}chain = runnable.RunnableLambda(detect_language) | (    lambda x: anonymizer.anonymize(x["text"], language=x["language"]))chain.invoke("Me llamo Sof√≠a")    es    'Me llamo Michael Perez III'chain.invoke("My name is John Doe")    en    'My name is Ronald Bennett'fasttext‚ÄãYou need to download the fasttext model first from https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.ftzimport fasttextmodel = fasttext.load_model("lid.176.ftz")def detect_language(text: str) -> dict:    language = model.predict(text)[0][0].replace("__label__", "")    print(language)    return {"text": text, "language": language}chain = runnable.RunnableLambda(detect_language) | (    lambda x: anonymizer.anonymize(x["text"], language=x["language"]))
Open In Colab
Open In Colab ->: previous examples work flawlessly:anonymizer = PresidioReversibleAnonymizer(    analyzed_fields=["PERSON"],    languages_config=nlp_config,)print(    anonymizer.anonymize("Me llamo Sof√≠a", language="es"))  # "My name is Sof√≠a" in Spanishprint(anonymizer.anonymize("Yo soy Sof√≠a", language="es"))  # "I am Sof√≠a" in Spanish    Me llamo Christopher Smith    Yo soy Joseph JenkinsBy default, the language indicated first in the configuration will be used when anonymising text (in this case English):print(anonymizer.anonymize("My name is John"))    My name is Shawna BennettUsage with other frameworks‚ÄãLanguage detection‚ÄãOne of the drawbacks of the presented approach is that we have to pass the language of the input text directly. However, there is a remedy for that - language detection libraries.We recommend using one of the following frameworks:fasttext (recommended)langdetectFrom our exprience fasttext performs a bit better, but you should verify it on your use case.# Install necessary packages# ! pip install fasttext langdetectlangdetect‚Äãimport langdetectfrom langchain.schema import runnabledef detect_language(text: str) -> dict:    language = langdetect.detect(text)    print(language)    return {"text": text, "language": language}chain = runnable.RunnableLambda(detect_language) | (    lambda x: anonymizer.anonymize(x["text"], language=x["language"]))chain.invoke("Me llamo Sof√≠a")    es    'Me llamo Michael Perez III'chain.invoke("My name is John Doe")    en    'My name is Ronald Bennett'fasttext‚ÄãYou need to download the fasttext model first from https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.ftzimport fasttextmodel = fasttext.load_model("lid.176.ftz")def detect_language(text: str) -> dict:    language = model.predict(text)[0][0].replace("__label__", "")    print(language)    return {"text": text, "language": language}chain = runnable.RunnableLambda(detect_language) | (    lambda x: anonymizer.anonymize(x["text"], language=x["language"]))