예제 #1
0
def _correct_entities(latest_message: Dict[Text, Any],
                      endpoint: EndpointConfig,
                      sender_id: Text) -> Dict[Text, Any]:
    """Validate the entities of a user message.

    Returns the corrected entities"""

    entity_str = _as_md_message(latest_message.get("parse_data", {}))
    question = questionary.text(
        "Please mark the entities using [value](type) notation",
        default=entity_str)

    annotation = _ask_or_abort(question, sender_id, endpoint)
    # noinspection PyProtectedMember
    parsed = MarkdownReader()._parse_training_example(annotation)
    return parsed.get("entities", [])
예제 #2
0
def _correct_entities(latest_message, endpoint, sender_id):
    # type: (Dict[Text, Any], EndpointConfig, Text) -> Dict[Text, Any]
    """Validate the entities of a user message.

    Returns the corrected entities"""

    q = "Please mark the entities using [value](type) notation"
    entity_str = _as_md_message(latest_message.get("parse_data", {}))
    questions = [{
        "type": "input",
        "name": "annotation",
        "default": entity_str,
        "message": q,
    }]
    answers = _ask_questions(questions, sender_id, endpoint)
    # noinspection PyProtectedMember
    parsed = MarkdownReader()._parse_training_example(answers["annotation"])
    return parsed.get("entities", [])