luga
v0.2.7

ルーガは言語のスワヒリ語です。 FastTextは、燃えるような言語検出ツールを提供します。嘆かわしいことに、FastTextのAPIは美しさのないものであり、ドキュメントは少しあいまいです。また、モデルを手動でダウンロードしてロードする必要があることもファンキーです。
ルーガが登場する場所です。不必要な手順を抽象化し、テキスト言語の検出という正確に1つのことを行うことができます。
じっと立ってください。黙ってください - ミンナ・サンドバーグによるインド・ヨーロッパとウラリック言語の関係。

python -m pip install -U luga from luga import language
print ( language ( "the world ended yesterday" ))
# Language(name='en', score=0.98)テキストのリストを使用すると、たとえばデータフレームで使用できるフィルタリングパイプライン用のマスクを作成できます。
from luga import language
import pandas as pd
examples = [ "Jeg har ikke en rød reje" , "Det blæser en halv pelican" , "We are not robots yet" ]
languages ( texts = examples , only_language = True , to_array = True ) == "en"
# output
# array([False, False, True])
dataf = pd . DataFrame ({ "text" : examples })
dataf . loc [ lambda d : languages ( texts = d [ "text" ]. to_list (), only_language = True , to_array = True ) == "en" ]
# output
# 2 We are not robots yet
# Name: text, dtype: objectモデルをダウンロードします
wget https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin -O /tmp/lid.176.binロードと使用
import fasttext
PATH_TO_MODEL = '/tmp/lid.176.bin'
fmodel = fasttext . load_model ( PATH_TO_MODEL )
fmodel . predict ([ "the world has ended yesterday" ])
# ([['__label__en']], [array([0.98046654], dtype=float32)])poetry run pre-commit install # assumes git push is completed
git tag -l # lists tags
git tag v * . * . * # Major.Minor.Fix
git push origin tag v * . * . *
# to delete tag:
git tag -d v * . * . * && git push origin tag -d v * . * . *
# change project_toml and __init__.py to reflect new version artifacts.py行111キャストを修正して、問題を引き起こす[str]リスト[str]