skillfed

spacy-language-detection

Fully customizable language detection for spaCy pipeline

spacy-language-detection v0.2.1 992.9K downloads/30d#4,557 on PyPI8
Copyleft license LGPLv3 Abandoned released

What it is and what it does

spacy_language_detection is a spaCy pipeline component that detects the language of text at both document and sentence level. It wraps langdetect under the hood and exposes language predictions as custom attributes (doc._.language and span._.language) on spaCy Doc and Span objects. The package was forked from spacy-langdetect to fix a seed problem and add spaCy 3.0 support.

The component is fully customizable: you can replace the default langdetect detector with your own language detection function (e.g., googletrans or pycld2) by passing a callable to the LanguageDetector constructor. This makes it useful for pipelines where you need language identification as a preprocessing or filtering step, or where you want to swap detection backends without rewriting integration code.

Use it for:

  • Filter or route multilingual documents to language-specific NLP pipelines based on detected language.
  • Identify language switches within a document to handle code-switching or mixed-language text.
  • Preprocess text corpora to separate documents by language before applying language-specific models.
  • Add language metadata to spaCy Doc objects for downstream analysis or logging.
  • Integrate a custom language detector (e.g., from an external API) into a spaCy workflow.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds language detection to spaCy pipelines at document and sentence level, using langdetect by default but accepting custom detection functions.

No. The package is abandoned (last update 2021-09-08, 1801 days ago) with no maintenance signal. While it has low install friction and no known vulnerabilities, the lack of updates means it may break with newer spaCy versions or Python releases. If you need language detection in spaCy, consider maintaining a fork or using a more actively maintained alternative.

Install

spacy-language-detection on PyPI

pip

pip install spacy-language-detection

uv

uv add spacy-language-detection

poetry

poetry add spacy-language-detection

Installing spacy-language-detection

Before you install

Low install friction with just two runtime dependencies (spacy and langdetect). However, the package is abandoned—last commit was 2021-09-08 and no updates since. Use only if you need this specific functionality and are comfortable maintaining a fork yourself.

License in practice

Licensed under LGPLv3 (copyleft). You must disclose source code and license any derivative work under the same terms if you distribute it; internal use has no obligation.

Quickstart

import spacy
from spacy.language import Language
from spacy_language_detection import LanguageDetector

def get_lang_detector(nlp, name):
    return LanguageDetector(seed=42)

nlp = spacy.load("en_core_web_sm")
Language.factory("language_detector", func=get_lang_detector)
nlp.add_pipe('language_detector', last=True)

doc = nlp("This is English text.")
print(doc._.language)

Requires a spaCy model to be installed separately (e.g., spacy download en_core_web_sm).

Verify before relying

  • Accuracy and performance of langdetect on modern language distributions and edge cases.
  • Compatibility with spaCy versions released after 2021-09-08.
  • Whether the seed-fixing fork resolves the original spacy-langdetect randomness issue completely.

Package facts

License LGPLv3 (copyleft)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — spacy, langdetect
Maintenance abandoned — 1,801 days since the last release
Last repo commit
First released
Downloads 992,917/month — #4,557 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: spacy_language_detection-0.2.1-py3-none-any.whl

Development Status :: 3 - AlphaIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)Programming Language :: Python :: 3Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

spacy language detectiondetect document languagemultilingual text processingsentence language identificationspacy nlp pipeline extensionlanguage classifier for spacyidentify text language
nlp-pipelinelanguage-detectionabandoned

More Libraries packages