Esempio n. 1
0
    def reset_pipeline(self, name):
        """
        Resets a pipeline given its name. (i.e. reloads it from config)

        Useful if you want to re-assemble it.

        :param name: Name of the pipeline to reset.
        :return: Newly created pipeline.
        """
        self.pipelines[name] = from_config(self.pipeline_configs[name])
        return self.pipelines[name]
Esempio n. 2
0
    def test_successful_parse_raw_text(self):
        p = pipeline.from_config(self.tp)
        p.assemble(ending=None)
        docs = p.load("tests/resources/test.txt")
        nt.assert_equal(len(docs), 1)
        doc = docs[0]
        nt.assert_equal(doc.language.name, "English")
        nt.assert_equal(doc.marco, "polo")
        nt.assert_equal(len(doc.sentences), 3)

        nt.assert_equal(doc.sentences[0].words[1].normalized_text,
                        "corporation")
Esempio n. 3
0
 def __init__(self, cfg_or_path: Union[str, ConfigTree] = None):
     super().__init__()
     if isinstance(cfg_or_path, Mapping):
         self.cfg = cfg_or_path
     else:
         try:
             self.cfg = util.read_config(cfg_or_path)['main']
         except Exception:
             raise ValueError("Could not construct main class. Param "
                              "cfg_or_path should be string or dict-like config! (Was {})".format(type(cfg_or_path)))
     self._docs = []
     self.dist_service: EmbeddingComparator = util.safe_construct(self.cfg['embedding_comparator'],
                                                                  restrict_to=EmbeddingComparator,
                                                                  relative_import="estrella.operate.latent")
     self.languages = language.from_config(self.cfg['languages'])
     self.pipeline_configs: Dict[str, ConfigTree] = {
         k: v for k, v in self.cfg.get_config("pipelines").items()
     }  # from name to config
     self.pipelines: Dict[str, Pipeline] = {
         k: from_config(v) for k, v in self.pipeline_configs.items()
     }  # from name to actual pipeline
Esempio n. 4
0
 def test_successful_setup_from_config_flat_kwargs(self):
     p = pipeline.from_config(self.tp)
     p.assemble(ending=".jpg")
     nt.assert_equal(p.source_reader.ending, ".jpg")
Esempio n. 5
0
 def test_successful_setup_from_config(self):
     pipeline.from_config(self.tp).assemble()