spaCy - Util.get_lang_class



As the name implies, this function is used to import and load a Language class. It will return a Language class for which, we also add a custom language code using util.set_lang_class function.

Argument

The table below explains its argument −

NAME TYPE DESCRIPTION
lang unicode It will be a two-letter language code. For example, ‘de’ for German.

Example

An example for util.get_lang_class() function is as follows −

import spacy
for language_id in ["de"]:
   language_class = spacy.util.get_lang_class(language_id)
   language = language_class()
language

Output

The output is mentioned below −

<spacy.lang.de.German at 0x207b96b0dd8>
spacy_util_get_data_path.htm
Advertisements