{"id":3538,"library":"lingua-language-detector","title":"Lingua Language Detector","description":"Lingua Language Detector is an accurate natural language detection library for Python, suitable for both short text snippets and mixed-language texts. It leverages Rust bindings for high performance and low memory consumption, supporting 75 languages offline. The current version is 2.2.0, with an active development cycle featuring regular minor and patch releases.","status":"active","version":"2.2.0","language":"en","source_language":"en","source_url":"https://github.com/pemistahl/lingua-rs","tags":["language-detection","nlp","rust-bindings","offline","short-text","mixed-language"],"install":[{"cmd":"pip install lingua-language-detector","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python >= 3.12","package":"python","optional":false}],"imports":[{"note":null,"symbol":"Language","correct":"from lingua import Language"},{"note":null,"symbol":"LanguageDetectorBuilder","correct":"from lingua import LanguageDetectorBuilder"}],"quickstart":{"code":"from lingua import Language, LanguageDetectorBuilder\n\n# Build a detector for specific languages\nlanguages = [Language.ENGLISH, Language.FRENCH, Language.GERMAN]\ndetector = LanguageDetectorBuilder.from_languages(*languages).build()\n\n# Detect a single language\ntext_single = \"languages are awesome\"\ndetected_language_single = detector.detect_language_of(text_single)\nprint(f\"Detected language (single): {detected_language_single.name}\")\n\n# Detect multiple languages in mixed text (experimental)\ntext_mixed = \"Hello world, comment ça va? Das ist ein Test.\"\ndetected_languages_mixed = detector.detect_multiple_languages_of(text_mixed)\nprint(\"Detected languages (mixed):\")\nfor result in detected_languages_mixed:\n    print(f\"  - {result.language.name}: '{text_mixed[result.start_index:result.end_index]}' ({result.start_index}-{result.end_index})\")","lang":"python","description":"This quickstart demonstrates how to build a language detector, detect the language of a single text, and identify multiple languages within a mixed-language text. It utilizes the `Language` enum and `LanguageDetectorBuilder` to configure and create a detector instance."},"warnings":[{"fix":"Review the official documentation for `lingua-language-detector` 2.x and update code to use the new API, especially `LanguageDetectorBuilder` and `Language` enum.","message":"Version 2.0.0 completely replaced the pure Python implementation with Rust bindings, changing the underlying API. Code written for `1.x` versions will likely break and require adaptation.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade your Python environment to version 3.12 or higher.","message":"Starting with version 2.1.1, support for Python 3.10 and 3.11 was dropped. The library now requires Python 3.12 or newer.","severity":"breaking","affected_versions":">=2.1.1"},{"fix":"Avoid `with_low_accuracy_mode()` for short texts or applications where high accuracy is paramount. Consider pre-filtering languages to optimize performance without sacrificing accuracy.","message":"Using `LanguageDetectorBuilder.with_low_accuracy_mode()` improves performance and reduces memory but significantly decreases detection accuracy for texts shorter than 120 characters.","severity":"gotcha","affected_versions":">=1.5.0"},{"fix":"Be aware of potential inaccuracies when using `detect_multiple_languages_of()` on very short or ambiguous mixed texts. Test thoroughly with your specific data.","message":"The `detect_multiple_languages_of()` method for mixed-language texts is considered experimental. Its results are highly dependent on the input text and it performs best in high-accuracy mode with longer words.","severity":"gotcha","affected_versions":">=1.5.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}