Spaces:
Running
Running
Update doc_searcher.py
Browse files- doc_searcher.py +34 -12
doc_searcher.py
CHANGED
|
@@ -19,18 +19,27 @@ class DocSearcher:
|
|
| 19 |
dense_query = self.dense_model.encode(text).tolist()
|
| 20 |
sparse_query = next(self.sparse_model.query_embed(text))
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
if type == 0 and law_type is not None:
|
| 36 |
filter = Filter(
|
|
@@ -54,6 +63,19 @@ class DocSearcher:
|
|
| 54 |
)
|
| 55 |
]
|
| 56 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
else:
|
| 58 |
return []
|
| 59 |
|
|
|
|
| 19 |
dense_query = self.dense_model.encode(text).tolist()
|
| 20 |
sparse_query = next(self.sparse_model.query_embed(text))
|
| 21 |
|
| 22 |
+
if type == 0:
|
| 23 |
+
prefetch = [
|
| 24 |
+
models.Prefetch(
|
| 25 |
+
query=dense_query,
|
| 26 |
+
using=DENSE_MODEL,
|
| 27 |
+
limit=100
|
| 28 |
+
),
|
| 29 |
+
models.Prefetch(
|
| 30 |
+
query=models.SparseVector(**sparse_query.as_object()),
|
| 31 |
+
using=SPARSE_MODEL,
|
| 32 |
+
limit=100
|
| 33 |
+
)
|
| 34 |
+
]
|
| 35 |
+
else:
|
| 36 |
+
prefetch = [
|
| 37 |
+
models.Prefetch(
|
| 38 |
+
query=dense_query,
|
| 39 |
+
using=DENSE_MODEL,
|
| 40 |
+
limit=100
|
| 41 |
+
)
|
| 42 |
+
]
|
| 43 |
|
| 44 |
if type == 0 and law_type is not None:
|
| 45 |
filter = Filter(
|
|
|
|
| 63 |
)
|
| 64 |
]
|
| 65 |
)
|
| 66 |
+
elif type == 1 and law_type is not None:
|
| 67 |
+
filter = Filter(
|
| 68 |
+
must=[
|
| 69 |
+
FieldCondition(
|
| 70 |
+
key="tip_dokumenta",
|
| 71 |
+
match=MatchValue(value=type)
|
| 72 |
+
),
|
| 73 |
+
FieldCondition(
|
| 74 |
+
key="vrsta_akta",
|
| 75 |
+
match=MatchValue(value=law_type)
|
| 76 |
+
),
|
| 77 |
+
]
|
| 78 |
+
)
|
| 79 |
else:
|
| 80 |
return []
|
| 81 |
|