contextl 1.2.25 → 1.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/python/query_engine.py +7 -5
package/package.json
CHANGED
package/python/query_engine.py
CHANGED
|
@@ -96,7 +96,7 @@ def _keyword_score(query_terms: list[str], file_path: str, idf_weights: dict[str
|
|
|
96
96
|
for term in query_terms:
|
|
97
97
|
# Exact match on filename
|
|
98
98
|
if term in filename_toks:
|
|
99
|
-
score +=
|
|
99
|
+
score += 4.0 * idf_weights.get(term, 1.0) # Massive signal
|
|
100
100
|
matched.append(term)
|
|
101
101
|
# Substring or abbreviation match on filename
|
|
102
102
|
elif len(term) >= 2 and any(
|
|
@@ -104,11 +104,11 @@ def _keyword_score(query_terms: list[str], file_path: str, idf_weights: dict[str
|
|
|
104
104
|
all(c in iter(ft) for c in term)
|
|
105
105
|
for ft in filename_toks
|
|
106
106
|
):
|
|
107
|
-
score +=
|
|
107
|
+
score += 3.0 * idf_weights.get(term, 1.0)
|
|
108
108
|
matched.append(term)
|
|
109
109
|
# Exact match on path
|
|
110
110
|
elif term in path_toks:
|
|
111
|
-
score += 0
|
|
111
|
+
score += 2.0 * idf_weights.get(term, 1.0) # Strong signal
|
|
112
112
|
if term not in matched:
|
|
113
113
|
matched.append(term)
|
|
114
114
|
# Substring or abbreviation match on path
|
|
@@ -117,14 +117,16 @@ def _keyword_score(query_terms: list[str], file_path: str, idf_weights: dict[str
|
|
|
117
117
|
all(c in iter(pt) for c in term)
|
|
118
118
|
for pt in path_toks
|
|
119
119
|
):
|
|
120
|
-
score +=
|
|
120
|
+
score += 1.5 * idf_weights.get(term, 1.0)
|
|
121
121
|
if term not in matched:
|
|
122
122
|
matched.append(term)
|
|
123
123
|
|
|
124
124
|
# Normalize by max possible score (sum of all IDFs)
|
|
125
125
|
max_score = sum(idf_weights.get(t, 1.0) for t in query_terms)
|
|
126
126
|
if max_score > 0:
|
|
127
|
-
|
|
127
|
+
base_normalized = min(1.0, sum(idf_weights.get(t, 1.0) for t in matched) / max_score)
|
|
128
|
+
bonus = score - sum(idf_weights.get(t, 1.0) for t in matched)
|
|
129
|
+
score = base_normalized + max(0, bonus)
|
|
128
130
|
|
|
129
131
|
return score, matched
|
|
130
132
|
|