Пример #1
0
def test_extract_hs2():
    md = open_file("examples/nlu_retrieval_intents.md")
    result = _extract_h2s(md)
    assert result == [
        "## intent: chitchat/what_should_i_buy",
        "## intent: how_should_i_spend_money",
        "## intent: chitchat/tell_me_a_joke",
    ]
Пример #2
0
                                               reverse=True)
        if args.similarity:
            similar: List[List] = [[t, s] for t, s in outputs_with_sim
                                   if s >= float(args.similarity)]
            less_similar: List[List] = [[t, s] for t, s in outputs_with_sim
                                        if s < float(args.similarity)]

            print("Similar: ")
            print(tabulate(similar))

            print("\nLess Similar: ")
            print(tabulate(less_similar))

        if args.csv:
            # csv will always include similarity
            df = pd.DataFrame(outputs_with_sim, columns=["text", "similarity"])
            df.to_csv(args.csv)

    if args.nlu:
        expanded_md = expand_nlu(open_file(args.nlu),
                                 params,
                                 model=model,
                                 verbose=args.verbose)
        print(expanded_md)

    # Stop the clock
    stop_perf = perf_counter()

    if args.verbose:
        print("Elapsed time:", abs(stop_perf - start_perf))
Пример #3
0
def test_open_file():
    result = open_file("examples/nlu_no_entities.md")
    assert result is not None
Пример #4
0
def test_extract_nlu():
    result = extract_nlu(open_file("examples/nlu_no_entities.md"))
    assert result is not None
    assert isinstance(result[0], tuple)
    assert isinstance(result[0][0], str)
    assert isinstance(result[0][1], list)
Пример #5
0
def test_extract_nlu_leading_line_breaks():
    md = open_file("examples/nlu_leading_breaks.md")
    result = extract_nlu(md)

    assert any(result[0][1])