Top-level Python API¶
import cc4q exposes the most common entry points as lazy aliases. The
aliases keep import time low (no torch/transformers/spaCy import until you
touch a model or a segmenter) and mirror the command-line workflow.
CC4Q — build, inspect, and profile labeled comment corpora for Python-based quantum SDKs.
The package conveniences are imported lazily so import cc4q stays cheap.
Canonical module APIs live in the submodules listed below; the top-level
names are aliases for the most common entry points.
- Pipeline:
cc4q.pipeline.extract.python_extract_comment_pairs(),cc4q.pipeline.segment.docstring.segment_docstring(),cc4q.pipeline.segment.inline.segment_inline_comment(),cc4q.pipeline.segment.block.segment_block_comment(),cc4q.pipeline.files.get_files_from_dir(),cc4q.pipeline.config.read_config(),cc4q.pipeline.ids.id_generator()- Models / inference:
cc4q.models.hub.load_models(),cc4q.models.hub.resolve_device(),cc4q.models.hub.ensure_checkpoints()- Prediction:
cc4q.predict.predict_snippet(),cc4q.predict.predict_corpus(),cc4q.predict.extract_units(),cc4q.predict.analyze_snippet()- Training / evaluation:
cc4q.train.train(),cc4q.evaluate.evaluate(),cc4q.evaluate.evaluate_files()- Sampling / annotation:
- Persistence:
See Top-level Python API for the grouped top-level API and Module index for the module map.
Grouped aliases¶
Corpus construction¶
Top-level alias |
Canonical API |
Purpose |
|---|---|---|
|
Source file -> comment/code pairs (stage 01). |
|
|
reST/Sphinx docstring -> semantic blocks (stage 02). |
|
|
Inline comment -> sentences (stage 02). |
|
|
Block comment -> sentences (stage 02). |
|
|
Apply a code-context cleaning policy. |
|
|
Discover |
|
|
Load a YAML pipeline config. |
|
|
Shallow-clone a repository at a pinned ref. |
|
|
Deterministic record ids. |
|
|
Repository root of a source checkout. |
|
|
Normalize a path into components. |
|
|
Typed record exchanged by the stages. |
|
|
Low-level LibCST extractor. |
Models and inference¶
Top-level alias |
Canonical API |
Purpose |
|---|---|---|
|
Load both released classifiers in eval mode. |
|
|
Resolve |
|
|
Download, verify, and extract missing checkpoints. |
|
|
Extract -> segment -> classify one snippet. |
|
|
Label an SCCU corpus on both quantum axes. |
|
|
Extract and segment a snippet without a model. |
|
|
Full snippet pipeline with parser fallback. |
Training, evaluation, sampling, annotation¶
Top-level alias |
Canonical API |
Purpose |
|---|---|---|
|
Fine-tune one quantum classifier. |
|
|
Agreement, kappa, precision/recall/F1, Wilson CI. |
|
|
Spot-check evaluation from CSV/JSONL + answer key. |
|
|
Random, stratified, or quota sampling. |
|
|
Launch the interactive annotation UI. |
|
|
Asset/workspace persistence module. |
Note
The top-level names are aliases, not separate implementations. Use
the canonical module path when you need module-level helpers, for
example from cc4q.train import normalize_training_records or
from cc4q.models.hub import load_models_from. For new code, importing
from the canonical module is the most explicit option.
Example¶
from cc4q import load_models, predict_corpus, sample
models = load_models() # auto-download once
labeled = predict_corpus("out/sccus_segmented.json", models=models)
spot_check = sample(labeled, by=["SDK"], n=200, seed=42)
The same functions are available through the CLI (see Command line) and the Workbench HTTP API (see Web Workbench HTTP API).