🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

textlangid

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textlangid

Detects the language of text

0.0.7
PyPI
Maintainers
1

Text language identifier

This package serves as a wrapper for the most performant text language identifier.

Currently it wraps fasttext (NLLB version).

Before detecting the language, it preprocesses the text to improve results.

Usage

%pip install textlangid

import textlangid

lang = textlangid.detect("This is some text.")

top_languages = TextLanguageIdentifier.detect(text, top_k=3)

top_languages_with_confidence = TextLanguageIdentifier.detect(
        text, top_k=3, return_confidence=True
    )

top_languages_with_threshold = TextLanguageIdentifier.detect(
        text, top_k=3, return_confidence=True, confidence_threshold=0.2
    )

The language is returned in a FLORES-200 language code. Full list available here.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts