CCockrum commited on
Commit
a1888b0
·
verified ·
1 Parent(s): b898bbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -210,11 +210,14 @@ if fetch_data:
210
  st.success("All records are complete!")
211
 
212
  st.subheader("Suggested Metadata Enhancements")
213
- incomplete_with_desc = incomplete_records[incomplete_records['description'].notnull()]
214
- reference_df = metadata_df[metadata_df['subject'].notnull() & metadata_df['description'].notnull()]
215
- tfidf = TfidfVectorizer(stop_words='english')
 
216
  suggestions = []
217
- for idx, row in incomplete_with_desc.iterrows():
 
 
218
  if pd.isna(row['subject']) and pd.notna(row['description']):
219
  desc_vec = tfidf.transform([str(row['description'])])
220
  sims = cosine_similarity(desc_vec, tfidf_matrix).flatten()
 
210
  st.success("All records are complete!")
211
 
212
  st.subheader("Suggested Metadata Enhancements")
213
+ incomplete_with_desc = incomplete_records[incomplete_records['description'].notnull()]
214
+ reference_df = metadata_df[metadata_df['subject'].notnull() & metadata_df['description'].notnull()]
215
+ tfidf = TfidfVectorizer(stop_words='english')
216
+ try:
217
  suggestions = []
218
+ tfidf = TfidfVectorizer(stop_words='english')
219
+ tfidf_matrix = tfidf.fit_transform(reference_df['description'])
220
+ for idx, row in incomplete_with_desc.iterrows():
221
  if pd.isna(row['subject']) and pd.notna(row['description']):
222
  desc_vec = tfidf.transform([str(row['description'])])
223
  sims = cosine_similarity(desc_vec, tfidf_matrix).flatten()