示例#1
0
def test_can_pick_up_entities():
    model_folder = "tests/demo/models"
    model_path = list(pathlib.Path(model_folder).glob("*"))[0]
    interpreter = load_interpreter(model_folder, str(model_path.parts[-1]))
    blob, nlu_dict, tokens = fetch_info_from_message(interpreter=interpreter,
                                                     text_input="hello python")
    assert blob["entities"][0]["entity"] == "proglang"
    assert blob["entities"][0]["value"] == "python"
示例#2
0
def test_load_interpreter_can_load():
    model_folder = "tests/demo/models"
    model_path = list(pathlib.Path(model_folder).glob("*"))[0]
    interpreter = load_interpreter(model_folder, str(model_path.parts[-1]))
    blob, nlu_dict, tokens = fetch_info_from_message(interpreter=interpreter,
                                                     text_input="hello world")

    assert blob["text"] == "hello world"
    assert tokens == ["hello", "world"]
    all_intents = [
        "talk_code",
        "bot_challenge",
        "mood_unhappy",
        "mood_great",
        "deny",
        "affirm",
        "goodbye",
        "greet",
    ]
    assert [i["name"] in all_intents for i in blob["intent_ranking"]]
示例#3
0
args = parser.parse_args()

model_folder = args.folder

st.markdown("# Arabic KYC NLU Model Summary")
st.markdown("You can select a model on the left to interact with.")

model_files = [
    str(p.parts[-1]) for p in pathlib.Path(model_folder).glob("*.tar.gz")
]
model_file = st.sidebar.selectbox("What model do you want to use", model_files)

interpreter = load_interpreter(model_folder, model_file)

text_input = st.text_input("Text Input for Model", "Hello")

blob, nlu_dict, tokens = fetch_info_from_message(interpreter=interpreter,
                                                 text_input=text_input)

st.markdown("## Tokens and Entities")
st.write(
    create_displacy_chart(tokens=tokens, entities=blob["entities"]),
    unsafe_allow_html=True,
)

st.markdown("## Intents")

chart_data = pd.DataFrame(blob["intent_ranking"]).sort_values("name")
p = create_altair_chart(chart_data)
st.altair_chart(p.properties(width=600))