cbrkit 0.19.0__tar.gz → 0.19.2__tar.gz
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.
- {cbrkit-0.19.0 → cbrkit-0.19.2}/PKG-INFO +1 -1
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/cli.py +13 -3
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/eval/_common.py +12 -8
- {cbrkit-0.19.0 → cbrkit-0.19.2}/pyproject.toml +1 -1
- {cbrkit-0.19.0 → cbrkit-0.19.2}/LICENSE +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/README.md +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/__init__.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/__main__.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/adaptation.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/api.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/eval/__init__.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/eval/_retrieval.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/helpers.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/loaders.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/py.typed +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/retrieval.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/__init__.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/_aggregator.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/_attribute_value.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/collections.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/generic.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/graphs/__init__.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/graphs/_astar.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/graphs/_isomorphism.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/graphs/_model.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/numbers.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/strings/__init__.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/sim/strings/taxonomy.py +0 -0
- {cbrkit-0.19.0 → cbrkit-0.19.2}/cbrkit/typing.py +0 -0
|
@@ -9,6 +9,8 @@ from enum import Enum
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from typing import Annotated
|
|
11
11
|
|
|
12
|
+
from cbrkit.helpers import unpack_sim
|
|
13
|
+
|
|
12
14
|
try:
|
|
13
15
|
import typer
|
|
14
16
|
from rich import print
|
|
@@ -33,7 +35,6 @@ class ParallelStrategy(str, Enum):
|
|
|
33
35
|
casebase = "casebase"
|
|
34
36
|
|
|
35
37
|
|
|
36
|
-
# py -m cbrkit retrieve data/cars-1k.csv data/cars-queries.csv examples.cars_retriever:retriever --output-path data/output.json
|
|
37
38
|
@app.command()
|
|
38
39
|
def retrieve(
|
|
39
40
|
casebase_path: Path,
|
|
@@ -41,6 +42,7 @@ def retrieve(
|
|
|
41
42
|
retriever: str,
|
|
42
43
|
search_path: Annotated[list[Path], typer.Option(default_factory=list)],
|
|
43
44
|
print_ranking: bool = True,
|
|
45
|
+
print_similarities: bool = False,
|
|
44
46
|
output_path: Path | None = None,
|
|
45
47
|
processes: int = 1,
|
|
46
48
|
parallel: ParallelStrategy = ParallelStrategy.queries,
|
|
@@ -62,10 +64,18 @@ def retrieve(
|
|
|
62
64
|
with output_path.with_suffix(".json").open("w") as fp:
|
|
63
65
|
json.dump(results_dict, fp, indent=2)
|
|
64
66
|
|
|
65
|
-
if print_ranking:
|
|
67
|
+
if print_ranking or print_similarities:
|
|
66
68
|
for query_name, result in results.items():
|
|
67
69
|
print(f"Query: {query_name}")
|
|
68
|
-
|
|
70
|
+
|
|
71
|
+
if print_ranking:
|
|
72
|
+
print(f"Ranking: {", ".join(map(str, result.ranking))}")
|
|
73
|
+
|
|
74
|
+
if print_similarities:
|
|
75
|
+
print("Similarities:")
|
|
76
|
+
for case_name, similarity in result.similarities.items():
|
|
77
|
+
print(f" {case_name}: {unpack_sim(similarity)}")
|
|
78
|
+
|
|
69
79
|
print()
|
|
70
80
|
|
|
71
81
|
|
|
@@ -44,16 +44,20 @@ def _correctness_completeness_single(
|
|
|
44
44
|
for i in range(len(case_keys)):
|
|
45
45
|
for j in range(i + 1, len(case_keys)):
|
|
46
46
|
idx1, idx2 = case_keys[i], case_keys[j]
|
|
47
|
-
|
|
47
|
+
qrel1, qrel2 = qrel[idx1], qrel[idx2]
|
|
48
48
|
|
|
49
|
-
if
|
|
50
|
-
|
|
51
|
-
run1, run2 = run_k[idx1], run_k[idx2]
|
|
49
|
+
if qrel1 != qrel2:
|
|
50
|
+
total_pairs += 1
|
|
52
51
|
|
|
53
|
-
if
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
if idx1 in run_k and idx2 in run_k:
|
|
53
|
+
run1, run2 = run_k[idx1], run_k[idx2]
|
|
54
|
+
|
|
55
|
+
if (qrel1 < qrel2 and run1 < run2) or (
|
|
56
|
+
qrel1 > qrel2 and run1 > run2
|
|
57
|
+
):
|
|
58
|
+
concordant_pairs += 1
|
|
59
|
+
else:
|
|
60
|
+
discordant_pairs += 1
|
|
57
61
|
|
|
58
62
|
correctness = (
|
|
59
63
|
(concordant_pairs - discordant_pairs) / (concordant_pairs + discordant_pairs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|