INNER CODE UNIT · Python

build

kangarooking/cangjie-skill · scripts/build_chunks.py:151

def build(source_path: Path, sidecar: Path, source_id: str, max_chars: int) -> dict:
    raw = source_path.read_text(encoding="utf-8")
    normalized = raw.replace("\r\n", "\n").strip() + "\n"
    version_id = f"sha256:{sha256_text(normalized)}"

    cache_root = sidecar / "cache"
    key = deterministic_cache_key("build_chunks", IMPL_VERSION, SCHEMA_VERSION,
                                  [version_id], {"max_chars": max_chars, "source_id": source_id})
    cached = cache_lookup(cache_root, "build_chunks", key)
    if cached:
        doc = json.loads((cached / "document.json").read_text(encoding="utf-8"))
        chunk_lines = (cached / "chunks.jsonl").read_text(encoding="utf-8")
        print(f"[cache-hit] build_chunks {key[:12]}")
    else:
        elements = parse_elements(normalized)
        doc = {
            "schema_version": 1,
            "source_id": source_id,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…