Update docs to reflect flattened model meta.json

Don't use "setup" key and instead, keep "lang" on root level and add
"pipeline".
This commit is contained in:
ines 2017-05-27 17:57:46 +02:00
parent a8e58e04ef
commit e05bcd6aa8
2 changed files with 17 additions and 23 deletions

View File

@ -19,20 +19,18 @@ p
p p
| When you load a model, spaCy first consults the model's | When you load a model, spaCy first consults the model's
| #[+a("/docs/usage/saving-loading#models-generating") meta.json] for its | #[+a("/docs/usage/saving-loading#models-generating") meta.json]. The
| #[code setup] details. This typically includes the ID of a language class, | meta typically includes the model details, the ID of a language class,
| and an optional list of pipeline components. spaCy then does the | and an optional list of pipeline components. spaCy then does the
| following: | following:
+aside-code("meta.json (excerpt)", "json"). +aside-code("meta.json (excerpt)", "json").
{ {
"name": "example_model", "name": "example_model",
"lang": "en"
"description": "Example model for spaCy", "description": "Example model for spaCy",
"setup": {
"lang": "en",
"pipeline": ["token_vectors", "tagger"] "pipeline": ["token_vectors", "tagger"]
} }
}
+list("numbers") +list("numbers")
+item +item
@ -287,18 +285,16 @@ p
p p
| In the model package's meta.json, specify the language class and pipeline | In the model package's meta.json, specify the language class and pipeline
| IDs in #[code setup]: | IDs:
+code("meta.json (excerpt)", "json"). +code("meta.json (excerpt)", "json").
{ {
"name": "my_sentiment_model", "name": "sentiment_model",
"lang": "en",
"version": "1.0.0", "version": "1.0.0",
"spacy_version": ">=2.0.0,<3.0.0", "spacy_version": ">=2.0.0,<3.0.0",
"setup": {
"lang": "en",
"pipeline": ["vectorizer", "sentiment"] "pipeline": ["vectorizer", "sentiment"]
} }
}
p p
| When you load your new model, spaCy will call the model's #[code load()] | When you load your new model, spaCy will call the model's #[code load()]
@ -307,7 +303,7 @@ p
| by your custom #[code "sentiment"] factory. | by your custom #[code "sentiment"] factory.
+code. +code.
nlp = spacy.load('my_sentiment_model') nlp = spacy.load('en_sentiment_model')
doc = nlp(u'I love pizza') doc = nlp(u'I love pizza')
assert doc.sentiment assert doc.sentiment

View File

@ -74,17 +74,15 @@ p
+aside-code("meta.json", "json"). +aside-code("meta.json", "json").
{ {
"name": "example_model", "name": "example_model",
"lang": "en",
"version": "1.0.0", "version": "1.0.0",
"spacy_version": ">=2.0.0,<3.0.0", "spacy_version": ">=2.0.0,<3.0.0",
"description": "Example model for spaCy", "description": "Example model for spaCy",
"author": "You", "author": "You",
"email": "you@example.com", "email": "you@example.com",
"license": "CC BY-SA 3.0", "license": "CC BY-SA 3.0",
"setup": {
"lang": "en",
"pipeline": ["token_vectors", "tagger"] "pipeline": ["token_vectors", "tagger"]
} }
}
+code(false, "bash"). +code(false, "bash").
python -m spacy package /home/me/data/en_example_model /home/me/my_models python -m spacy package /home/me/data/en_example_model /home/me/my_models
@ -110,9 +108,9 @@ p
+h(3, "models-custom") Customising the model setup +h(3, "models-custom") Customising the model setup
p p
| The meta.json includes a #[code setup] key that lets you customise how | The meta.json includes the model details, like name, requirements and
| the model should be initialised and loaded. You can define the language | license, and lets you customise how the model should be initialised and
| data to be loaded and the | loaded. You can define the language data to be loaded and the
| #[+a("/docs/usage/language-processing-pipeline") processing pipeline] to | #[+a("/docs/usage/language-processing-pipeline") processing pipeline] to
| execute. | execute.
@ -183,9 +181,9 @@ p
p p
| To load a model from a data directory, you can use | To load a model from a data directory, you can use
| #[+api("spacy#load") #[code spacy.load()]] with the local path. This will | #[+api("spacy#load") #[code spacy.load()]] with the local path. This will
| look for a meta.json in the directory and use the #[code setup] details | look for a meta.json in the directory and use the #[code lang] and
| to initialise a #[code Language] class with a processing pipeline and | #[code pipeline] settings to initialise a #[code Language] class with a
| load in the model data. | processing pipeline and load in the model data.
+code. +code.
nlp = spacy.load('/path/to/model') nlp = spacy.load('/path/to/model')