Skip to main content

Language Detection Library

Project description

SomeLang

Natural Language Detection Library

SomeLang is a lightweight and decently accurate natural language detection library. It is designed to be fast, python native, with no external dependencies for the main script, and highly customizable with support for whitelists and blacklists.

Installation

pip install somelang

Features

  • Fast Natural Language Detection - Trigrams-based approach for accurate results
  • Default 158+ language whitelist - The default whitelist provides better accuracy on short texts (3-100 characters)
  • Supports 194+ languages - Can detect a wide range of languages in full mode
  • Modern Training Data - Trained on OpenLID-v2 & many other modern datasets
  • Python-native - No external dependencies for main script
  • Customizable - Configurable whitelist/blacklist support

Usage

Basic Detection

from somelang import somelang

# Basic language detection
lang = somelang("Bonjour tout le monde")  # Returns: 'fra'

# Get language name instead of code
lang = somelang("Hello world", verbose=True)  # Returns: 'English'

Command Line

python -m somelang 'text to analyze'

Advanced Usage

from somelang import somelang_all, somelang_no_whitelist

# Get all probable languages with confidence scores
results = somelang_all("Hello world")  # Returns: [['eng', 1.0], ...]

# Use all 194 languages (no whitelist)
lang = somelang_no_whitelist("Text in rare language")

Note

Currently, the library expects a minimum text length of 10 characters, but due to the current trigram-based approach, it may give a false positive on less than 100 character texts. This will be remedied in future updates.

Citations

Trained mainly on the OpenLID-v2 dataset and a few other datasets (for refinement).

Inspired by franc by Titus Wormer.

See CITATIONS file for more details.

License

This project is licensed under the MIT license. Authored by SomeAB.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

somelang-0.0.3.tar.gz (288.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

somelang-0.0.3-py3-none-any.whl (293.2 kB view details)

Uploaded Python 3

File details

Details for the file somelang-0.0.3.tar.gz.

File metadata

  • Download URL: somelang-0.0.3.tar.gz
  • Upload date:
  • Size: 288.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for somelang-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1047edc41d763cbf7085d4e0a7ce75724fee5e47d58de3e96fa3f58cdaa490c8
MD5 a11f280f95760277b7eef0fa4ff0199c
BLAKE2b-256 16ce3acc9d84bc48fe1646b0436d4d87ccbae7296b3463884ffb591c3f48286e

See more details on using hashes here.

File details

Details for the file somelang-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: somelang-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 293.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for somelang-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c56a134ad17a763abede6d37440e2e9787817e58bef16429914a8570fbfd5dfb
MD5 ba2d5964d192adca0739275ef1b10a6f
BLAKE2b-256 71091580170b1de4cb3fda6b09cc0c99cefdd86f6b08575ffa760d7a80347f17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page