I am trying to detect the language of the text that may consist of an unknown number of languages. The following code gives me different languages as answer
NOTE: I reduced the review becuase it was giving the error during post "" are not allowed
print(detect(???? ????? ?????? ??????? ???? ??? ????? ??????))
print(detect(的马来西亚))
print(detect(Vi havde 2 perfekte dage i Legoland Malaysia))
print(detect(Wij hebben alleen gekozen voor het waterpark maar daar ben je vrijs snel doorheen. Super leuke glijbanen en overal ruimte om te zitten en te liggen. Misschien volgende keer een gecombineerd ticket kopen met ook toegang tot waterpark))
print(detect(This is a park thats just ok, nothing great to write home about. There is barely any shade, the weather is always really hot so they need to take this into consideration. The atractions are just meh. I would only go if you are a fan of lego, for the sculptures are nice.))
Here is the output
ar
zh-cn
da
nl
en
But using the following loop, all reviews give me 'en' as result
from langdetect import detect
import pandas as pd
df = pd.read_excel('data.xls') #
lang = []
for r in df.Review:
lang = detect(r)
df['Languagereveiw'] = lang
the output is 'en' for all five rows.
Need guidance that where is the missing chain?
Here is the sample data
Secondly, How can I get the complete name of languages i.e. English for 'en'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…