rahideer commited on
Commit
7d5ee6e
·
verified ·
1 Parent(s): 7253722

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -30
app.py CHANGED
@@ -1,34 +1,26 @@
1
  import streamlit as st
2
- import pandas as pd
3
  import zipfile
4
  import os
5
- from sentence_transformers import SentenceTransformer, util
6
- from transformers import pipeline
7
 
8
- st.set_page_config(page_title="Multilingual NLI RAG App")
9
-
10
- st.title("🌍 Multilingual RAG-style NLI App")
11
- st.markdown("Upload the `xnli-multilingual-nli-dataset.zip` file from Kaggle to explore relationships between premises and hypotheses in different languages.")
12
-
13
- EXTRACT_FOLDER = "extracted_data"
14
-
15
- # File upload
16
- uploaded_file = st.file_uploader("Upload the XNLI dataset ZIP file", type="zip")
17
-
18
- if uploaded_file:
19
- # Make sure the folder exists
20
- if not os.path.exists(EXTRACT_FOLDER):
21
- os.makedirs(EXTRACT_FOLDER)
22
-
23
- # Save and extract zip
24
- zip_path = os.path.join(EXTRACT_FOLDER, "dataset.zip")
25
- with open(zip_path, "wb") as f:
26
- f.write(uploaded_file.read())
27
-
28
- with zipfile.ZipFile(zip_path, "r") as zip_ref:
29
- zip_ref.extractall(EXTRACT_FOLDER)
30
-
31
- # List available CSVs
32
- csv_files = [f for f in os.listdir(EXTRACT_FOLDER) if f.endswith(".csv")]
33
- if csv_files:
34
- selected_csv = st.selectbox("Choose a language CSV file_
 
1
  import streamlit as st
 
2
  import zipfile
3
  import os
 
 
4
 
5
+ # Path to your uploaded zip file
6
+ ZIP_FILE = "xnli-multilingual-nli-dataset.zip"
7
+ EXTRACT_DIR = "extracted_data"
8
+
9
+ # Extract contents and list files
10
+ @st.cache_data
11
+ def extract_and_list():
12
+ with zipfile.ZipFile(ZIP_FILE, "r") as zip_ref:
13
+ zip_ref.extractall(EXTRACT_DIR)
14
+ return os.listdir(EXTRACT_DIR)
15
+
16
+ # App starts here
17
+ st.set_page_config(page_title="XNLI Multilingual Viewer")
18
+ st.title("📂 XNLI Multilingual Dataset Viewer")
19
+
20
+ if not os.path.exists(ZIP_FILE):
21
+ st.error("Zip file not found. Please upload it.")
22
+ else:
23
+ files = extract_and_list()
24
+ st.success("Zip file extracted successfully!")
25
+ st.write("Here are the files inside your dataset:")
26
+ st.code("\n".join(files), language="text")