rasa/core/training/interactive.py
async def _write_nlu_to_file(
    export_nlu_path: Text,
    evts: List[Dict[Text, Any]]
) -> None:
    """Write the nlu data of the sender_id to the file paths."""
    from rasa_nlu.training_data import TrainingData

    msgs = _collect_messages(evts)

    # noinspection PyBroadException
    try:
        previous_examples = load_data(export_nlu_path)
    except Exception as e:
        logger.exception("An exception occurred while trying to load the "
                         "NLU data.")

        export_nlu_path = questionary.text(
            message="Could not load existing NLU data, please "
                    "specify where to store NLU data learned in "
                    "this session (this will overwrite any "
                    "existing file). {}".format(str(e)),
            default=PATHS["backup"]).ask()

        if export_nlu_path is None:
            return

        previous_examples = TrainingData()

    nlu_data = previous_examples.merge(TrainingData(msgs))

    # need to guess the format of the file before opening it to avoid a read
    # in a write
    if _guess_format(export_nlu_path) in {"md", "unk"}:
        fformat = "md"
    else:
        fformat = "json"

    with open(export_nlu_path, 'w', encoding="utf-8") as f:
        if fformat == "md":
            f.write(nlu_data.as_markdown())
        else:
            f.write(nlu_data.as_json())
Write the nlu data of the sender_id to the file paths.
Write the nlu data of the sender_id to the file paths.
Write the nlu data of the sender_id to the file paths .
async def _write_nlu_to_file(
    export_nlu_path: Text,
    evts: List[Dict[Text, Any]]
) -> None:
    from rasa_nlu.training_data import TrainingData
    msgs = _collect_messages(evts)
    try:
        previous_examples = load_data(export_nlu_path)
    except Exception as e:
        logger.exception("An exception occurred while trying to load the "
                         "NLU data.")
        export_nlu_path = questionary.text(
            message="Could not load existing NLU data, please "
                    "specify where to store NLU data learned in "
                    "this session (this will overwrite any "
                    "existing file). {}".format(str(e)),
            default=PATHS["backup"]).ask()
        if export_nlu_path is None:
            return
        previous_examples = TrainingData()
    nlu_data = previous_examples.merge(TrainingData(msgs))
    if _guess_format(export_nlu_path) in {"md", "unk"}:
        fformat = "md"
    else:
        fformat = "json"
    with open(export_nlu_path, 'w', encoding="utf-8") as f:
        if fformat == "md":
            f.write(nlu_data.as_markdown())
        else:
            f.write(nlu_data.as_json())
async def _write_nlu_to_file ( export_nlu_path : Text , evts : List [ Dict [ Text , Any ] ] ) -> None : from rasa_nlu . training_data import TrainingData msgs = _collect_messages ( evts ) try : previous_examples = load_data ( export_nlu_path ) except Exception as e : logger . exception ( "An exception occurred while trying to load the " "NLU data." ) export_nlu_path = questionary . text ( message = "Could not load existing NLU data, please " "specify where to store NLU data learned in " "this session (this will overwrite any " "existing file). {}" . format ( str ( e ) ) , default = PATHS [ "backup" ] ) . ask ( ) if export_nlu_path is None : return previous_examples = TrainingData ( ) nlu_data = previous_examples . merge ( TrainingData ( msgs ) ) if _guess_format ( export_nlu_path ) in { "md" , "unk" } : fformat = "md" else : fformat = "json" with open ( export_nlu_path , 'w' , encoding = "utf-8" ) as f : if fformat == "md" : f . write ( nlu_data . as_markdown ( ) ) else : f . write ( nlu_data . as_json ( ) )
Write the nlu data of the sender_id to the file paths.
Write the nlu data of the sender_id to the file paths .
"""Write the nlu data of the sender_id to the file paths.""" # noinspection PyBroadException # need to guess the format of the file before opening it to avoid a read # in a write
export_nlu_path
Text
evts
List[Dict[Text, Any]]