James McCool commited on
Commit
ee0824a
·
1 Parent(s): 9b0d8bc

Improve name matching logic in app.py: enhance the match validation by adding a threshold check and retain original names for unmatched entries, along with debug output for better visibility into the matching process.

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -169,14 +169,20 @@ with tab1:
169
  limit=1 # Only get the best match
170
  )
171
 
172
- # Convert matches to dictionary
173
- match_dict = {name: name_id_map[match[0][0]] if match else name
174
- for name, match in zip(names, matches)}
 
 
 
175
 
176
  # Apply the matches
177
  projections['upload_match'] = projections['player_names'].map(match_dict)
178
  st.session_state['export_dict'] = dict(zip(projections['player_names'], projections['upload_match']))
179
- st.write(st.session_state['export_dict'])
 
 
 
180
 
181
  st.session_state['origin_portfolio'] = st.session_state['portfolio'].copy()
182
 
 
169
  limit=1 # Only get the best match
170
  )
171
 
172
+ match_dict = {}
173
+ for name, match_list in zip(names, matches):
174
+ if match_list and match_list[0][1] >= 85: # Check if we have a match and it meets threshold
175
+ match_dict[name] = name_id_map[match_list[0][0]] # Use the matched name to get the ID
176
+ else:
177
+ match_dict[name] = name # Keep original name if no good match
178
 
179
  # Apply the matches
180
  projections['upload_match'] = projections['player_names'].map(match_dict)
181
  st.session_state['export_dict'] = dict(zip(projections['player_names'], projections['upload_match']))
182
+ # Optional: Print some debug info
183
+ print("Sample of matches:")
184
+ for name, match in list(match_dict.items())[:5]:
185
+ print(f"{name} -> {match}")
186
 
187
  st.session_state['origin_portfolio'] = st.session_state['portfolio'].copy()
188