Mhassanen commited on
Commit
c9f4c20
·
verified ·
1 Parent(s): 79fe2d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -31,9 +31,11 @@ def predict_class(text):
31
  st.error(f"Error during prediction: {e}")
32
  return None
33
 
 
34
  uploaded_files_dir = "uploaded_files"
35
  os.makedirs(uploaded_files_dir, exist_ok=True)
36
 
 
37
  class_colors = {
38
  0: "#d62728", # Level 1
39
  1: "#ff7f0e", # Level 2
@@ -47,6 +49,8 @@ st.image("logo2.png", width=70)
47
 
48
  st.markdown('<div style="position: absolute; top: 5px; left: 5px;"></div>', unsafe_allow_html=True)
49
 
 
 
50
  st.title("Paper Citation Classifier")
51
 
52
  option = st.radio("Select input type:", ("Text", "PDF"))
@@ -60,10 +64,12 @@ if option == "Text":
60
 
61
  categories = pills("Select WoS category", options)
62
 
 
 
63
  combined_text = f"{title_input} [SEP] {abstract_input} [SEP] {full_text_input} [SEP] {affiliations_input} [SEP] {' [SEP] '.join(categories)}"
64
 
65
  if st.button("Predict"):
66
- if not combined_text.strip(): # Check if combined_text is empty or contains only whitespace
67
  st.warning("Please enter paper text.")
68
  else:
69
  with st.spinner("Predicting..."):
@@ -97,8 +103,8 @@ elif option == "PDF":
97
  st.text(file_text)
98
 
99
  if st.button("Predict from PDF Text"):
100
- if not file_text.strip(): # Check if file_text is empty or contains only whitespace
101
- st.warning("Please upload a PDF file with text content.")
102
  else:
103
  with st.spinner("Predicting..."):
104
  predicted_class = predict_class(file_text)
 
31
  st.error(f"Error during prediction: {e}")
32
  return None
33
 
34
+
35
  uploaded_files_dir = "uploaded_files"
36
  os.makedirs(uploaded_files_dir, exist_ok=True)
37
 
38
+
39
  class_colors = {
40
  0: "#d62728", # Level 1
41
  1: "#ff7f0e", # Level 2
 
49
 
50
  st.markdown('<div style="position: absolute; top: 5px; left: 5px;"></div>', unsafe_allow_html=True)
51
 
52
+ # col1, col2 = st.columns([1, 3])
53
+
54
  st.title("Paper Citation Classifier")
55
 
56
  option = st.radio("Select input type:", ("Text", "PDF"))
 
64
 
65
  categories = pills("Select WoS category", options)
66
 
67
+ # categories = st.multiselect("Select WoS categories:", options)
68
+
69
  combined_text = f"{title_input} [SEP] {abstract_input} [SEP] {full_text_input} [SEP] {affiliations_input} [SEP] {' [SEP] '.join(categories)}"
70
 
71
  if st.button("Predict"):
72
+ if not any([title_input, abstract_input, full_text_input, affiliations_input]):
73
  st.warning("Please enter paper text.")
74
  else:
75
  with st.spinner("Predicting..."):
 
103
  st.text(file_text)
104
 
105
  if st.button("Predict from PDF Text"):
106
+ if not file_text.strip():
107
+ st.warning("Please upload a PDF with text content.")
108
  else:
109
  with st.spinner("Predicting..."):
110
  predicted_class = predict_class(file_text)