32 lines
977 B
Python
32 lines
977 B
Python
#!/usr/bin/env python3
|
|
"""SQLite 코퍼스의 CPU 영속 후보 인덱스를 신규 구축하거나 증분 동기화한다."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
if __package__ in (None, ""):
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from app.engine.persistent_index import PersistentCorpusIndex
|
|
|
|
|
|
def main() -> int:
|
|
p = argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument("--database", type=Path, required=True)
|
|
p.add_argument("--index-dir", type=Path, required=True)
|
|
p.add_argument("--features", type=int, default=2**20)
|
|
args = p.parse_args()
|
|
if not args.database.exists():
|
|
p.error(f"database does not exist: {args.database}")
|
|
result = PersistentCorpusIndex(args.database, args.index_dir).sync(args.features)
|
|
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|