Esempio n. 1
0
    def test_slot_filler_data_augmentation_config(self):
        # Given
        config_dict = {"min_utterances": 42, "capitalization_ratio": 0.66}

        # When
        config = SlotFillerDataAugmentationConfig.from_dict(config_dict)
        serialized_config = config.to_dict()

        # Then
        self.assertDictEqual(config_dict, serialized_config)
Esempio n. 2
0
    def test_crf_slot_filler_config(self):
        # Given
        feature_factories = [{
            "args": {
                "common_words_gazetteer_name": None,
                "use_stemming": True,
                "n": 1
            },
            "factory_name": "get_ngram_fn",
            "offsets": [-2, -1, 0, 1, 2]
        }, {
            "args": {},
            "factory_name": "is_digit",
            "offsets": [-1, 0, 1]
        }]
        config_dict = {
            "unit_name":
            "crf_slot_filler",
            "feature_factory_configs":
            feature_factories,
            "tagging_scheme":
            2,
            "crf_args": {
                "c1": .2,
                "c2": .3,
                "algorithm": "lbfgs"
            },
            "exhaustive_permutations_threshold":
            42,
            "data_augmentation_config":
            SlotFillerDataAugmentationConfig().to_dict(),
            "random_seed":
            43
        }

        # When
        config = CRFSlotFillerConfig.from_dict(config_dict)
        serialized_config = config.to_dict()

        # Then
        self.assertDictEqual(config_dict, serialized_config)