TagaCare / app.py
rande's picture
Update app.py
0790bf8
raw
history blame
1.22 kB
import streamlit as st
import tl_calamancy_lg
import os
import os
import pandas as pd
import json
# Get the absolute path of the script directory
cwd = os.getcwd()
# Read the CSV file
file_path = os.path.join(cwd, "dataset_v2.json")
# Open the JSON file
with open(file_path, 'r') as file:
# Load the JSON data
data = json.load(file)
# Extract patterns and responses into separate lists
patterns_data = []
responses_data = []
for intent in data["intents"]:
tag = intent["tag"]
patterns = intent.get("patterns", [])
responses = intent.get("responses", [])
for pattern in patterns:
patterns_data.append({"tag": tag, "pattern": pattern})
for response in responses:
responses_data.append({"tag": tag, "response": response})
# Create DataFrames
patterns_df = pd.DataFrame(patterns_data)
responses_df = pd.DataFrame(responses_data)
def main():
# StreamLit Title
st.title("TagaCare")
nlp = tl_calamancy_lg.load()
doc1 = nlp("Pano gamutin ang sakit sa ngipin")
st.success(doc1)
for data in patterns_data:
st.write(data)
for data in responses_data:
st.write(data)
if __name__ == "__main__":
main()