Skip to main content

WizardLangID Banner


WizardLangID

PyPI - Version PyPI - Downloads/month License

WizardLangID is a Python library for Language identification via character n-gram profiles. Candidate gating guided by priors and linguistic cues, then probability estimation for each language. Supports 161 languages. Returns a top-1 ISO code or a probability-ordered list.


Contents


Installation

Requires Python 3.9+.

pip install wizardlangid

Quick start

import wizardlangid as wl

text = "hello world"
lang = wl.lang_detect(text, return_top1=True)
print(lang) 

Language detection

Parameters

  • text: Input string (Unicode).
  • top_k: Number of candidates to return (default 3).
  • profiles_dir: Override the bundled profiles directory.
  • use_mmap: If True, memory-map the profile tries (lower RAM; first access may be slightly slower).
  • return_top1: If True, return only the best language code; otherwise a list of (lang, prob).

Examples

Top-1 (single code)

import wizardlangid as wl

text = "Ciao, come stai oggi?"
lang = wl.lang_detect(text, return_top1=True)
print(lang) 

Output

it

Top-k distribution

import wizardlangid as wl

text = "The quick brown fox jumps over the lazy dog."
langs = wl.lang_detect(text, top_k=5, return_top1=False)
print(langs) 

Output

[('en', 0.9999376335362183), ('mg', 4.719212057614953e-05), ('fy', 1.4727973350205069e-05), ('rm', 2.8718519851832537e-07), ('la', 1.5918465665694727e-07)]

Batch example

import wizardlangid as wl

tests = [
    "これは日本語のテスト文です。",
    "Alex parle un peu français, aber nicht so viel.",
    "¿Dónde está la estación de tren?",
]
for s in tests:
    print("TOP1:", wl.lang_detect(s, return_top1=True))

Output

TOP1: ja
TOP1: fr
TOP1: es

Custom profiles & mmap

from pathlib import Path
import wizardlangid as wl

langs = wl.lang_detect(
    "Buongiorno a tutti!",
    profiles_dir=Path("/opt/wizardlangid/profiles"),  # custom profiles
    use_mmap=True,                                   # lower RAM
    top_k=3,
)
print(langs)

License

AGPL-3.0-or-later.

RESOURCES


Contact & Author

Author: Mattia Rubino
Email: textwizard.dev@gmail.com

Metadata

Release files for wizardlangid 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wizardlangid 1.0.0
File Size Uploaded Provenance Actions
wizardlangid-1.0.0.tar.gz 21.7 MB Without provenance Details for wizardlangid-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wizardlangid 1.0.0
File Interpreter ABI Platform Actions
wizardlangid-1.0.0-py3-none-any.whl Python 3 none any Details for wizardlangid-1.0.0-py3-none-any.whl

Total release size: 43.8 MB

Release files / wizardlangid-1.0.0.tar.gz

Download URL wizardlangid-1.0.0.tar.gz
Size 21.7 MB
Tags Source
SHA-256 checksum
How to use checksums
0e7dd49142c858a809ea26889f9712773c944f1c9d8804eedc9fbe48ddf57cc2
BLAKE2b-256 checksum
How to use checksums
70c588761d3a36bc55f0406f30cb620dfffd0cc240b2108c693ddf32d4028cfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Release files / wizardlangid-1.0.0-py3-none-any.whl

Download URL wizardlangid-1.0.0-py3-none-any.whl
Size 22.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
87c6a2871ed74712859408136f744dc3f6fc30109ca5dd55aaa5dff6a272c520
BLAKE2b-256 checksum
How to use checksums
6e89e0ab0fbce2b6230e12d25d620dc2e05cebc84dc8d7e57edd475e0b9458b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Security for wizardlangid 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page