def test_entities_synonyms():
    data = '\n{\n  "rasa_nlu_data": {\n    "entity_synonyms": [\n      {\n        "value": "nyc",\n        "synonyms": ["New York City", "nyc", "the big apple"]\n      }\n    ],\n    "common_examples" : [\n      {\n        "text": "show me flights to New York City",\n        "intent": "unk",\n        "entities": [\n          {\n            "entity": "destination",\n            "start": 19,\n            "end": 32,\n            "value": "NYC"\n          }\n        ]\n      },\n      {\n        "text": "show me flights to nyc",\n        "intent": "unk",\n        "entities": [\n          {\n            "entity": "destination",\n            "start": 19,\n            "end": 22,\n            "value": "nyc"\n          }\n        ]\n      }\n    ]\n  }\n}'
    with tempfile.NamedTemporaryFile(suffix='_tmp_training_data.json') as f:
        f.write(data.encode('utf-8'))
        f.flush()
        td = training_data.load_data(f.name)
        assert (td.entity_synonyms['New York City'] == 'nyc')
def test_entities_synonyms():
    data = '\n{\n  "rasa_nlu_data": {\n    "entity_synonyms": [\n      {\n        "value": "nyc",\n        "synonyms": ["New York City", "nyc", "the big apple"]\n      }\n    ],\n    "common_examples" : [\n      {\n        "text": "show me flights to New York City",\n        "intent": "unk",\n        "entities": [\n          {\n            "entity": "destination",\n            "start": 19,\n            "end": 32,\n            "value": "NYC"\n          }\n        ]\n      },\n      {\n        "text": "show me flights to nyc",\n        "intent": "unk",\n        "entities": [\n          {\n            "entity": "destination",\n            "start": 19,\n            "end": 22,\n            "value": "nyc"\n          }\n        ]\n      }\n    ]\n  }\n}'
    with tempfile.NamedTemporaryFile(suffix='_tmp_training_data.json') as f:
        f.write(data.encode('utf-8'))
        f.flush()
        td = training_data.load_data(f.name)
        assert (td.entity_synonyms['New York City'] == 'nyc')