MCPcopy
hub / github.com/explosion/spaCy / config

Method config

spacy/language.py:280–312  ·  view source on GitHub ↗

Trainable config for the current language instance. Includes the current pipeline components, as well as default training config. RETURNS (thinc.api.Config): The config. DOCS: https://spacy.io/api/language#config

(self)

Source from the content-addressed store, hash-verified

278
279 @property
280 def config(self) -> Config:
281 """Trainable config for the current language instance. Includes the
282 current pipeline components, as well as default training config.
283
284 RETURNS (thinc.api.Config): The config.
285
286 DOCS: https://spacy.io/api/language#config
287 """
288 self._config.setdefault("nlp", {})
289 self._config.setdefault("training", {})
290 self._config["nlp"]["lang"] = self.lang
291 # We're storing the filled config for each pipeline component and so
292 # we can populate the config again later
293 pipeline = {}
294 score_weights = []
295 for pipe_name in self.component_names:
296 pipe_meta = self.get_pipe_meta(pipe_name)
297 pipe_config = self.get_pipe_config(pipe_name)
298 pipeline[pipe_name] = {"factory": pipe_meta.factory, **pipe_config}
299 if pipe_meta.default_score_weights:
300 score_weights.append(pipe_meta.default_score_weights)
301 self._config["nlp"]["pipeline"] = list(self.component_names)
302 self._config["nlp"]["disabled"] = list(self.disabled)
303 self._config["components"] = pipeline
304 # We're merging the existing score weights back into the combined
305 # weights to make sure we're preserving custom settings in the config
306 # but also reflect updates (e.g. new components added)
307 prev_weights = self._config["training"].get("score_weights", {})
308 combined_score_weights = combine_score_weights(score_weights, prev_weights)
309 self._config["training"]["score_weights"] = combined_score_weights
310 if not srsly.is_json_serializable(self._config):
311 raise ValueError(Errors.E961.format(config=self._config))
312 return self._config
313
314 @config.setter
315 def config(self, value: Config) -> None:

Callers

nothing calls this directly

Calls 6

get_pipe_metaMethod · 0.95
get_pipe_configMethod · 0.95
combine_score_weightsFunction · 0.85
setdefaultMethod · 0.80
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected