Beispiel #1
0
    def test_whenInstanciatedWithPath_thenShouldLoadBPEmbModel(self):
        with patch('deepparse.embeddings_models.bpemb_embeddings_model.BPEmb',
                   return_value=self.model) as loader:
            self.embeddings_model = BPEmbEmbeddingsModel(lang="multi",
                                                         vs=100000,
                                                         dim=300)

            loader.assert_called_with(lang="multi", vs=100000, dim=300)
    def test_whenInstantiatedWithPath_thenShouldLoadBPEmbModel(self):
        with patch(
            "deepparse.embeddings_models.bpemb_embeddings_model.BPEmb",
            return_value=self.model,
        ) as loader:
            _ = BPEmbEmbeddingsModel(verbose=False)

            loader.assert_called_with(lang="multi", vs=100000, dim=300)
Beispiel #3
0
    def test_whenCalledToEmbed_thenShouldCallLoadedModel(self):
        with patch('deepparse.embeddings_models.bpemb_embeddings_model.BPEmb',
                   return_value=self.model) as loader:
            self.embeddings_model = BPEmbEmbeddingsModel(lang="multi",
                                                         vs=100000,
                                                         dim=300)

            self.embeddings_model(self.a_word)

            self.model.embed.assert_called_with(self.a_word)
    def test_givenADimOf9_whenAskDimProperty_thenReturnProperDim(self):
        with patch(
            "deepparse.embeddings_models.bpemb_embeddings_model.BPEmb",
            return_value=self.model,
        ):
            embeddings_model = BPEmbEmbeddingsModel(verbose=False)

            actual = embeddings_model.dim
            expected = self.dim
            self.assertEqual(actual, expected)
    def test_whenCalledToEmbed_thenShouldCallLoadedModel(self):
        with patch(
            "deepparse.embeddings_models.bpemb_embeddings_model.BPEmb",
            return_value=self.model,
        ):
            embeddings_model = BPEmbEmbeddingsModel(verbose=False)

            embeddings_model(self.a_word)

            self.model.embed.assert_called_with(self.a_word)
    def test_givenAWindowsOS_whenBPEmbModelCollateFnInDataLoaderNumWorkers2_thenWorkProperly(
        self, ):
        # we setup a smaller model for simplicity
        model = BPEmbEmbeddingsModel(verbose=self.verbose)
        data_transform = MockedDataTransform(model)

        data_loader = DataLoader(
            self.training_container,
            collate_fn=data_transform.collate_fn,
            batch_size=32,
            num_workers=2,
        )
        dataset = []
        for data in data_loader:
            dataset.append(data)
        self.assertGreater(len(dataset), 0)
    def test_givenANotWindowsOS_whenBPEmbModelInit_thenLoadWithProperFunction(
            self):
        # we setup a smaller model for simplicity
        model = BPEmbEmbeddingsModel(verbose=self.verbose)

        self.assertIsInstance(model.model, BPEmb)