【问题标题】:How to detect the language of a text (.csv) by its title using Python? [closed]如何使用 Python 通过标题检测文本 (.csv) 的语言? [关闭]
【发布时间】:2020-09-04 09:44:59
【问题描述】:

对于以研究为目的的工作,我应该:

  1. 读取 .csv 文件
  2. 通过标题检测文本的语言
  3. 通过一些关键字识别文本的参数 前任。脑叶切开术 --> 大脑

我正在尝试使用 Python 及其库 NLTK 来完成第二点和第三点, 如果你做过类似的事情,能给我一些建议吗?

提前谢谢你!

【问题讨论】:

标签: python text nlp nltk


【解决方案1】:

它不是万能的,但您可以尝试多种语言识别工具。

使用langid.py

最流行和最容易使用的一种,是langid.pyhttps://github.com/saffsd/langid.py

要安装:python -m pip install -U langid

>>> import langid

>>> text = "Hallo, wie gehts?"
>>> lang, log_prob = langid.classify(text)
>>> print(lang)
de

使用pyCLD2

pycld2chromium-compact-language-detector 的包装,请参阅https://github.com/aboSamoor/pycld2

安装:python -m pip install -U pycld2

>>> import pycld2 as cld2

>>> text = "Hallo, wie gehts?"

>>> isReliable, textBytesFound, details = cld2.detect(text)
>>> lang = details[0][1]
>>> print(lang)
de

使用cld3

安装:python -m pip install -U pycld3

>>> import cld3

>>> text = "Hallo, wie gehts?"

>>> prediction = cld3.get_language(text)
>>> print(prediction.language)
de

这是来自https://arxiv.org/pdf/1910.06748.pdf 的近期摘要(2019 年)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-19
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 1970-01-01
    • 2011-01-19
    • 1970-01-01
    相关资源
    最近更新 更多