Replies: 1 comment
-
|
Your error has nothing to do with pandas. You are trying to pass a list of language iso code strings to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Could you please provide noob-proof instructions for how to use lingua to detect and language(s) used in a text column of a dataframe?
I installed it with
pip install lingua-language-detector, which seemed to work just fine.But when I then tried
import os
import pandas as pd
from lingua import LanguageDetectorBuilder
languages = ['en', 'fr', 'de', 'es']
detector_builder = LanguageDetectorBuilder.from_languages(*languages)
LanguageDetectorBuilder object
def detect_language(text):
detector = detector_builder.build()
return detector.detect(text).language.name
df['language'] = df['abstract'].apply(detect_language)
it threw me an error:
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_58052\2805698229.py in
1 import os
2 import pandas as pd
----> 3 from lingua import LanguageDetectorBuilder
4
5 # Initialize the LanguageDetectorBuilder object with the languages to be supported
ImportError: cannot import name 'LanguageDetectorBuilder' from 'lingua' (c:\ProgramData\Anaconda3\lib\site-packages\lingua_init_.py)
Beta Was this translation helpful? Give feedback.
All reactions