Raise the clustering to 100 groups

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 22:38:31 +08:00
co-authored by Claude Opus 5
parent 8cdeb3db2e
commit 15f1843cde
6 changed files with 55 additions and 14 deletions
@@ -40,7 +40,6 @@ from typing import Any
from ..utils import format_duration
MODEL: str = "sentence-transformers/all-mpnet-base-v2"
DEFAULT_CLUSTERS: int = 50
CLUSTER_EXTRA_MESSAGE: str = (
"cluster-keywords requires the optional \"cluster\""
" dependency group; install it with"
@@ -101,8 +100,9 @@ def parse_args(argv: list[str] | None) -> argparse.Namespace:
"--revision", default=None,
help="the model revision to pin (default: unpinned)")
parser.add_argument(
"--clusters", type=int, default=DEFAULT_CLUSTERS,
help=f"the number of clusters (default {DEFAULT_CLUSTERS})")
"--clusters", type=int, required=True,
help="the number of clusters; required, so that the\n"
"group count is stated on every invocation")
parser.add_argument(
"--extra-keyword", dest="extra_keywords", action="append",
default=None,
+9
View File
@@ -478,6 +478,15 @@ class TestClusterKeywords(unittest.TestCase):
["a-center", "aaa-extra", "b-middle", "zzz-extra"])
self.assertEqual(keywords, sorted(keywords))
def test_missing_clusters_option_rejected(self) -> None:
"""Test that omitting --clusters fails the run."""
with self.assertRaises(SystemExit) as caught, \
redirect_stderr(io.StringIO()):
cluster_keywords.parse_args(
[str(self.__run1), str(self.__run2),
str(self.__output_dir)])
self.assertNotEqual(caught.exception.code, 0)
def test_duplicate_extra_keyword_rejected(self) -> None:
"""Test that repeating the same ``--extra-keyword`` value
fails the run without writing any output file."""