jkushwaha commited on
Commit
eb88408
·
verified ·
1 Parent(s): 2970320

Create onhold.py

Browse files
Files changed (1) hide show
  1. onhold.py +77 -0
onhold.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def onhold():
2
+ inbound_df_path = 'inbound_issues_tempus_2_q2_new.csv'
3
+ pif_list, image_path, auto_csv_path = path_setting(inbound_df_path)
4
+
5
+ # st.set_page_config(layout="wide") # Set layout to wide
6
+
7
+ # Slider to adjust the width of the columns
8
+ col1_width = st.sidebar.slider("Width of First Column", 0.1, 10.0, 2.0, 0.1)
9
+ col2_width = st.sidebar.slider("Width of Second Column", 0.1, 10.0, 6.5, 0.1)
10
+ col3_width = st.sidebar.slider("Width of Third Column", 0.1, 10.0, 5.0, 0.1)
11
+
12
+ # Divide the screen into three vertical panels with specified widths
13
+ col1, col2, col3 = st.columns([col1_width, col2_width, col3_width])
14
+
15
+ # Document Selection Panel
16
+ with col1:
17
+ st.write("### Document Selection")
18
+ global doc_index
19
+ doc_index = st.number_input("Select Document Index", min_value=1, max_value=len(pif_list)+1, step=1, value=1)
20
+ # doc_index = st.select_slider("Select Document ID", options=range(len(pif_list)))
21
+ document_id = pif_list[doc_index-1]
22
+ st.write("Current Document ID: ", document_id)
23
+ # document_id = st.selectbox("Select Document ID", options=pif_list)
24
+ pages = [int(i.split('-')[-1].split('.')[0]) for i in glob(f"{image_path}{document_id}*.png")]
25
+ page_number = st.number_input("Page Number", min_value=1, max_value=len(pages), step=1, value=1)
26
+ df_tmp = pd.read_csv(glob(f"{auto_csv_path}*{document_id}*auto.csv")[0])
27
+ reason_for_onhold = st.text_area("Reason for On-hold: ", value="Add a reason for onhold column into inbound CSV")
28
+ add_comment = st.text_area("Total Number of BMs: ", value=df_tmp.shape[0])
29
+
30
+ # Display Image Panel
31
+ with col2:
32
+ st.write("### Display Image")
33
+ im_path = load_image(image_path, document_id, page_number)
34
+ if im_path:
35
+ st.image(im_path)
36
+ else:
37
+ st.write("Image not found")
38
+
39
+ # Display DataFrame Panel
40
+ with col3:
41
+ st.write("### Display DataFrame")
42
+ df = load_dataframe(auto_csv_path, document_id, page_number)
43
+ if df is not None:
44
+ columns_to_display = st.multiselect("Select Columns to Display", df.columns)
45
+ if len(columns_to_display) > 0:
46
+ st.write(df[columns_to_display])
47
+
48
+ # Input area for comments and suggestions
49
+ st.subheader("Add Comments on NLP Output")
50
+ reco_list = ['Regular NLP working', 'Wrong Report type', 'Report not Found',
51
+ 'Dev work required', 'NLP not supported (non 5 labs)',
52
+ 'Limited Regular NLP Support and Manual NLP (ROI) is working',
53
+ 'Poor quality report- NLP not supported']
54
+ # comment = st.text_area("Add your comment here")
55
+ comment = st.selectbox("Select Comment", options=reco_list)
56
+ add_comment = st.text_area("Add your additional comment here")
57
+
58
+ # Save comments and suggestions to CSV when submitted
59
+ if st.button("Submit"):
60
+ global comments_df
61
+ data = {
62
+ "Document ID": [document_id],
63
+ "Page": [page_number],
64
+ "Comment": [comment],
65
+ "Additional Comment": [add_comment]
66
+ }
67
+ comments_df = comments_df.append(pd.DataFrame(data), ignore_index=True)
68
+ comments_csv = "comments.csv"
69
+ if os.path.exists(comments_csv):
70
+ comments_df.to_csv(comments_csv, mode="a", header=False, index=False)
71
+ else:
72
+ comments_df.to_csv(comments_csv, index=False)
73
+
74
+ else:
75
+ st.write("No columns selected")
76
+ else:
77
+ st.write("DataFrame not found")