From 8c47da1f1943df6681b771bd12ca8aca005b5b0f Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Tue, 7 Aug 2018 14:17:57 +0200 Subject: [PATCH] Update Language serialization docs (see #2628) [ci skip] Add note on using from_disk and from_bytes via subclasses and add example --- website/api/language.jade | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/website/api/language.jade b/website/api/language.jade index a5069d032..a04650dc9 100644 --- a/website/api/language.jade +++ b/website/api/language.jade @@ -513,11 +513,19 @@ p p | Loads state from a directory. Modifies the object in place and returns | it. If the saved #[code Language] object contains a model, the - | #[strong model will be loaded]. + | model will be loaded. Note that this method is commonly used via the + | subclasses like #[code English] or #[code German] to make + | language-specific functionality like the + | #[+a("/usage/adding-languages#lex-attrs") lexical attribute getters] + | available to the loaded object. +aside-code("Example"). from spacy.language import Language - nlp = Language().from_disk('/path/to/models') + nlp = Language().from_disk('/path/to/model') + + # using language-specific subclass + from spacy.lang.en import English + nlp = English().from_disk('/path/to/en_model') +table(["Name", "Type", "Description"]) +row @@ -575,7 +583,12 @@ p Serialize the current state to a binary string. +h(2, "from_bytes") Language.from_bytes +tag method -p Load state from a binary string. +p + | Load state from a binary string. Note that this method is commonly used + | via the subclasses like #[code English] or #[code German] to make + | language-specific functionality like the + | #[+a("/usage/adding-languages#lex-attrs") lexical attribute getters] + | available to the loaded object. +aside-code("Example"). from spacy.lang.en import English