kfahn commited on
Commit
c67c5c8
·
verified ·
1 Parent(s): abe7d90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -19
app.py CHANGED
@@ -47,28 +47,29 @@ image_sources = load_image_sources()
47
  # def get_image_url(image_type: str):
48
  # return image_sources.get(image_type, None)
49
 
50
- # def get_image_url(image_type: str):
51
- # """Finds the best match for the given image type using fuzzy matching."""
52
- # choices = list(image_sources.keys()) # Get all available keys
53
- # best_match, score = process.extractOne(image_type, choices) # Find closest match
54
 
55
- # if score > 70: # Set a threshold to ensure a reasonable match
56
- # return image_sources[best_match].get(image_type, None)
57
- # else:
58
- # return None # No good match found
 
59
 
60
- def get_image_url(image_type: str):
61
- """Finds an approximate match using simple substring matching."""
62
- image_type = image_type.lower()
63
 
64
- # Check for exact match first
65
- if image_type in image_sources:
66
- return image_sources[image_type]
67
-
68
- # If no exact match, look for a partial match
69
- for key in image_sources:
70
- if image_type in key.lower(): # Check if input is a substring of a key
71
- return image_sources[key]
72
 
73
  return None # No match found
74
  async def capture_screenshot(image_type: str):
 
47
  # def get_image_url(image_type: str):
48
  # return image_sources.get(image_type, None)
49
 
50
+ def get_image_url(image_type: str):
51
+ """Finds the best match for the given image type using fuzzy matching."""
52
+ choices = list(image_sources.keys()) # Get all available keys
53
+ best_match, score = process.extractOne(image_type, choices) # Find closest match
54
 
55
+ if score > 70: # Set a threshold to ensure a reasonable match
56
+ return image_sources[best_match]
57
+ else:
58
+ #return None # No good match found
59
+ return "https://editor.p5js.org/kfahn/full/2XD5Y8MiV"
60
 
61
+ # def get_image_url(image_type: str):
62
+ # """Finds an approximate match using simple substring matching."""
63
+ # image_type = image_type.lower()
64
 
65
+ # # Check for exact match first
66
+ # if image_type in image_sources:
67
+ # return image_sources[image_type]
68
+
69
+ # # If no exact match, look for a partial match
70
+ # for key in image_sources:
71
+ # if image_type in key.lower(): # Check if input is a substring of a key
72
+ # return image_sources[key]
73
 
74
  return None # No match found
75
  async def capture_screenshot(image_type: str):