leavoigt commited on
Commit
79e4a33
1 Parent(s): 4a8d0fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -100
app.py CHANGED
@@ -1,11 +1,4 @@
1
- #import appStore.target as target_extraction
2
- #import appStore.netzero as netzero
3
- #import appStore.sector as sector
4
- #import appStore.adapmit as adapmit
5
- #import appStore.ghg as ghg
6
- #import appStore.policyaction as policyaction
7
- #import appStore.conditional as conditional
8
- #import appStore.indicator as indicator
9
  import appStore.doc_processing as processing
10
  from utils.uploadAndExample import add_upload
11
  from PIL import Image
@@ -48,107 +41,49 @@ with st.expander("ℹ️ - About this app", expanded=False):
48
  Place holder \
49
  Place holder
50
  """)
51
- #c1, c2, c3 = st.columns([12,1,10])
52
- #with c1:
53
- #image = Image.open('docStore/img/flow.jpg')
54
- #st.image(image)
55
- #with c3:
56
- #st.write("""
57
- # What happens in the background?
58
 
59
- # - Step 1: Once the document is provided to app, it undergoes *Pre-processing*.\
60
- # In this step the document is broken into smaller paragraphs \
61
- # (based on word/sentence count).
62
- # - Step 2: The paragraphs are fed to **Target Classifier** which detects if
63
- # the paragraph contains any *Target* related information or not.
64
- # - Step 3: The paragraphs which are detected containing some target \
65
- # related information are then fed to multiple classifier to enrich the
66
- # Information Extraction.
67
 
68
- # The Step 2 and 3 are repated then similarly for Action and Policies & Plans.
69
- # """)
70
 
71
- #st.write("")
72
 
73
 
74
- apps = [processing.app, target_extraction.app, netzero.app, ghg.app,
75
- policyaction.app, conditional.app, sector.app, adapmit.app,indicator.app]
76
 
77
- multiplier_val =1/len(apps)
78
- if st.button("Analyze Document"):
79
- prg = st.progress(0.0)
80
- for i,func in enumerate(apps):
81
- func()
82
- prg.progress((i+1)*multiplier_val)
83
 
84
 
85
- if 'key1' in st.session_state:
86
- with st.sidebar:
87
- topic = st.radio(
88
- "Which category you want to explore?",
89
- ('Target', 'Action', 'Policies/Plans'))
90
 
91
- if topic == 'Target':
92
- target_extraction.target_display()
93
- elif topic == 'Action':
94
- policyaction.action_display()
95
- else:
96
- policyaction.policy_display()
97
- # st.write(st.session_state.key1)
98
 
99
- #st.title("Identify references to vulnerable groups.")
100
 
101
- #st.write("""Vulnerable groups encompass various communities and individuals who are disproportionately affected by the impacts of climate change
102
- #due to their socioeconomic status, geographical location, or inherent characteristics. By incorporating the needs and perspectives of these groups
103
- #into national climate policies, governments can ensure equitable outcomes, promote social justice, and strive to build resilience within the most marginalized populations,
104
- #fostering a more sustainable and inclusive society as we navigate the challenges posed by climate change.This app allows you to identify whether a text contains any
105
- #references to vulnerable groups, for example when talking about policy documents.""")
106
-
107
- # Document upload
108
- #uploaded_file = st.file_uploader("Upload your file here")
109
-
110
- # Create text input box
111
- #input_text = st.text_area(label='Please enter your text here', value="This policy has been implemented to support women.")
112
-
113
- #st.write('Prediction:', model(input_text))
114
-
115
- ######################################### Model #########################################################
116
-
117
- # Load the model
118
- #model = SetFitModel.from_pretrained("leavoigt/vulnerable_groups")
119
-
120
- # Define the classes
121
- #id2label = {
122
- # 0: 'Agricultural communities',
123
- # 1: 'Children and Youth',
124
- # 2: 'Coastal communities',
125
- # 3: 'Drought-prone regions',
126
- # 4: 'Economically disadvantaged communities',
127
- # 5: 'Elderly population',
128
- # 6: 'Ethnic minorities and indigenous people',
129
- # 7: 'Informal sector workers',
130
- # 8: 'Migrants and Refugees',
131
- # 9: 'Other',
132
- # 10: 'People with Disabilities',
133
- # 11: 'Rural populations',
134
- # 12: 'Sexual minorities (LGBTQI+)',
135
- # 13: 'Urban populations',
136
- # 14: 'Women'}
137
-
138
-
139
- ### Process document to paragraphs
140
- # Source: https://blog.jcharistech.com/2021/01/21/how-to-save-uploaded-files-to-directory-in-streamlit-apps/
141
-
142
- # Store uploaded file temporarily in directory to get file path (necessary for processing)
143
- # def save_uploadedfile(upl_file):
144
- # with open(os.path.join("tempDir",upl_file.name),"wb") as f:
145
- # f.write(upl_file.getbuffer())
146
- # return st.success("Saved File:{} to tempDir".format(upl_file.name))
147
-
148
- # if uploaded_file is not None:
149
- # # Save the file
150
- # file_details = {"FileName": uploaded_file.name, "FileType": uploaded_file.type}
151
- # save_uploadedfile(uploaded_file)
152
-
153
- # #Get the file path
154
 
 
1
+ #import appStore.identifier as target_identifier
 
 
 
 
 
 
 
2
  import appStore.doc_processing as processing
3
  from utils.uploadAndExample import add_upload
4
  from PIL import Image
 
41
  Place holder \
42
  Place holder
43
  """)
44
+
45
+ st.write("""
46
+ What happens in the background?
 
 
 
 
47
 
48
+ - Step 1: Once the document is provided to app, it undergoes *Pre-processing*.\
49
+ In this step the document is broken into smaller paragraphs \
50
+ (based on word/sentence count).
51
+ - Step 2: The paragraphs are fed to **Target Classifier** which detects if
52
+ the paragraph contains any *Target* related information or not.
53
+ - Step 3: The paragraphs which are detected containing some target \
54
+ related information are then fed to multiple classifier to enrich the
55
+ Information Extraction.
56
 
57
+ The Step 2 and 3 are repated then similarly for Action and Policies & Plans.
58
+ """)
59
 
60
+ st.write("")
61
 
62
 
63
+ # apps = [processing.app, target_extraction.app, netzero.app, ghg.app,
64
+ # policyaction.app, conditional.app, sector.app, adapmit.app,indicator.app]
65
 
66
+ # multiplier_val =1/len(apps)
67
+ # if st.button("Analyze Document"):
68
+ # prg = st.progress(0.0)
69
+ # for i,func in enumerate(apps):
70
+ # func()
71
+ # prg.progress((i+1)*multiplier_val)
72
 
73
 
74
+ # if 'key1' in st.session_state:
75
+ # with st.sidebar:
76
+ # topic = st.radio(
77
+ # "Which category you want to explore?",
78
+ # ('Target', 'Action', 'Policies/Plans'))
79
 
80
+ # if topic == 'Target':
81
+ # target_extraction.target_display()
82
+ # elif topic == 'Action':
83
+ # policyaction.action_display()
84
+ # else:
85
+ # policyaction.policy_display()
86
+ # # st.write(st.session_state.key1)
87
 
 
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89