Document util.set_lang_class (see
@@ -51,7 +51,9 @@ p
p
| Import and load a #[code Language] class. Allows lazy-loading
| #[+a("/usage/adding-languages") language data] and importing
- | languages using the two-letter language code.
+ | languages using the two-letter language code. To add a language code
+ | for a custom language class, you can use the
+ | #[+api("top-level#util.set_lang_class") #[code set_lang_class]] helper.
+aside-code("Example").
for lang_id in ['en', 'de']:
@@ -70,6 +72,33 @@ p
+cell #[code Language]
+cell Language class.
++h(3, "util.set_lang_class") util.set_lang_class
+ +tag function
+
+p
+ | Set a custom #[code Language] class name that can be loaded via
+ | #[+api("top-level#util.get_lang_class") #[code get_lang_class]]. If
+ | your model uses a custom language, this is required so that spaCy can
+ | load the correct class from the two-letter language code.
+
++aside-code("Example").
+ from spacy.lang.xy import CustomLanguage
+
+ util.set_lang_class('xy', CustomLanguage)
+ lang_class = util.get_lang_class('xy')
+ nlp = lang_class()
+
++table(["Name", "Type", "Description"])
+ +row
+ +cell #[code name]
+ +cell unicode
+ +cell Two-letter language code, e.g. #[code 'en'].
+
+ +row
+ +cell #[code cls]
+ +cell #[code Language]
+ +cell The language class, e.g. #[code English].
+
+h(3, "util.load_model") util.load_model
+tag function
+tag-new(2)
