This module allows you to add language detection capabilites to your spaCy pipeline. Also supports custom language detectors!
import spacy from spacy_langdetect import LanguageDetector nlp = spacy.load('en') nlp.add_pipe(LanguageDetector(), name='language_detector', last=True) text = 'This is an english text.' doc = nlp(text) # document level language detection. Think of it like average language of the document! print(doc._.language) # sentence level language detection for sent in doc.sents: print(sent, sent._.language)
Submit your project
If you have a project that you want the spaCy community to make use of, you can suggest it by submitting a pull request to the spaCy website repository. The Universe database is open-source and collected in a simple JSON file. For more details on the formats and available fields, see the documentation. Looking for inspiration your own spaCy plugin or extension? Check out the
project idea label on the issue tracker.