Make search result calculation even more robust
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
v0.11.6
|
||||
=======
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
* Fixes more bugs with search not working in certain situations. (#253)
|
||||
|
||||
v0.11.5
|
||||
=======
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
__version__ = "0.11.5"
|
||||
__version__ = "0.11.6"
|
||||
|
@@ -181,21 +181,24 @@ class SearchResult:
|
||||
self, it: Dict[str, _S], transform: Callable[[_S], Tuple[Optional[str], ...]],
|
||||
) -> List[_S]:
|
||||
assert self.query
|
||||
all_results = sorted(
|
||||
(
|
||||
(
|
||||
max(
|
||||
self.similiarity_partial(t.lower())
|
||||
for t in transform(x)
|
||||
if t is not None
|
||||
),
|
||||
x,
|
||||
)
|
||||
for x in it.values()
|
||||
),
|
||||
key=lambda rx: rx[0],
|
||||
reverse=True,
|
||||
)
|
||||
all_results = []
|
||||
for value in it.values():
|
||||
transformed = transform(value)
|
||||
if any(t is None for t in transformed):
|
||||
continue
|
||||
|
||||
max_similarity = max(
|
||||
self.similiarity_partial(t.lower())
|
||||
for t in transformed
|
||||
if t is not None
|
||||
)
|
||||
if max_similarity < 60:
|
||||
continue
|
||||
|
||||
all_results.append((max_similarity, value))
|
||||
|
||||
all_results.sort(key=lambda rx: rx[0], reverse=True)
|
||||
|
||||
result: List[SearchResult._S] = []
|
||||
for ratio, x in all_results:
|
||||
if ratio >= 60 and len(result) < 20:
|
||||
|
Reference in New Issue
Block a user