MCPcopy Index your code
hub / github.com/geekcomputers/Python / find_application

Function find_application

JARVIS/apps.py:67–91  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

65
66
67def find_application(name):
68 wanted = normalize_text(name)
69 if not wanted:
70 return None
71 if wanted in BLOCKED_APPS or any(word in wanted.split() for word in DANGEROUS_WORDS):
72 return None
73 normalized_apps = [(app, normalize_text(app.get("name", ""))) for app in load_application_index()]
74 for app, app_name in normalized_apps:
75 if wanted == app_name:
76 return app
77 for app, app_name in normalized_apps:
78 if wanted in app_name.split():
79 return app
80 best = None
81 best_score = 0
82 for app, app_name in normalized_apps:
83 if not app_name:
84 continue
85 if len(wanted) >= 5 and (wanted in app_name or app_name in wanted):
86 return app
87 score = SequenceMatcher(None, wanted, app_name).ratio()
88 if score > best_score:
89 best = app
90 best_score = score
91 return best if best_score >= 0.72 else None
92
93
94def search_apps(query, limit=8):

Callers 1

open_applicationFunction · 0.85

Calls 3

normalize_textFunction · 0.85
load_application_indexFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected