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
|
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], ...]],
|
self, it: Dict[str, _S], transform: Callable[[_S], Tuple[Optional[str], ...]],
|
||||||
) -> List[_S]:
|
) -> List[_S]:
|
||||||
assert self.query
|
assert self.query
|
||||||
all_results = sorted(
|
all_results = []
|
||||||
(
|
for value in it.values():
|
||||||
(
|
transformed = transform(value)
|
||||||
max(
|
if any(t is None for t in transformed):
|
||||||
self.similiarity_partial(t.lower())
|
continue
|
||||||
for t in transform(x)
|
|
||||||
if t is not None
|
max_similarity = max(
|
||||||
),
|
self.similiarity_partial(t.lower())
|
||||||
x,
|
for t in transformed
|
||||||
)
|
if t is not None
|
||||||
for x in it.values()
|
)
|
||||||
),
|
if max_similarity < 60:
|
||||||
key=lambda rx: rx[0],
|
continue
|
||||||
reverse=True,
|
|
||||||
)
|
all_results.append((max_similarity, value))
|
||||||
|
|
||||||
|
all_results.sort(key=lambda rx: rx[0], reverse=True)
|
||||||
|
|
||||||
result: List[SearchResult._S] = []
|
result: List[SearchResult._S] = []
|
||||||
for ratio, x in all_results:
|
for ratio, x in all_results:
|
||||||
if ratio >= 60 and len(result) < 20:
|
if ratio >= 60 and len(result) < 20:
|
||||||
|
Reference in New Issue
Block a user