def test_should_be_serializable_into_bytearray(self): # Given dataset_stream = io.StringIO(""" --- type: intent name: MakeTea utterances: - make me [number_of_cups:snips/number](one) cup of tea - i want [number_of_cups] cups of tea please - can you prepare [number_of_cups] cup of tea ? --- type: intent name: MakeCoffee utterances: - make me [number_of_cups:snips/number](two) cups of coffee - brew [number_of_cups] cups of coffee - can you prepare [number_of_cups] cup of coffee""") dataset = Dataset.from_yaml_files("en", [dataset_stream]).json shared = self.get_shared_data(dataset) intent_parser = DeterministicIntentParser(**shared).fit(dataset) # When intent_parser_bytes = intent_parser.to_byte_array() loaded_intent_parser = DeterministicIntentParser.from_byte_array( intent_parser_bytes, **shared) result = loaded_intent_parser.parse("make me two cups of coffee") # Then self.assertEqual("MakeCoffee", result[RES_INTENT][RES_INTENT_NAME])
def test_should_be_serializable_into_bytearray(self): # Given dataset = BEVERAGE_DATASET intent_parser = DeterministicIntentParser().fit(dataset) # When intent_parser_bytes = intent_parser.to_byte_array() loaded_intent_parser = DeterministicIntentParser.from_byte_array( intent_parser_bytes) result = loaded_intent_parser.parse("make me two cups of coffee") # Then self.assertEqual("MakeCoffee", result[RES_INTENT][RES_INTENT_NAME])
def test_should_be_serializable_into_bytearray(self): # Given dataset = BEVERAGE_DATASET intent_parser = DeterministicIntentParser().fit(dataset) custom_entity_parser = intent_parser.custom_entity_parser # When intent_parser_bytes = intent_parser.to_byte_array() loaded_intent_parser = DeterministicIntentParser.from_byte_array( intent_parser_bytes, builtin_entity_parser=BuiltinEntityParser.build(language="en"), custom_entity_parser=custom_entity_parser) result = loaded_intent_parser.parse("make me two cups of coffee") # Then self.assertEqual("MakeCoffee", result[RES_INTENT][RES_INTENT_NAME])