- phase2b_converter: result.json -> neo4j.cypher + qdrant_points.jsonl (payload keys replicate direct_flow_retriever contract; kb_version= aqua_srt_v1_20260930_normalized, source_system=Aqua_canonical) - qdrant_loader: bge-m3 embed + batched upsert + checkpoint resume - registry_builder: paper blocks -> registry jsonl (plant format) - batch_runner: manifest -> convert -> neo4j -> qdrant, all checkpointed - start_aqua_kb.sh: user-space trial instances (Neo4j 19889 / Qdrant 27435) - smoke 11/11 green incl. resume drills - aqua configs: entity_alias_aqua.yaml (22 entries), relation_taxonomy_aqua.yaml (45 groups); manifest points to aqua configs - QA artifacts: golden_aqua.jsonl (41 Qs zh/en), qc_standards.md, budget_template.md + cost_model.py (measured pilot tokens) - pilot: 500 MD + 30 PDF extracted, 0 failures; QC stats computed Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
235 lines
12 KiB
Python
235 lines
12 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""自造 3 个最小 v16 结构 result.json fixture(手写字段按 v16_1_2 契约)。
|
|
|
|
产出 <dir>/<paper_id>/result.json,每篇 3-5 实体 + 3-5 关系,
|
|
含 rejected 关系(验证转换器过滤)与多层 output_layer。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
FIXTURES = [
|
|
{
|
|
"paper_id": "doi:10.1016/0044-8486(88)90238-4",
|
|
"paper": {
|
|
"paper_id": "doi:10.1016/0044-8486(88)90238-4",
|
|
"title": "Quality of algal material produced on a fertilizer-tap water medium in outdoor plastic-enclosed systems",
|
|
"doi": "10.1016/0044-8486(88)90238-4",
|
|
"pmid": "",
|
|
"pmcid": "",
|
|
"journal": "Aquaculture",
|
|
"publication_year": "1988",
|
|
},
|
|
"entities": [
|
|
{"name": "Chlorella vulgaris", "type": "species", "name_resolved": "",
|
|
"synonyms": [], "confidence": 0.95},
|
|
{"name": "outdoor plastic-enclosed culture", "type": "culture_system",
|
|
"name_resolved": "", "synonyms": [], "confidence": 0.9},
|
|
{"name": "fertilizer-tap water medium", "type": "culture_medium",
|
|
"name_resolved": "", "synonyms": [], "confidence": 0.9},
|
|
{"name": "protein content", "type": "biochemical_trait",
|
|
"name_resolved": "", "synonyms": [], "confidence": 0.85},
|
|
],
|
|
"relations": [
|
|
{
|
|
"source": "Chlorella vulgaris", "source_type": "species",
|
|
"source_resolved": "Chlorella vulgaris", "source_type_resolved": "species",
|
|
"relation": "cultured_in", "relationship_resolved": "cultured_in",
|
|
"target": "outdoor plastic-enclosed culture", "target_type": "culture_system",
|
|
"target_resolved": "outdoor plastic-enclosed culture",
|
|
"target_type_resolved": "culture_system",
|
|
"relation_category": "cultivation",
|
|
"evidence": "C. vulgaris was maintained in outdoor plastic-enclosed systems with fertilizer-tap water medium.",
|
|
"confidence": 0.95, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
{
|
|
"source": "Chlorella vulgaris", "source_type": "species",
|
|
"source_resolved": "Chlorella vulgaris", "source_type_resolved": "species",
|
|
"relation": "cultured_in", "relationship_resolved": "cultured_in",
|
|
"target": "fertilizer-tap water medium", "target_type": "culture_medium",
|
|
"target_resolved": "fertilizer-tap water medium",
|
|
"target_type_resolved": "culture_medium",
|
|
"relation_category": "cultivation",
|
|
"evidence": "Algal biomass was produced on a fertilizer-tap water medium.",
|
|
"confidence": 0.9, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
{
|
|
"source": "Chlorella vulgaris", "source_type": "species",
|
|
"source_resolved": "Chlorella vulgaris", "source_type_resolved": "species",
|
|
"relation": "has_trait", "relationship_resolved": "has_trait",
|
|
"target": "protein content", "target_type": "biochemical_trait",
|
|
"target_resolved": "protein content", "target_type_resolved": "biochemical_trait",
|
|
"relation_category": "physiological_measurement",
|
|
"evidence": "Protein content of the harvested biomass reached 45% of dry weight.",
|
|
"confidence": 0.85, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
{
|
|
"source": "Chlorella vulgaris", "source_type": "species",
|
|
"source_resolved": "Chlorella vulgaris", "source_type_resolved": "species",
|
|
"relation": "grows_in", "relationship_resolved": "grows_in",
|
|
"target": "fertilizer-tap water medium", "target_type": "culture_medium",
|
|
"target_resolved": "fertilizer-tap water medium",
|
|
"target_type_resolved": "culture_medium",
|
|
"relation_category": "growth_condition",
|
|
"evidence": "Growth rates were stable across seasons.",
|
|
"confidence": 0.6, "output_layer": "rejected", "claim_scope": "",
|
|
"candidate_status": "rejected", "triple_quality": "", "final_action": "",
|
|
},
|
|
],
|
|
"chunks": [], "sections": [],
|
|
"metadata": {"version": "16.1.2"},
|
|
},
|
|
{
|
|
"paper_id": "doi:10.2331/suisan.54.1049",
|
|
"paper": {
|
|
"paper_id": "doi:10.2331/suisan.54.1049",
|
|
"title": "Titration of the alternative complement pathway activity of representative cultured fishes",
|
|
"doi": "10.2331/suisan.54.1049",
|
|
"pmid": "", "pmcid": "", "journal": "Nippon Suisan Gakkaishi",
|
|
"publication_year": "1988",
|
|
},
|
|
"entities": [
|
|
{"name": "Oncorhynchus mykiss", "type": "species", "name_resolved": "",
|
|
"synonyms": [], "confidence": 0.95},
|
|
{"name": "alternative complement pathway", "type": "immune_pathway",
|
|
"name_resolved": "", "synonyms": [], "confidence": 0.9},
|
|
{"name": "serum", "type": "biological_sample", "name_resolved": "",
|
|
"synonyms": [], "confidence": 0.9},
|
|
],
|
|
"relations": [
|
|
{
|
|
"source": "Oncorhynchus mykiss", "source_type": "species",
|
|
"source_resolved": "Oncorhynchus mykiss", "source_type_resolved": "species",
|
|
"relation": "activates", "relationship_resolved": "activates",
|
|
"target": "alternative complement pathway", "target_type": "immune_pathway",
|
|
"target_resolved": "alternative complement pathway",
|
|
"target_type_resolved": "immune_pathway",
|
|
"relation_category": "immune_function",
|
|
"evidence": "Serum from rainbow trout showed ACH50 activity of 142 U/ml.",
|
|
"confidence": 0.95, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
{
|
|
"source": "alternative complement pathway", "source_type": "immune_pathway",
|
|
"source_resolved": "alternative complement pathway",
|
|
"source_type_resolved": "immune_pathway",
|
|
"relation": "measured_in", "relationship_resolved": "measured_in",
|
|
"target": "serum", "target_type": "biological_sample",
|
|
"target_resolved": "serum", "target_type_resolved": "biological_sample",
|
|
"relation_category": "physiological_measurement",
|
|
"evidence": "The ACP titer was titrated in serum samples.",
|
|
"confidence": 0.9, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
{
|
|
"source": "Oncorhynchus mykiss", "source_type": "species",
|
|
"source_resolved": "Oncorhynchus mykiss", "source_type_resolved": "species",
|
|
"relation": "has_sample", "relationship_resolved": "has_sample",
|
|
"target": "serum", "target_type": "biological_sample",
|
|
"target_resolved": "serum", "target_type_resolved": "biological_sample",
|
|
"relation_category": "experimental_material",
|
|
"evidence": "Blood was collected from the caudal vein.",
|
|
"confidence": 0.8, "output_layer": "background_relations", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
],
|
|
"chunks": [], "sections": [],
|
|
"metadata": {"version": "16.1.2"},
|
|
},
|
|
{
|
|
"paper_id": "doi:10.1051/alr/1989009",
|
|
"paper": {
|
|
"paper_id": "doi:10.1051/alr/1989009",
|
|
"title": "Suitability of brackish water tilapia species from the Ivory Coast for lagoon aquaculture. I - Reproduction",
|
|
"doi": "10.1051/alr/1989009",
|
|
"pmid": "", "pmcid": "", "journal": "Aquatic Living Resources",
|
|
"publication_year": "1989",
|
|
},
|
|
"entities": [
|
|
{"name": "Oreochromis niloticus", "type": "species", "name_resolved": "",
|
|
"synonyms": [], "confidence": 0.95},
|
|
{"name": "lagoon aquaculture", "type": "culture_system",
|
|
"name_resolved": "", "synonyms": [], "confidence": 0.9},
|
|
{"name": "Ivory Coast", "type": "location", "name_resolved": "",
|
|
"synonyms": [], "confidence": 0.9},
|
|
{"name": "reproductive performance", "type": "biological_trait",
|
|
"name_resolved": "", "synonyms": [], "confidence": 0.85},
|
|
],
|
|
"relations": [
|
|
{
|
|
"source": "Oreochromis niloticus", "source_type": "species",
|
|
"source_resolved": "Oreochromis niloticus", "source_type_resolved": "species",
|
|
"relation": "suited_for", "relationship_resolved": "suited_for",
|
|
"target": "lagoon aquaculture", "target_type": "culture_system",
|
|
"target_resolved": "lagoon aquaculture",
|
|
"target_type_resolved": "culture_system",
|
|
"relation_category": "aquaculture_suitability",
|
|
"evidence": "O. niloticus showed the best reproduction performance among brackish water tilapias.",
|
|
"confidence": 0.9, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
{
|
|
"source": "Oreochromis niloticus", "source_type": "species",
|
|
"source_resolved": "Oreochromis niloticus", "source_type_resolved": "species",
|
|
"relation": "native_to", "relationship_resolved": "native_to",
|
|
"target": "Ivory Coast", "target_type": "location",
|
|
"target_resolved": "Ivory Coast", "target_type_resolved": "location",
|
|
"relation_category": "geographic_distribution",
|
|
"evidence": "Tilapia populations were sampled in lagoons of the Ivory Coast.",
|
|
"confidence": 0.85, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
{
|
|
"source": "Oreochromis niloticus", "source_type": "species",
|
|
"source_resolved": "Oreochromis niloticus", "source_type_resolved": "species",
|
|
"relation": "has_trait", "relationship_resolved": "has_trait",
|
|
"target": "reproductive performance", "target_type": "biological_trait",
|
|
"target_resolved": "reproductive performance",
|
|
"target_type_resolved": "biological_trait",
|
|
"relation_category": "reproductive_biology",
|
|
"evidence": "Mean fecundity was 1200 eggs per female.",
|
|
"confidence": 0.8, "output_layer": "main_kg", "claim_scope": "paper",
|
|
"candidate_status": "", "triple_quality": "", "final_action": "",
|
|
},
|
|
],
|
|
"chunks": [], "sections": [],
|
|
"metadata": {"version": "16.1.2"},
|
|
},
|
|
]
|
|
|
|
|
|
def main() -> None:
|
|
import argparse
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--out", default="fixtures")
|
|
args = parser.parse_args()
|
|
root = Path(args.out)
|
|
for fixture in FIXTURES:
|
|
paper_dir = root / fixture["paper_id"].replace("/", "_")
|
|
paper_dir.mkdir(parents=True, exist_ok=True)
|
|
(paper_dir / "result.json").write_text(
|
|
json.dumps(fixture, ensure_ascii=False, indent=2), encoding="utf-8"
|
|
)
|
|
print(f"wrote {paper_dir}/result.json")
|
|
# pilot manifest
|
|
manifest = {
|
|
"papers": [
|
|
{"paper_id": paper["paper_id"], "result": f"{paper['paper_id'].replace(chr(47), chr(95))}/result.json",
|
|
"paper": paper["paper"]}
|
|
for paper in FIXTURES
|
|
]
|
|
}
|
|
(root / "pilot_manifest.json").write_text(
|
|
json.dumps(manifest, ensure_ascii=False, indent=2), encoding="utf-8"
|
|
)
|
|
print(f"wrote {root}/pilot_manifest.json")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|