def to_entities(js):
    """Converts duckling output to the correct format."""
    entities = {}
    for entity in js:
        key, value = entity['dim'], entity['value']
        if key == 'time':
            key = 'datetime'
        if key not in entities:
            entities[key] = []
        entities[key].append(value)
    return entities
