Commit History
-
feat: smarter fallback — heuristic sufficiency + result merging (v3.1)
Robin +1: Claude Sonnet 4.6Previously: fallback fired only on entities==0, and replaced primary results. Now: heuristic sufficiency check, with results MERGED (not replaced). Sufficiency criterion (NERService._expected_min) expected_min = max(length_floor, label_floor) length_floor: text<30→1, <100→2, <300→3, ≥300→4 label_floor : ⌈len(labels)/3⌉, default 1 fallback fires when len(primary_entities) < expected_min Override ExtractRequest.min_entities (int, ≥0): client overrides the heuristic min_entities=0 disables fallback entirely Merge semantics primary results are kept verbatim fallback results appended; deduplication keeps highest-score per (start,end) applies to both single-language fallback and mixed-language dual-run Tests: 38 → 48 (heuristic, override, additive merge, EN/ZH symmetric paths) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>2288fd7 -
feat: optional labels, bilingual auto-expansion, language hint (v2.0)
Robin +1: Claude Sonnet 4.6- app/labels.py (new): bilingual label pairs table, DEFAULT_LABELS, expand_bilingual() — auto-adds counterpart label for each known entry - app/models.py: labels optional (default []), add language field (auto/en/zh/ar/mixed), response now echoes labels_used - app/ner.py: integrate expand_bilingual + DEFAULT_LABELS; language-aware processing; span deduplication (_deduplicate) - app/main.py: pass language to NERService.extract(), return labels_used - tests/test_extract.py: expanded from 15 → 25 tests; cover Arabic, bilingual expansion, optional-labels, language field, labels_used echo - scripts/compare_models.py: bilingual labels in all cases, Markdown report - reports/comparison_report.md: model comparison results Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>372fe0c
-
fix: raise default threshold from 0.5 to 0.6 to reduce false positives
Robin +1: Claude Sonnet 4.6Low-confidence results (e.g. score ~0.547) were being incorrectly identified as entities. Raising the default threshold filters these out. Callers can still override per-request via the threshold field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>eb553d1 -
feat: GLiNER NER HTTP API
Robin +1: Claude Sonnet 4.6- POST /extract 接收文本和实体类型,返回抽取结果 - 模型启动时加载一次,多次请求复用 - 通过 HF_ENDPOINT 使用国内镜像,MODEL_CACHE_DIR 本地缓存 - 默认端口 4000,支持环境变量配置 - 包含单元测试(mock)和集成测试(真实 API) - start.bat 从 conda ai 环境启动 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>d470d45