Matheel 0.2.2__tar.gz → 0.3.1__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.
- {matheel-0.2.2 → matheel-0.3.1}/PKG-INFO +30 -19
- {matheel-0.2.2 → matheel-0.3.1}/README.md +22 -18
- {matheel-0.2.2 → matheel-0.3.1}/matheel/chunking.py +2 -15
- {matheel-0.2.2 → matheel-0.3.1}/matheel/cli.py +129 -2
- matheel-0.3.1/matheel/code_metrics.py +1400 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel/comparison_suite.py +36 -22
- {matheel-0.2.2 → matheel-0.3.1}/matheel/feature_weights.py +11 -29
- matheel-0.3.1/matheel/preprocessing.py +198 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel/similarity.py +540 -100
- {matheel-0.2.2 → matheel-0.3.1}/matheel.egg-info/PKG-INFO +30 -19
- {matheel-0.2.2 → matheel-0.3.1}/matheel.egg-info/requires.txt +7 -0
- {matheel-0.2.2 → matheel-0.3.1}/pyproject.toml +10 -2
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_chunking.py +8 -15
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_cli.py +66 -0
- matheel-0.3.1/tests/test_code_metrics.py +256 -0
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_comparison_suite.py +30 -7
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_feature_weights.py +18 -2
- matheel-0.3.1/tests/test_preprocessing.py +67 -0
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_real_models.py +4 -7
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_similarity.py +125 -82
- matheel-0.2.2/matheel/code_metrics.py +0 -417
- matheel-0.2.2/matheel/preprocessing.py +0 -88
- matheel-0.2.2/tests/test_code_metrics.py +0 -57
- matheel-0.2.2/tests/test_preprocessing.py +0 -21
- {matheel-0.2.2 → matheel-0.3.1}/LICENSE +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel/__init__.py +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel/model_routing.py +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel/vectors.py +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel.egg-info/SOURCES.txt +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel.egg-info/dependency_links.txt +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel.egg-info/entry_points.txt +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/matheel.egg-info/top_level.txt +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/setup.cfg +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_model_routing.py +0 -0
- {matheel-0.2.2 → matheel-0.3.1}/tests/test_vectors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: matheel
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Matheel: A CLI and Python package for source-code similarity detection.
|
|
5
5
|
Author: Fahad Ebrahim
|
|
6
6
|
License-Expression: CC-BY-NC-4.0
|
|
@@ -13,6 +13,9 @@ Requires-Dist: click<9,>=8
|
|
|
13
13
|
Requires-Dist: pandas<3.1,>=2.2
|
|
14
14
|
Requires-Dist: numpy<3,>=2
|
|
15
15
|
Requires-Dist: rapidfuzz<4,>=3
|
|
16
|
+
Requires-Dist: networkx<4,>=3
|
|
17
|
+
Requires-Dist: tree-sitter-language-pack<0.8,>=0.7
|
|
18
|
+
Requires-Dist: func-timeout<5,>=4
|
|
16
19
|
Requires-Dist: sentence-transformers<5.2,>=5.1
|
|
17
20
|
Requires-Dist: sentencepiece<0.3,>=0.2
|
|
18
21
|
Provides-Extra: chunking
|
|
@@ -20,6 +23,8 @@ Requires-Dist: chonkie<1.6,>=1.5; extra == "chunking"
|
|
|
20
23
|
Provides-Extra: chunking-code
|
|
21
24
|
Requires-Dist: chonkie[code]<1.6,>=1.5; extra == "chunking-code"
|
|
22
25
|
Provides-Extra: metrics
|
|
26
|
+
Requires-Dist: apted<2,>=1.0; extra == "metrics"
|
|
27
|
+
Requires-Dist: bert-score<0.4,>=0.3; extra == "metrics"
|
|
23
28
|
Provides-Extra: model2vec
|
|
24
29
|
Requires-Dist: model2vec<0.8,>=0.7; extra == "model2vec"
|
|
25
30
|
Provides-Extra: pylate
|
|
@@ -29,6 +34,8 @@ Requires-Dist: gradio<6,>=5; extra == "gradio"
|
|
|
29
34
|
Requires-Dist: gradio-huggingfacehub-search==0.0.8; extra == "gradio"
|
|
30
35
|
Provides-Extra: all
|
|
31
36
|
Requires-Dist: chonkie[code]<1.6,>=1.5; extra == "all"
|
|
37
|
+
Requires-Dist: apted<2,>=1.0; extra == "all"
|
|
38
|
+
Requires-Dist: bert-score<0.4,>=0.3; extra == "all"
|
|
32
39
|
Requires-Dist: model2vec<0.8,>=0.7; extra == "all"
|
|
33
40
|
Requires-Dist: pylate<1.5,>=1.4; extra == "all"
|
|
34
41
|
Requires-Dist: gradio<6,>=5; extra == "all"
|
|
@@ -58,6 +65,7 @@ Optional extras:
|
|
|
58
65
|
```bash
|
|
59
66
|
pip install "matheel[chunking]"
|
|
60
67
|
pip install "matheel[chunking_code]"
|
|
68
|
+
pip install "matheel[metrics]"
|
|
61
69
|
pip install "matheel[model2vec]"
|
|
62
70
|
pip install "matheel[pylate]"
|
|
63
71
|
pip install "matheel[gradio]"
|
|
@@ -65,23 +73,17 @@ pip install "matheel[all]"
|
|
|
65
73
|
pip install "matheel[dev]"
|
|
66
74
|
```
|
|
67
75
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
pip install -c constraints/py312.txt .
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
`matheel[all]` installs the currently supported optional backends in one command: Chonkie code chunking, model2vec, PyLate, and the Gradio app dependencies.
|
|
76
|
+
`matheel[all]` installs the currently supported optional backends in one command: Chonkie code chunking, metrics runtime dependencies (RUBY graph/tree, TSED, CodeBERTScore), model2vec, PyLate, and the Gradio app dependencies.
|
|
75
77
|
|
|
76
78
|
## Quick Start
|
|
77
79
|
|
|
78
|
-
The repo includes a small Java archive at `sample_pairs.zip` for
|
|
80
|
+
The repo includes a small Java archive at `sample_pairs.zip` for quick validation.
|
|
79
81
|
|
|
80
82
|
CLI:
|
|
81
83
|
|
|
82
84
|
```bash
|
|
83
85
|
matheel compare sample_pairs.zip \
|
|
84
|
-
--model
|
|
86
|
+
--model huggingface/CodeBERTa-small-v1 \
|
|
85
87
|
--feature-weight semantic=0.7 \
|
|
86
88
|
--feature-weight levenshtein=0.3 \
|
|
87
89
|
--threshold 0.2 \
|
|
@@ -95,7 +97,7 @@ from matheel.similarity import get_sim_list
|
|
|
95
97
|
|
|
96
98
|
results = get_sim_list(
|
|
97
99
|
"sample_pairs.zip",
|
|
98
|
-
model_name="
|
|
100
|
+
model_name="huggingface/CodeBERTa-small-v1",
|
|
99
101
|
threshold=0.2,
|
|
100
102
|
number_results=10,
|
|
101
103
|
feature_weights={
|
|
@@ -119,6 +121,8 @@ Similarity features:
|
|
|
119
121
|
- `semantic`
|
|
120
122
|
- `levenshtein`
|
|
121
123
|
- `jaro_winkler`
|
|
124
|
+
- `winnowing`
|
|
125
|
+
- `gst`
|
|
122
126
|
- `code_metric`
|
|
123
127
|
|
|
124
128
|
Code metrics:
|
|
@@ -129,11 +133,16 @@ Code metrics:
|
|
|
129
133
|
- `codebleu_syntax`
|
|
130
134
|
- `codebleu_dataflow`
|
|
131
135
|
- `crystalbleu`
|
|
136
|
+
- `ruby`
|
|
137
|
+
- `tsed`
|
|
138
|
+
- `codebertscore`
|
|
139
|
+
|
|
140
|
+
`ruby` now uses a full staged implementation (`graph -> tree -> string`), with optional runtime dependencies enabled via `matheel[metrics]`.
|
|
132
141
|
|
|
133
142
|
Chunking methods:
|
|
134
143
|
|
|
135
144
|
- `none`
|
|
136
|
-
- Chonkie-backed when installed: `code`, `
|
|
145
|
+
- Chonkie-backed when installed: `code`, `chonkie_token`, `chonkie_sentence`, `chonkie_recursive`, `chonkie_fast`
|
|
137
146
|
|
|
138
147
|
Vector backends:
|
|
139
148
|
|
|
@@ -165,7 +174,7 @@ Sentence Transformers pooling methods:
|
|
|
165
174
|
- Preprocessing: whitespace and comment normalization before any scoring.
|
|
166
175
|
- Chunking: Chonkie-backed document splitting with per-method options.
|
|
167
176
|
- Vectors: dense single-vector, learned static single-vector, and multivector late interaction.
|
|
168
|
-
-
|
|
177
|
+
- Lexical metrics and baselines: normalized Levenshtein, Jaro-Winkler, Winnowing, and Greedy String Tiling.
|
|
169
178
|
- Code metrics: built-in CodeBLEU-style metrics and CrystalBLEU.
|
|
170
179
|
- Comparison suite: run multiple configurations, rank them, and optionally write summary/detail artifacts.
|
|
171
180
|
|
|
@@ -175,7 +184,7 @@ Compare a directory or ZIP archive:
|
|
|
175
184
|
|
|
176
185
|
```bash
|
|
177
186
|
matheel compare codes/ \
|
|
178
|
-
--model
|
|
187
|
+
--model huggingface/CodeBERTa-small-v1 \
|
|
179
188
|
--vector-backend auto \
|
|
180
189
|
--max-token-length 256 \
|
|
181
190
|
--feature-weight semantic=0.6 \
|
|
@@ -212,7 +221,7 @@ from matheel.similarity import calculate_similarity
|
|
|
212
221
|
score = calculate_similarity(
|
|
213
222
|
"def add(a, b):\n return a + b\n",
|
|
214
223
|
"def add(x, y):\n return x + y\n",
|
|
215
|
-
model_name="
|
|
224
|
+
model_name="huggingface/CodeBERTa-small-v1",
|
|
216
225
|
vector_backend="auto",
|
|
217
226
|
max_token_length=256,
|
|
218
227
|
similarity_function="dot",
|
|
@@ -233,7 +242,7 @@ from matheel.similarity import get_sim_list
|
|
|
233
242
|
|
|
234
243
|
results = get_sim_list(
|
|
235
244
|
"sample_codes",
|
|
236
|
-
model_name="
|
|
245
|
+
model_name="huggingface/CodeBERTa-small-v1",
|
|
237
246
|
threshold=0.4,
|
|
238
247
|
number_results=50,
|
|
239
248
|
vector_backend="auto",
|
|
@@ -246,7 +255,9 @@ results = get_sim_list(
|
|
|
246
255
|
feature_weights={
|
|
247
256
|
"semantic": 0.7,
|
|
248
257
|
"levenshtein": 0.15,
|
|
249
|
-
"jaro_winkler": 0.
|
|
258
|
+
"jaro_winkler": 0.05,
|
|
259
|
+
"winnowing": 0.05,
|
|
260
|
+
"gst": 0.05,
|
|
250
261
|
},
|
|
251
262
|
)
|
|
252
263
|
```
|
|
@@ -276,7 +287,7 @@ The `docs/` folder is already structured well for a later GitHub Pages setup if
|
|
|
276
287
|
|
|
277
288
|
## Examples
|
|
278
289
|
|
|
279
|
-
- Quick archive
|
|
290
|
+
- Quick archive check: [examples/sample_pairs_demo.py](examples/sample_pairs_demo.py)
|
|
280
291
|
- Preprocessing: [examples/preprocessing_demo.py](examples/preprocessing_demo.py)
|
|
281
292
|
- Chunking: [examples/chunking_demo.py](examples/chunking_demo.py)
|
|
282
293
|
- Vector backends: [examples/vectors_demo.py](examples/vectors_demo.py)
|
|
@@ -286,7 +297,7 @@ The `docs/` folder is already structured well for a later GitHub Pages setup if
|
|
|
286
297
|
|
|
287
298
|
## Gradio
|
|
288
299
|
|
|
289
|
-
The Gradio demo stays in `gradio_app
|
|
300
|
+
The Gradio demo stays in `gradio_app/` and is aligned with the Hugging Face Space setup. The UI supports embeddings, lexical metrics, baseline algorithms (Winnowing and GST), and the code-aware metrics (CodeBLEU, CrystalBLEU, RUBY, TSED, CodeBERTScore), with metric-specific advanced fields. The core package and CLI can read either a ZIP archive or a directory; the Gradio upload flow remains ZIP-based.
|
|
290
301
|
|
|
291
302
|
## License
|
|
292
303
|
|
|
@@ -17,6 +17,7 @@ Optional extras:
|
|
|
17
17
|
```bash
|
|
18
18
|
pip install "matheel[chunking]"
|
|
19
19
|
pip install "matheel[chunking_code]"
|
|
20
|
+
pip install "matheel[metrics]"
|
|
20
21
|
pip install "matheel[model2vec]"
|
|
21
22
|
pip install "matheel[pylate]"
|
|
22
23
|
pip install "matheel[gradio]"
|
|
@@ -24,23 +25,17 @@ pip install "matheel[all]"
|
|
|
24
25
|
pip install "matheel[dev]"
|
|
25
26
|
```
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
pip install -c constraints/py312.txt .
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
`matheel[all]` installs the currently supported optional backends in one command: Chonkie code chunking, model2vec, PyLate, and the Gradio app dependencies.
|
|
28
|
+
`matheel[all]` installs the currently supported optional backends in one command: Chonkie code chunking, metrics runtime dependencies (RUBY graph/tree, TSED, CodeBERTScore), model2vec, PyLate, and the Gradio app dependencies.
|
|
34
29
|
|
|
35
30
|
## Quick Start
|
|
36
31
|
|
|
37
|
-
The repo includes a small Java archive at `sample_pairs.zip` for
|
|
32
|
+
The repo includes a small Java archive at `sample_pairs.zip` for quick validation.
|
|
38
33
|
|
|
39
34
|
CLI:
|
|
40
35
|
|
|
41
36
|
```bash
|
|
42
37
|
matheel compare sample_pairs.zip \
|
|
43
|
-
--model
|
|
38
|
+
--model huggingface/CodeBERTa-small-v1 \
|
|
44
39
|
--feature-weight semantic=0.7 \
|
|
45
40
|
--feature-weight levenshtein=0.3 \
|
|
46
41
|
--threshold 0.2 \
|
|
@@ -54,7 +49,7 @@ from matheel.similarity import get_sim_list
|
|
|
54
49
|
|
|
55
50
|
results = get_sim_list(
|
|
56
51
|
"sample_pairs.zip",
|
|
57
|
-
model_name="
|
|
52
|
+
model_name="huggingface/CodeBERTa-small-v1",
|
|
58
53
|
threshold=0.2,
|
|
59
54
|
number_results=10,
|
|
60
55
|
feature_weights={
|
|
@@ -78,6 +73,8 @@ Similarity features:
|
|
|
78
73
|
- `semantic`
|
|
79
74
|
- `levenshtein`
|
|
80
75
|
- `jaro_winkler`
|
|
76
|
+
- `winnowing`
|
|
77
|
+
- `gst`
|
|
81
78
|
- `code_metric`
|
|
82
79
|
|
|
83
80
|
Code metrics:
|
|
@@ -88,11 +85,16 @@ Code metrics:
|
|
|
88
85
|
- `codebleu_syntax`
|
|
89
86
|
- `codebleu_dataflow`
|
|
90
87
|
- `crystalbleu`
|
|
88
|
+
- `ruby`
|
|
89
|
+
- `tsed`
|
|
90
|
+
- `codebertscore`
|
|
91
|
+
|
|
92
|
+
`ruby` now uses a full staged implementation (`graph -> tree -> string`), with optional runtime dependencies enabled via `matheel[metrics]`.
|
|
91
93
|
|
|
92
94
|
Chunking methods:
|
|
93
95
|
|
|
94
96
|
- `none`
|
|
95
|
-
- Chonkie-backed when installed: `code`, `
|
|
97
|
+
- Chonkie-backed when installed: `code`, `chonkie_token`, `chonkie_sentence`, `chonkie_recursive`, `chonkie_fast`
|
|
96
98
|
|
|
97
99
|
Vector backends:
|
|
98
100
|
|
|
@@ -124,7 +126,7 @@ Sentence Transformers pooling methods:
|
|
|
124
126
|
- Preprocessing: whitespace and comment normalization before any scoring.
|
|
125
127
|
- Chunking: Chonkie-backed document splitting with per-method options.
|
|
126
128
|
- Vectors: dense single-vector, learned static single-vector, and multivector late interaction.
|
|
127
|
-
-
|
|
129
|
+
- Lexical metrics and baselines: normalized Levenshtein, Jaro-Winkler, Winnowing, and Greedy String Tiling.
|
|
128
130
|
- Code metrics: built-in CodeBLEU-style metrics and CrystalBLEU.
|
|
129
131
|
- Comparison suite: run multiple configurations, rank them, and optionally write summary/detail artifacts.
|
|
130
132
|
|
|
@@ -134,7 +136,7 @@ Compare a directory or ZIP archive:
|
|
|
134
136
|
|
|
135
137
|
```bash
|
|
136
138
|
matheel compare codes/ \
|
|
137
|
-
--model
|
|
139
|
+
--model huggingface/CodeBERTa-small-v1 \
|
|
138
140
|
--vector-backend auto \
|
|
139
141
|
--max-token-length 256 \
|
|
140
142
|
--feature-weight semantic=0.6 \
|
|
@@ -171,7 +173,7 @@ from matheel.similarity import calculate_similarity
|
|
|
171
173
|
score = calculate_similarity(
|
|
172
174
|
"def add(a, b):\n return a + b\n",
|
|
173
175
|
"def add(x, y):\n return x + y\n",
|
|
174
|
-
model_name="
|
|
176
|
+
model_name="huggingface/CodeBERTa-small-v1",
|
|
175
177
|
vector_backend="auto",
|
|
176
178
|
max_token_length=256,
|
|
177
179
|
similarity_function="dot",
|
|
@@ -192,7 +194,7 @@ from matheel.similarity import get_sim_list
|
|
|
192
194
|
|
|
193
195
|
results = get_sim_list(
|
|
194
196
|
"sample_codes",
|
|
195
|
-
model_name="
|
|
197
|
+
model_name="huggingface/CodeBERTa-small-v1",
|
|
196
198
|
threshold=0.4,
|
|
197
199
|
number_results=50,
|
|
198
200
|
vector_backend="auto",
|
|
@@ -205,7 +207,9 @@ results = get_sim_list(
|
|
|
205
207
|
feature_weights={
|
|
206
208
|
"semantic": 0.7,
|
|
207
209
|
"levenshtein": 0.15,
|
|
208
|
-
"jaro_winkler": 0.
|
|
210
|
+
"jaro_winkler": 0.05,
|
|
211
|
+
"winnowing": 0.05,
|
|
212
|
+
"gst": 0.05,
|
|
209
213
|
},
|
|
210
214
|
)
|
|
211
215
|
```
|
|
@@ -235,7 +239,7 @@ The `docs/` folder is already structured well for a later GitHub Pages setup if
|
|
|
235
239
|
|
|
236
240
|
## Examples
|
|
237
241
|
|
|
238
|
-
- Quick archive
|
|
242
|
+
- Quick archive check: [examples/sample_pairs_demo.py](examples/sample_pairs_demo.py)
|
|
239
243
|
- Preprocessing: [examples/preprocessing_demo.py](examples/preprocessing_demo.py)
|
|
240
244
|
- Chunking: [examples/chunking_demo.py](examples/chunking_demo.py)
|
|
241
245
|
- Vector backends: [examples/vectors_demo.py](examples/vectors_demo.py)
|
|
@@ -245,7 +249,7 @@ The `docs/` folder is already structured well for a later GitHub Pages setup if
|
|
|
245
249
|
|
|
246
250
|
## Gradio
|
|
247
251
|
|
|
248
|
-
The Gradio demo stays in `gradio_app
|
|
252
|
+
The Gradio demo stays in `gradio_app/` and is aligned with the Hugging Face Space setup. The UI supports embeddings, lexical metrics, baseline algorithms (Winnowing and GST), and the code-aware metrics (CodeBLEU, CrystalBLEU, RUBY, TSED, CodeBERTScore), with metric-specific advanced fields. The core package and CLI can read either a ZIP archive or a directory; the Gradio upload flow remains ZIP-based.
|
|
249
253
|
|
|
250
254
|
## License
|
|
251
255
|
|
|
@@ -2,11 +2,8 @@ import inspect
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
_BASE_METHODS = ("none",)
|
|
5
|
-
_LEGACY_METHODS = ("lines", "tokens", "characters")
|
|
6
5
|
_CHONKIE_METHODS = (
|
|
7
6
|
"code",
|
|
8
|
-
"codechunker",
|
|
9
|
-
"chonkie_code",
|
|
10
7
|
"chonkie_token",
|
|
11
8
|
"chonkie_sentence",
|
|
12
9
|
"chonkie_recursive",
|
|
@@ -14,8 +11,6 @@ _CHONKIE_METHODS = (
|
|
|
14
11
|
)
|
|
15
12
|
_CHONKIE_CLASS_NAMES = {
|
|
16
13
|
"code": "CodeChunker",
|
|
17
|
-
"codechunker": "CodeChunker",
|
|
18
|
-
"chonkie_code": "CodeChunker",
|
|
19
14
|
"chonkie_token": "TokenChunker",
|
|
20
15
|
"chonkie_sentence": "SentenceChunker",
|
|
21
16
|
"chonkie_recursive": "RecursiveChunker",
|
|
@@ -23,8 +18,6 @@ _CHONKIE_CLASS_NAMES = {
|
|
|
23
18
|
}
|
|
24
19
|
_CHONKIE_PARAMETER_NAMES = {
|
|
25
20
|
"code": ("chunk_size", "language", "include_nodes", "tokenizer"),
|
|
26
|
-
"codechunker": ("chunk_size", "language", "include_nodes", "tokenizer"),
|
|
27
|
-
"chonkie_code": ("chunk_size", "language", "include_nodes", "tokenizer"),
|
|
28
21
|
"chonkie_token": ("chunk_size", "chunk_overlap", "tokenizer"),
|
|
29
22
|
"chonkie_sentence": (
|
|
30
23
|
"chunk_size",
|
|
@@ -47,7 +40,7 @@ def available_chunking_methods():
|
|
|
47
40
|
|
|
48
41
|
def chunker_parameter_names(method):
|
|
49
42
|
selected_method = (method or "").strip().lower()
|
|
50
|
-
if selected_method
|
|
43
|
+
if selected_method == "none":
|
|
51
44
|
return ()
|
|
52
45
|
return _CHONKIE_PARAMETER_NAMES.get(selected_method, ())
|
|
53
46
|
|
|
@@ -275,14 +268,8 @@ def chunk_text(
|
|
|
275
268
|
):
|
|
276
269
|
selected_method = (method or "none").strip().lower()
|
|
277
270
|
|
|
278
|
-
if selected_method
|
|
271
|
+
if selected_method == "none":
|
|
279
272
|
chunks = [text or ""]
|
|
280
|
-
elif selected_method == "lines":
|
|
281
|
-
chunks = chunk_by_lines(text, chunk_size=chunk_size, chunk_overlap=chunk_overlap)
|
|
282
|
-
elif selected_method == "tokens":
|
|
283
|
-
chunks = chunk_by_tokens(text, chunk_size=chunk_size, chunk_overlap=chunk_overlap)
|
|
284
|
-
elif selected_method == "characters":
|
|
285
|
-
chunks = chunk_by_characters(text, chunk_size=chunk_size, chunk_overlap=chunk_overlap)
|
|
286
273
|
elif selected_method in _CHONKIE_METHODS:
|
|
287
274
|
return _chunk_with_chonkie(
|
|
288
275
|
text,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import click
|
|
2
2
|
from .comparison_suite import load_run_configs, run_comparison_suite
|
|
3
3
|
from .code_metrics import available_code_metrics
|
|
4
|
-
from .similarity import available_runtime_devices, get_sim_list
|
|
4
|
+
from .similarity import DEFAULT_MODEL_NAME, available_runtime_devices, get_sim_list
|
|
5
5
|
from .chunking import available_chunk_aggregations, available_chunking_methods
|
|
6
6
|
from .model_routing import available_vector_backends
|
|
7
7
|
from .preprocessing import available_preprocess_modes
|
|
@@ -24,7 +24,7 @@ def main():
|
|
|
24
24
|
multiple=True,
|
|
25
25
|
help='Normalized feature weights as name=value. Example: --feature-weight semantic=0.5 --feature-weight code_metric=0.5',
|
|
26
26
|
)
|
|
27
|
-
@click.option('--model', default=
|
|
27
|
+
@click.option('--model', default=DEFAULT_MODEL_NAME, show_default=True, help='Embedding model name.')
|
|
28
28
|
@click.option(
|
|
29
29
|
'--preprocess-mode',
|
|
30
30
|
type=click.Choice(available_preprocess_modes()),
|
|
@@ -68,8 +68,73 @@ def main():
|
|
|
68
68
|
@click.option('--codebleu-component-weights', default='0.25,0.25,0.25,0.25', show_default=True, help='Comma-separated weights for ngram, weighted_ngram, syntax, dataflow.')
|
|
69
69
|
@click.option('--crystalbleu-max-order', default=4, show_default=True, help='Maximum n-gram order for CrystalBLEU.')
|
|
70
70
|
@click.option('--crystalbleu-trivial-ngram-count', default=50, show_default=True, help='How many frequent n-grams to ignore in CrystalBLEU.')
|
|
71
|
+
@click.option('--ruby-max-order', default=4, show_default=True, help='Maximum n-gram order for RUBY.')
|
|
72
|
+
@click.option('--ruby-epsilon', default=1e-12, show_default=True, help='Small epsilon used by RUBY F1 smoothing.')
|
|
73
|
+
@click.option(
|
|
74
|
+
'--ruby-mode',
|
|
75
|
+
type=click.Choice(("auto", "graph", "tree", "string", "ngram")),
|
|
76
|
+
default='auto',
|
|
77
|
+
show_default=True,
|
|
78
|
+
help='RUBY strategy selection.',
|
|
79
|
+
)
|
|
80
|
+
@click.option(
|
|
81
|
+
'--ruby-tokenizer',
|
|
82
|
+
type=click.Choice(("tranx", "regex")),
|
|
83
|
+
default='tranx',
|
|
84
|
+
show_default=True,
|
|
85
|
+
help='Tokenizer used by RUBY string mode.',
|
|
86
|
+
)
|
|
87
|
+
@click.option(
|
|
88
|
+
'--ruby-denominator',
|
|
89
|
+
type=click.Choice(("max", "mean")),
|
|
90
|
+
default='max',
|
|
91
|
+
show_default=True,
|
|
92
|
+
help='Length normalization denominator used by RUBY string mode.',
|
|
93
|
+
)
|
|
94
|
+
@click.option('--ruby-graph-timeout-seconds', default=1.0, show_default=True, help='Per-step timeout (seconds) for RUBY graph edit search.')
|
|
95
|
+
@click.option('--ruby-graph-use-edge-cost/--no-ruby-graph-use-edge-cost', default=True, show_default=True, help='Whether RUBY graph mode includes edge insertion/deletion cost.')
|
|
96
|
+
@click.option('--ruby-graph-include-leaf-edges/--no-ruby-graph-include-leaf-edges', default=True, show_default=True, help='Whether RUBY graph mode adds sequential leaf edges.')
|
|
97
|
+
@click.option('--ruby-tree-max-nodes', default=180, show_default=True, help='Maximum parsed tree nodes for RUBY tree/graph modes.')
|
|
98
|
+
@click.option('--ruby-tree-max-depth', default=10, show_default=True, help='Maximum parsed tree depth for RUBY tree/graph modes.')
|
|
99
|
+
@click.option('--ruby-tree-max-children', default=8, show_default=True, help='Maximum parsed children per node for RUBY tree/graph modes.')
|
|
100
|
+
@click.option('--tsed-delete-cost', default=1.0, show_default=True, help='Delete edit cost for TSED.')
|
|
101
|
+
@click.option('--tsed-insert-cost', default=1.0, show_default=True, help='Insert edit cost for TSED.')
|
|
102
|
+
@click.option('--tsed-rename-cost', default=1.0, show_default=True, help='Rename edit cost for TSED.')
|
|
103
|
+
@click.option('--tsed-max-nodes', default=180, show_default=True, help='Maximum AST nodes sampled per file for TSED.')
|
|
104
|
+
@click.option('--tsed-max-depth', default=10, show_default=True, help='Maximum AST depth for TSED.')
|
|
105
|
+
@click.option('--tsed-max-children', default=8, show_default=True, help='Maximum AST children sampled per node for TSED.')
|
|
106
|
+
@click.option('--codebertscore-model', default='microsoft/codebert-base', show_default=True, help='Model name used for CodeBERTScore.')
|
|
107
|
+
@click.option('--codebertscore-num-layers', default=0, show_default=True, help='Hidden layer count for CodeBERTScore. 0 uses model defaults.')
|
|
108
|
+
@click.option('--codebertscore-batch-size', default=16, show_default=True, help='Batch size for CodeBERTScore.')
|
|
109
|
+
@click.option('--codebertscore-max-length', default=0, show_default=True, help='Max tokenizer length for CodeBERTScore. 0 uses model limits.')
|
|
110
|
+
@click.option(
|
|
111
|
+
'--codebertscore-device',
|
|
112
|
+
type=click.Choice(("auto",) + available_runtime_devices()),
|
|
113
|
+
default='auto',
|
|
114
|
+
show_default=True,
|
|
115
|
+
help='Runtime device for CodeBERTScore.',
|
|
116
|
+
)
|
|
117
|
+
@click.option('--codebertscore-lang', default='', show_default=True, help='Optional language code passed to CodeBERTScore.')
|
|
118
|
+
@click.option('--codebertscore-idf/--no-codebertscore-idf', default=False, show_default=True, help='Enable IDF weighting for CodeBERTScore.')
|
|
119
|
+
@click.option(
|
|
120
|
+
'--codebertscore-rescale-with-baseline/--no-codebertscore-rescale-with-baseline',
|
|
121
|
+
default=False,
|
|
122
|
+
show_default=True,
|
|
123
|
+
help='Enable baseline rescaling for CodeBERTScore.',
|
|
124
|
+
)
|
|
125
|
+
@click.option(
|
|
126
|
+
'--codebertscore-use-fast-tokenizer/--no-codebertscore-use-fast-tokenizer',
|
|
127
|
+
default=False,
|
|
128
|
+
show_default=True,
|
|
129
|
+
help='Use fast tokenizer for CodeBERTScore.',
|
|
130
|
+
)
|
|
131
|
+
@click.option('--codebertscore-nthreads', default=4, show_default=True, help='Thread count for CodeBERTScore.')
|
|
132
|
+
@click.option('--codebertscore-verbose/--no-codebertscore-verbose', default=False, show_default=True, help='Verbose CodeBERTScore output.')
|
|
71
133
|
@click.option('--levenshtein-weights', default='1,1,1', show_default=True, help='Comma-separated insert,delete,substitute costs for Levenshtein.')
|
|
72
134
|
@click.option('--jaro-winkler-prefix-weight', default=0.1, show_default=True, help='Prefix bonus weight for Jaro-Winkler (0.0 to 0.25).')
|
|
135
|
+
@click.option('--winnowing-kgram', default=5, show_default=True, help='Token k-gram size used by Winnowing.')
|
|
136
|
+
@click.option('--winnowing-window', default=4, show_default=True, help='Window size used by Winnowing fingerprint selection.')
|
|
137
|
+
@click.option('--gst-min-match-length', default=5, show_default=True, help='Minimum token tile length used by Greedy String Tiling.')
|
|
73
138
|
@click.option(
|
|
74
139
|
'--vector-backend',
|
|
75
140
|
type=click.Choice(available_vector_backends()),
|
|
@@ -120,8 +185,39 @@ def compare(
|
|
|
120
185
|
codebleu_component_weights,
|
|
121
186
|
crystalbleu_max_order,
|
|
122
187
|
crystalbleu_trivial_ngram_count,
|
|
188
|
+
ruby_max_order,
|
|
189
|
+
ruby_epsilon,
|
|
190
|
+
ruby_mode,
|
|
191
|
+
ruby_tokenizer,
|
|
192
|
+
ruby_denominator,
|
|
193
|
+
ruby_graph_timeout_seconds,
|
|
194
|
+
ruby_graph_use_edge_cost,
|
|
195
|
+
ruby_graph_include_leaf_edges,
|
|
196
|
+
ruby_tree_max_nodes,
|
|
197
|
+
ruby_tree_max_depth,
|
|
198
|
+
ruby_tree_max_children,
|
|
199
|
+
tsed_delete_cost,
|
|
200
|
+
tsed_insert_cost,
|
|
201
|
+
tsed_rename_cost,
|
|
202
|
+
tsed_max_nodes,
|
|
203
|
+
tsed_max_depth,
|
|
204
|
+
tsed_max_children,
|
|
205
|
+
codebertscore_model,
|
|
206
|
+
codebertscore_num_layers,
|
|
207
|
+
codebertscore_batch_size,
|
|
208
|
+
codebertscore_max_length,
|
|
209
|
+
codebertscore_device,
|
|
210
|
+
codebertscore_lang,
|
|
211
|
+
codebertscore_idf,
|
|
212
|
+
codebertscore_rescale_with_baseline,
|
|
213
|
+
codebertscore_use_fast_tokenizer,
|
|
214
|
+
codebertscore_nthreads,
|
|
215
|
+
codebertscore_verbose,
|
|
123
216
|
levenshtein_weights,
|
|
124
217
|
jaro_winkler_prefix_weight,
|
|
218
|
+
winnowing_kgram,
|
|
219
|
+
winnowing_window,
|
|
220
|
+
gst_min_match_length,
|
|
125
221
|
vector_backend,
|
|
126
222
|
similarity_function,
|
|
127
223
|
static_vector_dim,
|
|
@@ -152,8 +248,39 @@ def compare(
|
|
|
152
248
|
codebleu_component_weights=codebleu_component_weights,
|
|
153
249
|
crystalbleu_max_order=crystalbleu_max_order,
|
|
154
250
|
crystalbleu_trivial_ngram_count=crystalbleu_trivial_ngram_count,
|
|
251
|
+
ruby_max_order=ruby_max_order,
|
|
252
|
+
ruby_epsilon=ruby_epsilon,
|
|
253
|
+
ruby_mode=ruby_mode,
|
|
254
|
+
ruby_tokenizer=ruby_tokenizer,
|
|
255
|
+
ruby_denominator=ruby_denominator,
|
|
256
|
+
ruby_graph_timeout_seconds=ruby_graph_timeout_seconds,
|
|
257
|
+
ruby_graph_use_edge_cost=ruby_graph_use_edge_cost,
|
|
258
|
+
ruby_graph_include_leaf_edges=ruby_graph_include_leaf_edges,
|
|
259
|
+
ruby_tree_max_nodes=ruby_tree_max_nodes,
|
|
260
|
+
ruby_tree_max_depth=ruby_tree_max_depth,
|
|
261
|
+
ruby_tree_max_children=ruby_tree_max_children,
|
|
262
|
+
tsed_delete_cost=tsed_delete_cost,
|
|
263
|
+
tsed_insert_cost=tsed_insert_cost,
|
|
264
|
+
tsed_rename_cost=tsed_rename_cost,
|
|
265
|
+
tsed_max_nodes=tsed_max_nodes,
|
|
266
|
+
tsed_max_depth=tsed_max_depth,
|
|
267
|
+
tsed_max_children=tsed_max_children,
|
|
268
|
+
codebertscore_model=codebertscore_model,
|
|
269
|
+
codebertscore_num_layers=(None if int(codebertscore_num_layers or 0) <= 0 else int(codebertscore_num_layers)),
|
|
270
|
+
codebertscore_batch_size=codebertscore_batch_size,
|
|
271
|
+
codebertscore_max_length=codebertscore_max_length,
|
|
272
|
+
codebertscore_device=codebertscore_device,
|
|
273
|
+
codebertscore_lang=(str(codebertscore_lang).strip() or None),
|
|
274
|
+
codebertscore_idf=codebertscore_idf,
|
|
275
|
+
codebertscore_rescale_with_baseline=codebertscore_rescale_with_baseline,
|
|
276
|
+
codebertscore_use_fast_tokenizer=codebertscore_use_fast_tokenizer,
|
|
277
|
+
codebertscore_nthreads=codebertscore_nthreads,
|
|
278
|
+
codebertscore_verbose=codebertscore_verbose,
|
|
155
279
|
levenshtein_weights=levenshtein_weights,
|
|
156
280
|
jaro_winkler_prefix_weight=jaro_winkler_prefix_weight,
|
|
281
|
+
winnowing_kgram=winnowing_kgram,
|
|
282
|
+
winnowing_window=winnowing_window,
|
|
283
|
+
gst_min_match_length=gst_min_match_length,
|
|
157
284
|
vector_backend=vector_backend,
|
|
158
285
|
similarity_function=similarity_function,
|
|
159
286
|
static_vector_dim=static_vector_dim,
|