Update app.py
Browse files
app.py
CHANGED
|
@@ -152,19 +152,99 @@ def display_data(standard, version, selection):
|
|
| 152 |
|
| 153 |
# 4οΈβ£ UI ꡬμ±
|
| 154 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 155 |
gr.Markdown("# π Regulation Viewer")
|
| 156 |
|
| 157 |
with gr.Row():
|
| 158 |
-
standard_dd = gr.Dropdown(label="1. λ²κ· μ ν")
|
| 159 |
-
version_dd = gr.Dropdown(label="2. Version μ ν")
|
| 160 |
-
category_dd = gr.Dropdown(label="3. Category / Table μ ν")
|
| 161 |
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
if __name__ == "__main__":
|
| 170 |
demo.launch()
|
|
|
|
| 152 |
|
| 153 |
# 4οΈβ£ UI ꡬμ±
|
| 154 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 155 |
+
|
| 156 |
gr.Markdown("# π Regulation Viewer")
|
| 157 |
|
| 158 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
+
# π μΌμͺ½ μμ (κΈ°μ€ + λΉκ΅)
|
| 161 |
+
with gr.Column(scale=1):
|
| 162 |
+
|
| 163 |
+
# β
κΈ°μ€ λ²κ·
|
| 164 |
+
with gr.Group():
|
| 165 |
+
gr.Markdown("### π κΈ°μ€ λ²κ·")
|
| 166 |
+
base_standard = gr.Dropdown(label="Standard")
|
| 167 |
+
base_version = gr.Dropdown(label="Version")
|
| 168 |
+
base_category = gr.Dropdown(label="Category")
|
| 169 |
+
|
| 170 |
+
# β
λΉκ΅ λ²κ·
|
| 171 |
+
with gr.Group():
|
| 172 |
+
gr.Markdown("### π λΉκ΅ λ²κ·")
|
| 173 |
+
comp_standard = gr.Dropdown(label="Standard")
|
| 174 |
+
comp_version = gr.Dropdown(label="Version")
|
| 175 |
+
comp_category = gr.Dropdown(label="Category")
|
| 176 |
+
|
| 177 |
+
# π μ€λ₯Έμͺ½ κ²°κ³Ό μμ
|
| 178 |
+
with gr.Column(scale=3):
|
| 179 |
+
gr.Markdown("### π λ΄μ©")
|
| 180 |
+
output_df = gr.Dataframe(
|
| 181 |
+
wrap=True,
|
| 182 |
+
interactive=False,
|
| 183 |
+
datatype="html",
|
| 184 |
+
height=700
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
# π λ²νΌ (νλλ§)
|
| 188 |
+
with gr.Row():
|
| 189 |
+
search_btn = gr.Button("π μ‘°ν", size="lg")
|
| 190 |
+
|
| 191 |
+
# --------------------------
|
| 192 |
+
# π₯ λλ‘λ€μ΄ μ΄λ²€νΈ (κΈ°μ‘΄ μ μ§)
|
| 193 |
+
# --------------------------
|
| 194 |
+
demo.load(on_load, None, base_standard)
|
| 195 |
+
demo.load(on_load, None, comp_standard)
|
| 196 |
+
|
| 197 |
+
base_standard.change(update_version_dd, base_standard, base_version)
|
| 198 |
+
base_version.change(update_category_dd, [base_standard, base_version], base_category)
|
| 199 |
|
| 200 |
+
comp_standard.change(update_version_dd, comp_standard, comp_version)
|
| 201 |
+
comp_version.change(update_category_dd, [comp_standard, comp_version], comp_category)
|
| 202 |
+
|
| 203 |
+
# --------------------------
|
| 204 |
+
# π₯ μ‘°ν λ‘μ§ (ν΅μ¬)
|
| 205 |
+
# --------------------------
|
| 206 |
+
def unified_search(bs, bv, bc, cs, cv, cc):
|
| 207 |
+
|
| 208 |
+
# β
κΈ°μ€λ§ μ νλ κ²½μ°
|
| 209 |
+
if bs and bv and bc and not (cs and cv and cc):
|
| 210 |
+
return display_data(bs, bv, bc)
|
| 211 |
+
|
| 212 |
+
# β
κΈ°μ€ + λΉκ΅ λ λ€ μ νλ κ²½μ°
|
| 213 |
+
if bs and bv and bc and cs and cv and cc:
|
| 214 |
+
df_base = display_data(bs, bv, bc)
|
| 215 |
+
df_comp = display_data(cs, cv, cc)
|
| 216 |
+
|
| 217 |
+
# π₯ section κΈ°μ€ outer merge
|
| 218 |
+
if df_base is None or df_comp is None:
|
| 219 |
+
return None
|
| 220 |
+
|
| 221 |
+
try:
|
| 222 |
+
merged = pd.merge(
|
| 223 |
+
df_base,
|
| 224 |
+
df_comp,
|
| 225 |
+
on="section",
|
| 226 |
+
how="outer",
|
| 227 |
+
suffixes=("_base", "_comp")
|
| 228 |
+
)
|
| 229 |
+
|
| 230 |
+
return merged
|
| 231 |
+
|
| 232 |
+
except Exception as e:
|
| 233 |
+
return pd.DataFrame({"Error": [str(e)]})
|
| 234 |
+
|
| 235 |
+
# β μ무κ²λ μ μ ν
|
| 236 |
+
return pd.DataFrame({"Info": ["μ νμ μλ£νμΈμ"]})
|
| 237 |
+
|
| 238 |
+
# π λ²νΌ ν΄λ¦ μ μ€ν
|
| 239 |
+
search_btn.click(
|
| 240 |
+
unified_search,
|
| 241 |
+
[base_standard, base_version, base_category,
|
| 242 |
+
comp_standard, comp_version, comp_category],
|
| 243 |
+
output_df
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
if __name__ == "__main__":
|
| 247 |
+
demo.launch()
|
| 248 |
|
| 249 |
if __name__ == "__main__":
|
| 250 |
demo.launch()
|