Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,53 @@
|
|
1 |
import streamlit as st
|
2 |
import tl_calamancy_lg
|
3 |
import os
|
|
|
|
|
|
|
4 |
|
5 |
# Get the absolute path of the script directory
|
6 |
cwd = os.getcwd()
|
7 |
|
8 |
# Read the CSV file
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import tl_calamancy_lg
|
3 |
import os
|
4 |
+
import os
|
5 |
+
import pandas as pd
|
6 |
+
import json
|
7 |
|
8 |
# Get the absolute path of the script directory
|
9 |
cwd = os.getcwd()
|
10 |
|
11 |
# Read the CSV file
|
12 |
+
file_path = os.path.join(cwd, "dataset_v2.json")
|
13 |
+
|
14 |
+
# Open the JSON file
|
15 |
+
with open(file_path, 'r') as file:
|
16 |
+
# Load the JSON data
|
17 |
+
data = json.load(file)
|
18 |
+
|
19 |
+
# Extract patterns and responses into separate lists
|
20 |
+
patterns_data = []
|
21 |
+
responses_data = []
|
22 |
+
|
23 |
+
for intent in data["intents"]:
|
24 |
+
tag = intent["tag"]
|
25 |
+
patterns = intent.get("patterns", [])
|
26 |
+
responses = intent.get("responses", [])
|
27 |
+
|
28 |
+
for pattern in patterns:
|
29 |
+
patterns_data.append({"tag": tag, "pattern": pattern})
|
30 |
+
|
31 |
+
for response in responses:
|
32 |
+
responses_data.append({"tag": tag, "response": response})
|
33 |
+
|
34 |
+
# Create DataFrames
|
35 |
+
patterns_df = pd.DataFrame(patterns_data)
|
36 |
+
responses_df = pd.DataFrame(responses_data)
|
37 |
+
|
38 |
+
def main():
|
39 |
+
# StreamLit Title
|
40 |
+
st.title("TagaCare")
|
41 |
+
|
42 |
+
nlp = tl_calamancy_lg.load()
|
43 |
+
|
44 |
+
doc1 = nlp("Pano gamutin ang sakit sa ngipin")
|
45 |
+
|
46 |
+
st.success(doc1)
|
47 |
+
|
48 |
+
for data in patterns_data:
|
49 |
+
st.write(data)
|
50 |
+
|
51 |
+
|
52 |
+
if __name__ == "__main__":
|
53 |
+
main()
|