Guillem
Guillem

Reputation: 164

How to load arbitrary languages from Spacy

So I have this function:

import spacy

def foo(lang):
   if lang == "en":
       model = spacy.lang.en.English()
   elif:

There are a ton of languages in Spacy and I need to be able to handle them all (with no hardcoding).

Reading their code, they have submodules like en and in teh variable __all__ there is "English" but I could not figure out how could I do it.

Upvotes: 1

Views: 143

Answers (1)

aab
aab

Reputation: 11474

To load a Language (this does not include any statistical models):

nlp = spacy.util.get_lang_class("en")

Upvotes: 1

Related Questions