def process_training_examples_by_key( training_examples: Dict, key_name: Text, key_examples: Text, example_extraction_predicate=lambda x: x, ) -> List[OrderedDict]: from ruamel.yaml.scalarstring import LiteralScalarString result = [] for entity_key, examples in training_examples.items(): converted_examples = [ TrainingDataWriter.generate_list_item( example_extraction_predicate(example).strip(STRIP_SYMBOLS)) for example in examples ] next_item = OrderedDict() next_item[key_name] = entity_key next_item[key_examples] = LiteralScalarString( "".join(converted_examples)) result.append(next_item) return result
def render(example: Dict) -> Text: return TrainingDataWriter.generate_list_item( example[KEY_INTENT_TEXT])