Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,350 +1,213 @@
|
|
1 |
# MetaDiscovery Agent - LOC API with Enhanced Completeness and Quality Analysis
|
2 |
import requests
|
3 |
import pandas as pd
|
4 |
-
import numpy as np
|
5 |
import streamlit as st
|
6 |
-
import matplotlib
|
7 |
import plotly.express as px
|
8 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
9 |
from sklearn.metrics.pairwise import cosine_similarity
|
|
|
10 |
|
11 |
-
#
|
12 |
st.markdown("""
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
border-radius: 12px;
|
54 |
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
55 |
-
font-size: 0.95rem;
|
56 |
-
line-height: 1.5;
|
57 |
-
}
|
58 |
-
.block-container {
|
59 |
-
background-color: gray !important;
|
60 |
-
color: #1A1A1A !important;
|
61 |
-
padding-left: 2rem !important;
|
62 |
-
padding-right: 2rem !important;
|
63 |
-
box-shadow: none !important;
|
64 |
-
}
|
65 |
-
html, body, [data-testid="stApp"] {
|
66 |
-
background-color: #1A1A1A !important;
|
67 |
-
}
|
68 |
-
.custom-table {
|
69 |
-
background-color: #D3D3D3;
|
70 |
-
color: #1A1A1A;
|
71 |
-
font-family: monospace;
|
72 |
-
padding: 1rem;
|
73 |
-
border-radius: 8px;
|
74 |
-
overflow-x: auto;
|
75 |
-
white-space: pre;
|
76 |
-
border: 1px solid #ccc;
|
77 |
-
|
78 |
-
}
|
79 |
-
.sidebar-stats {
|
80 |
-
color: lightgray !important;
|
81 |
-
font-size: 1.1rem !important;
|
82 |
-
margin-top: 1.5rem;
|
83 |
-
font-weight: 600;
|
84 |
-
}
|
85 |
-
.sidebar-contrast-block {
|
86 |
-
background-color: #2b2b2b !important; /* Slightly lighter than #1A1A1A */
|
87 |
-
padding: 1.25rem;
|
88 |
-
border-radius: 10px;
|
89 |
-
margin-top: 1.5rem;
|
90 |
-
}
|
91 |
-
|
92 |
</style>
|
93 |
""", unsafe_allow_html=True)
|
94 |
|
95 |
-
#
|
96 |
st.image("https://cdn-uploads.huggingface.co/production/uploads/67351c643fe51cb1aa28f2e5/7ThcAOjbuM8ajrP85bGs4.jpeg", use_container_width=True)
|
97 |
-
|
98 |
-
# Streamlit app header
|
99 |
st.title("MetaDiscovery Agent for Library of Congress Collections")
|
100 |
-
st.markdown(""
|
101 |
-
This tool connects to the LOC API, retrieves metadata from a selected collection, and performs
|
102 |
-
an analysis of metadata completeness, suggests enhancements, and identifies authority gaps.
|
103 |
-
""")
|
104 |
|
105 |
-
#
|
106 |
collections = {
|
107 |
"American Revolutionary War Maps": "american+revolutionary+war+maps",
|
108 |
"Civil War Maps": "civil+war+maps",
|
109 |
"Women's Suffrage": "women+suffrage",
|
110 |
"World War I Posters": "world+war+posters"
|
111 |
}
|
112 |
-
|
113 |
-
# Sidebar for selecting collection
|
114 |
-
#st.sidebar.markdown("## Settings")
|
115 |
-
|
116 |
-
# Create empty metadata_df variable to ensure it exists before checking
|
117 |
-
metadata_df = pd.DataFrame()
|
118 |
-
|
119 |
-
# Add a key to the selectbox to ensure it refreshes properly
|
120 |
selected = st.sidebar.selectbox("Select a collection", list(collections.keys()), key="collection_selector")
|
121 |
search_query = collections[selected]
|
122 |
-
|
123 |
-
# Define the collection URL
|
124 |
collection_url = f"https://www.loc.gov/search/?q={search_query}&fo=json"
|
125 |
|
126 |
-
#
|
127 |
-
stats_placeholder = st.sidebar.
|
|
|
128 |
|
129 |
-
#
|
130 |
-
completeness_placeholder = st.sidebar.empty()
|
131 |
-
|
132 |
-
# Helpful Resources (styled and moved below dropdown)
|
133 |
-
st.sidebar.markdown("### Helpful Resources", unsafe_allow_html=True)
|
134 |
-
# Helpful Resources styled section
|
135 |
-
# 3. Helpful Resources Section (Fixed, under Completeness)
|
136 |
st.sidebar.markdown("""
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
.sidebar-links a:hover {
|
148 |
-
text-decoration: underline !important;
|
149 |
-
}
|
150 |
-
</style>
|
151 |
-
<div class="sidebar-section">
|
152 |
-
<h3>π Helpful Resources</h3>
|
153 |
-
<div class="sidebar-links">
|
154 |
-
<ul style='padding-left: 1em'>
|
155 |
-
<li><a href="https://www.loc.gov/apis/" target="_blank">LOC API Info</a></li>
|
156 |
-
<li><a href="https://www.loc.gov/" target="_blank">Library of Congress Homepage</a></li>
|
157 |
-
<li><a href="https://www.loc.gov/collections/" target="_blank">LOC Digital Collections</a></li>
|
158 |
-
<li><a href="https://www.loc.gov/marc/" target="_blank">MARC Metadata Standards</a></li>
|
159 |
-
<li><a href="https://labs.loc.gov/about-labs/digital-strategy/" target="_blank">LOC Digital Strategy</a></li>
|
160 |
-
</ul>
|
161 |
-
</div>
|
162 |
-
</div>
|
163 |
""", unsafe_allow_html=True)
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
<
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
try:
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
completeness_table = completeness_df.set_index("Field")
|
275 |
-
|
276 |
-
# FILL THE PLACEHOLDER created earlier
|
277 |
-
|
278 |
-
# FILL THE PLACEHOLDER created earlier
|
279 |
-
with completeness_placeholder:
|
280 |
-
st.markdown("""
|
281 |
-
<div style='
|
282 |
-
background-color: #2e2e2e;
|
283 |
-
padding: 1.2rem;
|
284 |
-
border-radius: 10px;
|
285 |
-
margin-top: 1.5rem;
|
286 |
-
color: lightgray;
|
287 |
-
'>
|
288 |
-
<h4 style='margin-bottom: 1rem;'>π Field Completeness Breakdown</h4>
|
289 |
-
""", unsafe_allow_html=True)
|
290 |
-
|
291 |
-
st.dataframe(
|
292 |
-
completeness_table.style.background_gradient(cmap="Greens").format("{:.1f}%"),
|
293 |
-
use_container_width=True,
|
294 |
-
height=240
|
295 |
-
)
|
296 |
-
|
297 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
298 |
-
|
299 |
-
completeness_table = completeness.round(1).to_frame(name="Completeness (%)")
|
300 |
-
|
301 |
-
# Then continue plotting in main panel
|
302 |
-
fig = px.bar(completeness_df, x="Field", y="Completeness (%)", title="Metadata Completeness by Field")
|
303 |
-
st.plotly_chart(fig)
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
# Identify incomplete records
|
308 |
-
incomplete_mask = metadata_df.map(is_incomplete).any(axis=1)
|
309 |
-
incomplete_records = metadata_df[incomplete_mask]
|
310 |
-
|
311 |
-
st.subheader("β¨ Suggested Metadata Enhancements")
|
312 |
-
|
313 |
-
incomplete_with_desc = incomplete_records[incomplete_records['description'].notnull()]
|
314 |
-
reference_df = metadata_df[metadata_df['subject'].notnull() & metadata_df['description'].notnull()]
|
315 |
-
tfidf = TfidfVectorizer(stop_words='english')
|
316 |
-
|
317 |
-
if len(incomplete_with_desc) > 1 and len(reference_df) > 1:
|
318 |
-
try:
|
319 |
-
suggestions = []
|
320 |
-
tfidf_matrix = tfidf.fit_transform(reference_df['description'])
|
321 |
-
|
322 |
-
for idx, row in incomplete_with_desc.iterrows():
|
323 |
-
if pd.isna(row['subject']) and pd.notna(row['description']):
|
324 |
-
desc_vec = tfidf.transform([str(row['description'])])
|
325 |
-
sims = cosine_similarity(desc_vec, tfidf_matrix).flatten()
|
326 |
-
top_idx = sims.argmax()
|
327 |
-
suggested_subject = reference_df.iloc[top_idx]['subject']
|
328 |
-
if pd.notna(suggested_subject) and suggested_subject:
|
329 |
-
suggestions.append((row['title'], suggested_subject))
|
330 |
-
|
331 |
-
if suggestions:
|
332 |
-
suggestions_df = pd.DataFrame(suggestions, columns=["Title", "Suggested Subject"])
|
333 |
-
st.markdown("<div class='custom-table'>" + suggestions_df.to_markdown(index=False) + "</div>", unsafe_allow_html=True)
|
334 |
-
else:
|
335 |
-
st.markdown("""
|
336 |
-
<div class='custom-table'>
|
337 |
-
<b>No metadata enhancement suggestions available.</b>
|
338 |
-
</div>
|
339 |
-
""", unsafe_allow_html=True)
|
340 |
-
|
341 |
-
except Exception as e:
|
342 |
-
st.error(f"Error generating metadata suggestions: {e}")
|
343 |
-
else:
|
344 |
-
st.markdown("""
|
345 |
-
<div class='custom-table'>
|
346 |
-
<b>Not enough descriptive data to generate metadata suggestions.</b>
|
347 |
-
</div>
|
348 |
-
""", unsafe_allow_html=True)
|
349 |
else:
|
350 |
-
st.
|
|
|
|
|
|
|
|
1 |
# MetaDiscovery Agent - LOC API with Enhanced Completeness and Quality Analysis
|
2 |
import requests
|
3 |
import pandas as pd
|
|
|
4 |
import streamlit as st
|
|
|
5 |
import plotly.express as px
|
6 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
7 |
from sklearn.metrics.pairwise import cosine_similarity
|
8 |
+
import matplotlib
|
9 |
|
10 |
+
# --- CUSTOM CSS ---
|
11 |
st.markdown("""
|
12 |
+
<style>
|
13 |
+
html, body, [data-testid="stApp"] {
|
14 |
+
background-color: #1A1A1A !important;
|
15 |
+
}
|
16 |
+
.block-container {
|
17 |
+
background-color: gray !important;
|
18 |
+
color: #1A1A1A !important;
|
19 |
+
padding-left: 2rem !important;
|
20 |
+
padding-right: 2rem !important;
|
21 |
+
}
|
22 |
+
section[data-testid="stSidebar"] > div:first-child {
|
23 |
+
background-color: #1A1A1A !important;
|
24 |
+
color: #FFFFFF !important;
|
25 |
+
padding: 2rem 1.5rem;
|
26 |
+
border-radius: 12px;
|
27 |
+
}
|
28 |
+
.sidebar-contrast-block {
|
29 |
+
background-color: #2b2b2b !important;
|
30 |
+
padding: 1rem;
|
31 |
+
border-radius: 10px;
|
32 |
+
margin-top: 1.5rem;
|
33 |
+
color: lightgray;
|
34 |
+
}
|
35 |
+
.custom-table {
|
36 |
+
background-color: #D3D3D3;
|
37 |
+
color: #1A1A1A;
|
38 |
+
font-family: monospace;
|
39 |
+
padding: 1rem;
|
40 |
+
border-radius: 8px;
|
41 |
+
overflow-x: auto;
|
42 |
+
white-space: pre;
|
43 |
+
border: 1px solid #ccc;
|
44 |
+
}
|
45 |
+
.sidebar-links a {
|
46 |
+
color: lightgray !important;
|
47 |
+
text-decoration: none !important;
|
48 |
+
}
|
49 |
+
.sidebar-links a:hover {
|
50 |
+
text-decoration: underline !important;
|
51 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
</style>
|
53 |
""", unsafe_allow_html=True)
|
54 |
|
55 |
+
# --- HEADER ---
|
56 |
st.image("https://cdn-uploads.huggingface.co/production/uploads/67351c643fe51cb1aa28f2e5/7ThcAOjbuM8ajrP85bGs4.jpeg", use_container_width=True)
|
|
|
|
|
57 |
st.title("MetaDiscovery Agent for Library of Congress Collections")
|
58 |
+
st.markdown("This tool connects to the LOC API, retrieves metadata from a selected collection, and performs an analysis of metadata completeness, suggests enhancements, and identifies authority gaps.")
|
|
|
|
|
|
|
59 |
|
60 |
+
# --- COLLECTION SETUP ---
|
61 |
collections = {
|
62 |
"American Revolutionary War Maps": "american+revolutionary+war+maps",
|
63 |
"Civil War Maps": "civil+war+maps",
|
64 |
"Women's Suffrage": "women+suffrage",
|
65 |
"World War I Posters": "world+war+posters"
|
66 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
selected = st.sidebar.selectbox("Select a collection", list(collections.keys()), key="collection_selector")
|
68 |
search_query = collections[selected]
|
|
|
|
|
69 |
collection_url = f"https://www.loc.gov/search/?q={search_query}&fo=json"
|
70 |
|
71 |
+
# --- PLACEHOLDERS FOR SIDEBAR BLOCKS ---
|
72 |
+
stats_placeholder = st.sidebar.container()
|
73 |
+
completeness_placeholder = st.sidebar.container()
|
74 |
|
75 |
+
# --- HELPFUL RESOURCES ---
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
st.sidebar.markdown("""
|
77 |
+
<div class="sidebar-contrast-block">
|
78 |
+
<h4>π Helpful Resources</h4>
|
79 |
+
<ul class="sidebar-links">
|
80 |
+
<li><a href="https://www.loc.gov/apis/" target="_blank">LOC API Info</a></li>
|
81 |
+
<li><a href="https://www.loc.gov/" target="_blank">Library of Congress Homepage</a></li>
|
82 |
+
<li><a href="https://www.loc.gov/collections/" target="_blank">LOC Digital Collections</a></li>
|
83 |
+
<li><a href="https://www.loc.gov/marc/" target="_blank">MARC Metadata Standards</a></li>
|
84 |
+
<li><a href="https://labs.loc.gov/about-labs/digital-strategy/" target="_blank">LOC Digital Strategy</a></li>
|
85 |
+
</ul>
|
86 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
""", unsafe_allow_html=True)
|
88 |
|
89 |
+
# Define Utility Functions
|
90 |
+
def is_incomplete(value):
|
91 |
+
return pd.isna(value) or value in ["", "N/A", "null", None]
|
92 |
+
|
93 |
+
def is_valid_date(value):
|
94 |
+
try:
|
95 |
+
pd.to_datetime(value)
|
96 |
+
return True
|
97 |
+
except:
|
98 |
+
return False
|
99 |
+
|
100 |
+
# Fetch data from LOC API
|
101 |
+
def fetch_loc_data(collection_url):
|
102 |
+
headers = {"User-Agent": "Mozilla/5.0"}
|
103 |
+
try:
|
104 |
+
response = requests.get(collection_url, headers=headers)
|
105 |
+
response.raise_for_status()
|
106 |
+
data = response.json()
|
107 |
+
if "results" in data:
|
108 |
+
return data["results"]
|
109 |
+
elif "items" in data:
|
110 |
+
return data["items"]
|
111 |
+
else:
|
112 |
+
return []
|
113 |
+
except Exception as e:
|
114 |
+
st.error(f"API Error: {e}")
|
115 |
+
return []
|
116 |
+
|
117 |
+
# Transform Records
|
118 |
+
def transform_records(records):
|
119 |
+
items = []
|
120 |
+
for record in records:
|
121 |
+
if isinstance(record, dict):
|
122 |
+
description = record.get("description", "")
|
123 |
+
if isinstance(description, list):
|
124 |
+
description = " ".join(map(str, description))
|
125 |
+
item = {
|
126 |
+
"id": record.get("id", ""),
|
127 |
+
"title": record.get("title", ""),
|
128 |
+
"date": record.get("date", ""),
|
129 |
+
"subject": ", ".join(record.get("subject", [])) if isinstance(record.get("subject"), list) else record.get("subject", ""),
|
130 |
+
"creator": record.get("creator", ""),
|
131 |
+
"description": description
|
132 |
+
}
|
133 |
+
items.append(item)
|
134 |
+
return pd.DataFrame(items)
|
135 |
+
|
136 |
+
# Render Main Application Sections
|
137 |
+
def render_main_sections(metadata_df, stats_placeholder, completeness_placeholder):
|
138 |
+
if not metadata_df.empty:
|
139 |
+
# Sidebar Quick Stats
|
140 |
+
incomplete_mask = metadata_df.map(is_incomplete).any(axis=1)
|
141 |
+
incomplete_count = incomplete_mask.sum()
|
142 |
+
|
143 |
+
total_fields = metadata_df.size
|
144 |
+
filled_fields = metadata_df.map(lambda x: not is_incomplete(x)).sum().sum()
|
145 |
+
overall_percent = (filled_fields / total_fields) * 100
|
146 |
+
|
147 |
+
# Completeness Table
|
148 |
+
completeness = metadata_df.map(lambda x: not is_incomplete(x)).mean() * 100
|
149 |
+
completeness_table = completeness.round(1).to_frame(name="Completeness (%)")
|
150 |
+
|
151 |
+
# Update sidebar placeholders
|
152 |
+
stats_html = f"""
|
153 |
+
<div class="sidebar-stats">
|
154 |
+
<h3 style="color: lightgray;">Quick Stats</h3>
|
155 |
+
<p style="color:lightgray;">Total Records: <b>{len(metadata_df)}</b></p>
|
156 |
+
<p style="color:lightgray;">Incomplete Records: <b>{incomplete_count}</b></p>
|
157 |
+
<p style="color:lightgray;">Overall Completeness: <b>{overall_percent:.1f}%</b></p>
|
158 |
+
</div>
|
159 |
+
"""
|
160 |
+
stats_placeholder.markdown(stats_html, unsafe_allow_html=True)
|
161 |
+
|
162 |
+
# Field Completeness Breakdown (inside contrast block)
|
163 |
+
with completeness_placeholder:
|
164 |
+
st.markdown("""
|
165 |
+
<div style='background-color:#2e2e2e; padding:1.25rem; border-radius:8px; margin-top:1.5rem;'>
|
166 |
+
<h4 style='color: lightgray;'>Field Completeness Breakdown</h4>
|
167 |
+
""", unsafe_allow_html=True)
|
168 |
+
|
169 |
+
st.dataframe(
|
170 |
+
completeness_table.style.background_gradient(cmap="Greens").format("{:.1f}%"),
|
171 |
+
use_container_width=True
|
172 |
+
)
|
173 |
+
|
174 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
175 |
+
|
176 |
+
# Main Body
|
177 |
+
st.subheader("π Retrieved Metadata Sample")
|
178 |
+
st.dataframe(metadata_df.head())
|
179 |
+
|
180 |
+
st.subheader("π Metadata Completeness Analysis")
|
181 |
+
completeness_df = completeness.reset_index()
|
182 |
+
completeness_df.columns = ["Field", "Completeness (%)"]
|
183 |
+
fig = px.bar(completeness_df, x="Field", y="Completeness (%)", title="Metadata Completeness by Field")
|
184 |
+
st.plotly_chart(fig)
|
185 |
+
|
186 |
+
# Suggested Metadata Enhancements
|
187 |
+
st.subheader("β¨ Suggested Metadata Enhancements")
|
188 |
+
incomplete_with_desc = metadata_df[incomplete_mask & metadata_df['description'].notna()]
|
189 |
+
reference_df = metadata_df[metadata_df['subject'].notna() & metadata_df['description'].notna()]
|
190 |
+
if not incomplete_with_desc.empty and not reference_df.empty:
|
191 |
try:
|
192 |
+
tfidf = TfidfVectorizer(stop_words='english')
|
193 |
+
tfidf_matrix = tfidf.fit_transform(reference_df['description'])
|
194 |
+
suggestions = []
|
195 |
+
for idx, row in incomplete_with_desc.iterrows():
|
196 |
+
desc_vec = tfidf.transform([row['description']])
|
197 |
+
sims = cosine_similarity(desc_vec, tfidf_matrix).flatten()
|
198 |
+
top_idx = sims.argmax()
|
199 |
+
suggested_subject = reference_df.iloc[top_idx]['subject']
|
200 |
+
if suggested_subject:
|
201 |
+
suggestions.append((row['title'], suggested_subject))
|
202 |
+
if suggestions:
|
203 |
+
suggestions_df = pd.DataFrame(suggestions, columns=["Title", "Suggested Subject"])
|
204 |
+
st.markdown("<div class='custom-table'>" + suggestions_df.to_markdown(index=False) + "</div>", unsafe_allow_html=True)
|
205 |
+
else:
|
206 |
+
st.info("No suggestions could be generated.")
|
207 |
+
except Exception as e:
|
208 |
+
st.error(f"Error generating suggestions: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
else:
|
210 |
+
st.info("Not enough data for metadata enhancement suggestions.")
|
211 |
+
else:
|
212 |
+
st.warning("No metadata found for the selected collection.")
|
213 |
+
|