Spaces:
Running
Running
import streamlit as st | |
import streamlit.components.v1 as components | |
from infer_intent import IntentClassifier | |
from infer_location import LocationFinder | |
import matplotlib.pyplot as plt | |
st.title("Intent classifier") | |
def get_intent_classifier(): | |
cls = IntentClassifier() | |
return cls | |
def get_location_finder(): | |
ner = LocationFinder() | |
return ner | |
cls = get_intent_classifier() | |
query = st.text_input("Enter a query", value="What is the weather today") | |
pred_result, proba_result = cls.find_intent(query) | |
ner = get_location_finder() | |
location = ner.find_location(query) | |
st.markdown(f"Intent = :green[{pred_result}]") | |
st.markdown(f"Location = :green[{location}]") | |
keys = list(proba_result.keys()) | |
values = list(proba_result.values()) | |
# Creating the bar plot | |
fig, ax = plt.subplots() | |
ax.barh(keys, values) | |
# Adding labels and title | |
ax.set_xlabel('probability score') | |
ax.set_ylabel('Intents') | |
ax.set_title('Intents probability score') | |
st.pyplot(fig) | |