28 lines
928 B
Python
28 lines
928 B
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from common import build_lexical_index, read_jsonl, write_json
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DEFAULT_CORPUS = ROOT / "plugins" / "1c" / "datasets" / "prepared" / "rag_corpus.jsonl"
|
|
DEFAULT_INDEX = ROOT / "plugins" / "1c" / "datasets" / "prepared" / "rag_index.json"
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Build a simple lexical RAG index for the 1C corpus.")
|
|
parser.add_argument("--corpus", type=Path, default=DEFAULT_CORPUS)
|
|
parser.add_argument("--output", type=Path, default=DEFAULT_INDEX)
|
|
args = parser.parse_args()
|
|
|
|
records = read_jsonl(args.corpus)
|
|
index = build_lexical_index(records)
|
|
write_json(args.output, index)
|
|
print(f"Wrote index with {index['doc_count']} document chunk(s) to {args.output}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|