Spaces:
Sleeping
Sleeping
PanagiotisMark
commited on
Commit
•
dcfabec
1
Parent(s):
23eb9e8
Update gradio_app.py
Browse files- gradio_app.py +17 -0
gradio_app.py
CHANGED
@@ -112,6 +112,23 @@ def preprocess_and_flatten(json_results, mode, meta_fields=None):
|
|
112 |
# Capitalize column names
|
113 |
dataframe_results.columns = [col.capitalize() for col in dataframe_results.columns]
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
return dataframe_results
|
116 |
|
117 |
# Define the functions to handle the inputs and outputs
|
|
|
112 |
# Capitalize column names
|
113 |
dataframe_results.columns = [col.capitalize() for col in dataframe_results.columns]
|
114 |
|
115 |
+
# Rename columns at the end of the function, conditionally if they exist
|
116 |
+
rename_columns = {}
|
117 |
+
|
118 |
+
# Conditionally add renaming based on the mode and column existence
|
119 |
+
if 'doc_id' in dataframe_results.columns:
|
120 |
+
rename_columns['doc_id'] = 'DOC ID'
|
121 |
+
|
122 |
+
if mode == 'claim_verification':
|
123 |
+
if 'doi' in dataframe_results.columns:
|
124 |
+
rename_columns['doi'] = 'DOI'
|
125 |
+
if 'sentence' in dataframe_results.columns:
|
126 |
+
rename_columns['sentence'] = 'Sentence'
|
127 |
+
|
128 |
+
# Apply the renaming if there are any columns to rename
|
129 |
+
if rename_columns:
|
130 |
+
dataframe_results.rename(columns=rename_columns, inplace=True)
|
131 |
+
|
132 |
return dataframe_results
|
133 |
|
134 |
# Define the functions to handle the inputs and outputs
|