dknowc-dsh 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -50
- package/package.json +2 -2
- package/skills/dk-trace-report/SKILL.md +288 -0
- package/skills/dk-trace-report/config/examples/doc.json +56 -0
- package/skills/dk-trace-report/config/examples/legal.json +51 -0
- package/skills/dk-trace-report/config/examples/ppt.json +47 -0
- package/skills/dk-trace-report/config/examples/tax.json +46 -0
- package/skills/dk-trace-report/config/examples/trusted.json +122 -0
- package/skills/dk-trace-report/reference/sample_input.json +60 -0
- package/skills/dk-trace-report/resources/ECHARTS-NOTICE.txt +10 -0
- package/skills/dk-trace-report/resources/echarts.custom.min.js +48 -0
- package/skills/dk-trace-report/scripts/build_report_input.py +333 -0
- package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/chart_embed.py +4 -1
- package/skills/{dknowc-trusted-search → dk-trace-report}/scripts/render_trace_html.py +1072 -537
- package/skills/dk-trace-report/scripts/run_paths.py +95 -0
- package/skills/dk-trace-report/scripts/trust_digest.py +77 -0
- package/skills/dknowc-legal-assistant/README.md +95 -0
- package/skills/dknowc-legal-assistant/SKILL.md +122 -0
- package/skills/dknowc-legal-assistant/attribution.json +5 -0
- package/skills/dknowc-legal-assistant/reference/answer-and-report.md +221 -0
- package/skills/dknowc-legal-assistant/reference/capability-layer.md +143 -0
- package/skills/dknowc-legal-assistant/reference/legal_claims.example.json +96 -0
- package/skills/dknowc-legal-assistant/reference/onboarding_scripts.md +198 -0
- package/skills/dknowc-legal-assistant/reference/policy_tags.json +2002 -0
- package/skills/dknowc-legal-assistant/reference/retrieval-statute.md +81 -0
- package/skills/dknowc-legal-assistant/reference/retrieval-v2.md +133 -0
- package/skills/dknowc-legal-assistant/reference/sample_search_result.md +33 -0
- package/skills/dknowc-legal-assistant/reference/sample_trace_report.html +940 -0
- package/skills/dknowc-legal-assistant/reference/tags.md +53 -0
- package/skills/dknowc-legal-assistant/reference/troubleshooting.md +50 -0
- package/skills/dknowc-legal-assistant/reference/verification-pass.md +59 -0
- package/skills/dknowc-legal-assistant/resources/echarts.custom.min.js +48 -0
- package/skills/dknowc-legal-assistant/scripts/api_key.py +68 -0
- package/skills/dknowc-legal-assistant/scripts/attribution.py +61 -0
- package/skills/dknowc-legal-assistant/scripts/calc_legal.py +375 -0
- package/skills/dknowc-legal-assistant/scripts/calc_period.py +155 -0
- package/skills/dknowc-legal-assistant/scripts/check_answer.py +664 -0
- package/skills/dknowc-legal-assistant/scripts/initialize.py +188 -0
- package/skills/dknowc-legal-assistant/scripts/legal_client.py +208 -0
- package/skills/dknowc-legal-assistant/scripts/legal_search.py +1059 -0
- package/skills/dknowc-legal-assistant/scripts/merge_search_results.py +630 -0
- package/skills/dknowc-legal-assistant/scripts/path_guard.py +92 -0
- package/skills/dknowc-legal-assistant/scripts/question_profile.py +215 -0
- package/skills/dknowc-legal-assistant/scripts/register_key.mjs +1152 -0
- package/skills/dknowc-legal-assistant/scripts/run_eval.py +109 -0
- package/skills/dknowc-legal-assistant/scripts/source_cards.py +321 -0
- package/skills/dknowc-legal-assistant/scripts/tag_catalog.py +162 -0
- package/skills/dknowc-legal-assistant/scripts/trace_report.config.json +66 -0
- package/skills/dknowc-legal-assistant/scripts/verify_claims.py +448 -0
- package/skills/dknowc-legal-assistant/scripts/websearch_convert.py +396 -0
- package/skills/dknowc-official-doc-writer/README.md +45 -25
- package/skills/dknowc-official-doc-writer/SKILL.md +28 -14
- package/skills/dknowc-official-doc-writer/config/trace_report.config.json +56 -0
- package/skills/dknowc-official-doc-writer/official-docs/input//345/274/225/347/224/250/345/257/271/347/205/247_/351/252/214/346/224/266_materials.json +628 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_1555.json +345 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_my.json +728 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_wp.json +159 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/baseline_wp2.json +1006 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/test_tz.json +28 -0
- package/skills/dknowc-official-doc-writer/official-docs/search-results/tmp_q.json +1419 -0
- package/skills/dknowc-official-doc-writer/reference/anti_ai_patterns.md +13 -1
- package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +4 -0
- package/skills/dknowc-official-doc-writer/reference/genre_writing_notes.md +4 -0
- package/skills/dknowc-official-doc-writer/reference/initialization.md +28 -20
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +21 -0
- package/skills/dknowc-official-doc-writer/reference/materials_pipeline.md +64 -7
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +43 -32
- package/skills/dknowc-official-doc-writer/reference/outline_rules.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +19 -20
- package/skills/dknowc-official-doc-writer/reference/research_notes.md +5 -3
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +6 -2
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +45 -33
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +63 -36
- package/skills/dknowc-official-doc-writer/reference/standards/00_index.md +63 -77
- package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +6 -3
- package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +12 -3
- package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +8 -2
- package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/08_tongbao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/09_tonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/10_gonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/11_fuhan_approve.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/12_fuhan_objection.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/13_reminder.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/14_generic.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/16_decision.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/18_order.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/19_gazette.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/20_motion.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/22_application.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/23_publicity.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/25_plan.md +2 -1
- package/skills/dknowc-official-doc-writer/reference/standards/26_summary.md +7 -1
- package/skills/dknowc-official-doc-writer/reference/standards/27_speech.md +4 -1
- package/skills/dknowc-official-doc-writer/reference/standards/99_expressions.md +1 -2
- package/skills/dknowc-official-doc-writer/reference/task_router.md +5 -5
- package/skills/dknowc-official-doc-writer/reference/working_principles.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/writing_method.md +166 -0
- package/skills/dknowc-official-doc-writer/reference/writing_rules.md +11 -5
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +30 -3
- package/skills/dknowc-official-doc-writer/scripts/attribution.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +216 -22
- package/skills/dknowc-official-doc-writer/scripts/check_materials.py +375 -27
- package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +9 -4
- package/skills/dknowc-official-doc-writer/scripts/deep_query.py +3 -2
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +23 -9
- package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +116 -41
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +246 -12
- package/skills/dknowc-official-doc-writer/scripts/local_memory.py +2 -6
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +2 -3
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +113 -13
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +3 -2
- package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +7 -2
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +782 -216
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +120 -13
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +2 -1
- package/skills/dknowc-official-doc-writer/scripts/update_skill.py +339 -0
- package/skills/dknowc-official-doc-writer/scripts/websearch_convert.py +326 -0
- package/skills/dknowc-ppt-assistant/README.md +21 -9
- package/skills/dknowc-ppt-assistant/SKILL.md +29 -20
- package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +3 -2
- package/skills/dknowc-ppt-assistant/config/trace_report.config.json +65 -0
- package/skills/dknowc-ppt-assistant/references/initialization.md +58 -7
- package/skills/dknowc-ppt-assistant/references/material_usage.md +51 -14
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +51 -18
- package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +372 -920
- package/skills/dknowc-ppt-assistant/references/search_intro.md +2 -2
- package/skills/dknowc-ppt-assistant/references/svg-authoring.md +3 -3
- package/skills/dknowc-ppt-assistant/references/upstream-example/README.md +2 -0
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +11 -27
- package/skills/dknowc-ppt-assistant/scripts/attribution.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/build_trace_input.py +188 -0
- package/skills/dknowc-ppt-assistant/scripts/compact_svg_coordinates.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/config.py +9 -9
- package/skills/dknowc-ppt-assistant/scripts/console_encoding.py +1 -2
- package/skills/dknowc-ppt-assistant/scripts/error_helper.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/hyperlink_contract.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +248 -15
- package/skills/dknowc-ppt-assistant/scripts/language_tags.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/mcp_convert.py +7 -14
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +3 -2
- package/skills/dknowc-ppt-assistant/scripts/merge_search_results.py +604 -0
- package/skills/dknowc-ppt-assistant/scripts/native_payloads.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_animations.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/__init__.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/errors.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/formula.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/loader.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/models.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/registry.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantic_hash.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantics.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/animation_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/formula_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/hyperlinks.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_authoring.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_registry_to_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_svg_markup.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/slide_to_svg.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/transition_import.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/pptx_transitions.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/preset_shape_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/preview_slide_html.py +4 -11
- package/skills/dknowc-ppt-assistant/scripts/project_utils.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +890 -341
- package/skills/dknowc-ppt-assistant/scripts/resource_paths.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/shape_boolean_svg.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/slide_roster.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/__init__.py +2 -9
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/align_embed_images.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/crop_images.py +3 -3
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/__init__.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/checker.py +9 -10
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/cli.py +4 -4
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/svg_contracts.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/xml_support.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_quality_checker.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/hyperlinks.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_colors.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_fonts.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/geometry_properties.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_ast.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_compiler.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_omml.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_parser.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_profile.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_run_properties.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/inline_formula.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/builder.py +9 -11
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/cli.py +7 -5
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_structure.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_validation.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/semantic_markers.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/shape_boolean.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/text_outline.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx.py +1 -1
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +51 -17
- package/skills/dknowc-ppt-assistant/scripts/update_skill.py +314 -0
- package/skills/dknowc-ppt-assistant/scripts/update_spec.py +25 -1
- package/skills/dknowc-ppt-assistant/scripts/websearch_convert.py +326 -0
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +99 -34
- package/skills/dknowc-tax-assistant/README.md +54 -0
- package/skills/dknowc-tax-assistant/SKILL.md +99 -0
- package/skills/dknowc-tax-assistant/attribution.json +5 -0
- package/skills/dknowc-tax-assistant/reference/answer-and-report.md +100 -0
- package/skills/dknowc-tax-assistant/reference/capability-layer.md +205 -0
- package/skills/dknowc-tax-assistant/reference/onboarding_scripts.md +68 -0
- package/skills/dknowc-tax-assistant/reference/policy_tags.json +2002 -0
- package/skills/dknowc-tax-assistant/reference/retrieval-policy.md +43 -0
- package/skills/dknowc-tax-assistant/reference/retrieval-v2.md +58 -0
- package/skills/dknowc-tax-assistant/reference/tags.md +53 -0
- package/skills/dknowc-tax-assistant/reference/tax_claims.example.json +76 -0
- package/skills/dknowc-tax-assistant/reference/trace_report.config.json +46 -0
- package/skills/dknowc-tax-assistant/reference/troubleshooting.md +70 -0
- package/skills/dknowc-tax-assistant/reference/websearch-fallback.md +59 -0
- package/skills/dknowc-tax-assistant/resources/THIRD_PARTY_NOTICES.md +9 -0
- package/skills/dknowc-tax-assistant/resources/echarts.custom.min.js +48 -0
- package/skills/dknowc-tax-assistant/scripts/api_key.py +60 -0
- package/skills/dknowc-tax-assistant/scripts/attribution.py +61 -0
- package/skills/dknowc-tax-assistant/scripts/calc_period.py +156 -0
- package/skills/dknowc-tax-assistant/scripts/calc_tax.py +179 -0
- package/skills/dknowc-tax-assistant/scripts/check_answer.py +210 -0
- package/skills/dknowc-tax-assistant/scripts/initialize.py +208 -0
- package/skills/dknowc-tax-assistant/scripts/merge_search_results.py +631 -0
- package/skills/dknowc-tax-assistant/scripts/path_guard.py +23 -0
- package/skills/dknowc-tax-assistant/scripts/question_profile.py +444 -0
- package/skills/dknowc-tax-assistant/scripts/register_key.mjs +1173 -0
- package/skills/dknowc-tax-assistant/scripts/run_dir.py +149 -0
- package/skills/dknowc-tax-assistant/scripts/source_cards.py +372 -0
- package/skills/dknowc-tax-assistant/scripts/tag_catalog.py +164 -0
- package/skills/dknowc-tax-assistant/scripts/tax_client.py +218 -0
- package/skills/dknowc-tax-assistant/scripts/tax_search.py +403 -0
- package/skills/dknowc-tax-assistant/scripts/verify_claims.py +587 -0
- package/skills/dknowc-tax-assistant/scripts/websearch_convert.py +352 -0
- package/skills/dknowc-trusted-search/README.md +29 -23
- package/skills/dknowc-trusted-search/SKILL.md +257 -107
- package/skills/dknowc-trusted-search/config/trace_report.config.json +119 -0
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +40 -15
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +286 -191
- package/skills/dknowc-trusted-search/resources/ECHARTS-NOTICE.txt +10 -0
- package/skills/dknowc-trusted-search/scripts/api_key.py +10 -26
- package/skills/dknowc-trusted-search/scripts/attribution.py +1 -1
- package/skills/dknowc-trusted-search/scripts/build_trace_input.py +173 -0
- package/skills/dknowc-trusted-search/scripts/deep_convert.py +79 -30
- package/skills/dknowc-trusted-search/scripts/deep_query.py +23 -34
- package/skills/dknowc-trusted-search/scripts/initialize.py +353 -12
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +3 -2
- package/skills/dknowc-trusted-search/scripts/merge_search_results.py +222 -35
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +845 -291
- package/skills/dknowc-trusted-search/scripts/source_display.py +59 -0
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +69 -36
- package/skills/dknowc-trusted-search/scripts/update_skill.py +300 -0
- package/skills/dknowc-trusted-search/scripts/websearch_convert.py +328 -0
- package/src/index.js +15 -0
- package/skills/dknowc-official-doc-writer/scripts/mcp_convert.py +0 -287
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +0 -2574
- package/skills/dknowc-ppt-assistant/references/upstream-docs/svg-pipeline.md +0 -842
- package/skills/dknowc-ppt-assistant/scripts/finalize_svg.py +0 -507
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +0 -2642
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/svg_rect_to_path.py +0 -346
- package/skills/dknowc-trusted-search/official-docs/output/.gitkeep +0 -0
- package/skills/dknowc-trusted-search/official-docs/search-results/.gitkeep +0 -0
- package/skills/dknowc-trusted-search/scripts/mcp_convert.py +0 -198
|
@@ -1,2642 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""深知可信PPT 溯源核验报告渲染器:把检索素材 JSON + 答案文件渲染为单文件可核验 HTML。
|
|
3
|
-
|
|
4
|
-
双版支持(--stage):
|
|
5
|
-
- outline 提纲版:结构方案确认门前的提纲答案文件(页面规划表 + 口径事项清单)→ 事前核验
|
|
6
|
-
- final 成稿版:交付时的页面级结论文本 → 事后溯源
|
|
7
|
-
|
|
8
|
-
3.7.x 同源架构(对齐公文写作 3.7.5/3.7.6,参考深知晓交互原型,数据口径保持自有与真实):
|
|
9
|
-
- 顶栏:身份章 + 标题 + 工具组(只看正文 / 复制全文 / 打印归档)+ 阅读进度条
|
|
10
|
-
- Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+ 双视图切换
|
|
11
|
-
- 过程回顾条:检索 → 入库 → 逐条比对 → 核验完成(静态回放,数字全部真实计算)
|
|
12
|
-
- 核验报告视图(默认):核验报告单 + 正文文档流(章节标题 + 句后引文胶囊,点击原地展开溯源卡)
|
|
13
|
-
- 知识专库视图(全屏):大搜索 + 热词(真实计算)+ 检索分组 tabs + 来源文章卡
|
|
14
|
-
- 链接给出方式:接口返回的原文链接**原样进报告**(不做连通性检测、不隐藏);
|
|
15
|
-
接口提供存档快照(screenShotPath)时作为**附加回看入口**与原文链接并存
|
|
16
|
-
(路径容错补 /A/、纯本地格式校验)
|
|
17
|
-
|
|
18
|
-
PPT 特有口径(与公文写作版本的既定差异):
|
|
19
|
-
- 提醒制:数据缺口(缺原文链接/缺摘录)不判不通过、指标恒绿附温和提醒;只有无素材/
|
|
20
|
-
正文无角标/角标未绑定三种真实错误才判不通过
|
|
21
|
-
- 双版 stage:提纲版(事前核验)与成稿版(事后溯源)同脚本同形式,标题与身份章带版本后缀
|
|
22
|
-
- 双形态 JSON:素材数组认顶层 {"检索文章": [...]} 或原始接口 content.data.检索文章
|
|
23
|
-
- 未引用判定双通道:JSON 标记(recalled_materials)∪ 正文角标未引用
|
|
24
|
-
- 去重键含角标:同一文章被赋不同角标时各留一卡;双向硬校验(exit 2)
|
|
25
|
-
|
|
26
|
-
诚实原则:脚本真实计算的结果才打勾;政策现行效力等无法自动判定项归入"建议人工复核"。
|
|
27
|
-
布局为单文件静态 HTML;打印归档模式单栏全展开并附材料附录。
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
from __future__ import annotations
|
|
31
|
-
|
|
32
|
-
import argparse
|
|
33
|
-
import html
|
|
34
|
-
import json
|
|
35
|
-
import re
|
|
36
|
-
import sys
|
|
37
|
-
from datetime import datetime
|
|
38
|
-
from html.parser import HTMLParser
|
|
39
|
-
from pathlib import Path
|
|
40
|
-
from typing import Any, Dict, List, Optional, Tuple
|
|
41
|
-
from urllib.parse import urlsplit
|
|
42
|
-
|
|
43
|
-
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
44
|
-
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
45
|
-
import os as _os
|
|
46
|
-
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
47
|
-
if not _ws:
|
|
48
|
-
# dsh 会话隔离:每会话独立产物目录 <工作区>/dknowc-output/<DSH_SESSION_ID前8位>/,
|
|
49
|
-
# 多会话共用同一工作区时互不混杂;非 dsh 环境回退为工作区本身。
|
|
50
|
-
_sid = _os.environ.get("DSH_SESSION_ID", "")
|
|
51
|
-
_ws = str(Path(_os.getcwd()) / "dknowc-output" / (_sid[:8] if _sid else "_default"))
|
|
52
|
-
WS_ROOT = Path(_ws).resolve()
|
|
53
|
-
SEARCH_RESULTS_DIR = WS_ROOT / "official-docs" / "search-results"
|
|
54
|
-
OUTPUT_DIR = WS_ROOT / "official-docs" / "output"
|
|
55
|
-
|
|
56
|
-
STAGE_LABELS = {"outline": "提纲版", "final": "成稿版"}
|
|
57
|
-
REPORT_NAME = "溯源核验报告"
|
|
58
|
-
|
|
59
|
-
# 快照兜底开关:默认启用。接口 screenShotPath 曾存在路径缺 /A/ 层级的拼接 bug;
|
|
60
|
-
# verify_snapshots 在展示前完成"补 /A/ 修订 + 纯本地格式校验 + 非法弃用"。
|
|
61
|
-
SNAPSHOT_ENABLED = True
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _is_within(path: Path, parent: Path) -> bool:
|
|
65
|
-
try:
|
|
66
|
-
path.relative_to(parent)
|
|
67
|
-
return True
|
|
68
|
-
except ValueError:
|
|
69
|
-
return False
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def _safe_input_path(value: str, allowed_suffixes: set) -> Path:
|
|
73
|
-
"""把待读取文件定位到 skill 的 official-docs/search-results/ 内。"""
|
|
74
|
-
raw = Path(value).expanduser()
|
|
75
|
-
resolved = raw.resolve() if raw.is_absolute() else (SEARCH_RESULTS_DIR / raw.name).resolve()
|
|
76
|
-
if resolved.suffix.lower() not in allowed_suffixes:
|
|
77
|
-
raise ValueError(f"只允许读取 {', '.join(sorted(allowed_suffixes))} 文件: {value}")
|
|
78
|
-
if not _is_within(resolved, SEARCH_RESULTS_DIR.resolve()):
|
|
79
|
-
raise ValueError(f"输入文件必须位于 official-docs/search-results/ 内: {SEARCH_RESULTS_DIR}")
|
|
80
|
-
return resolved
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def _safe_output_path(value: str, allowed_suffixes: set, default_suffix: str) -> Path:
|
|
84
|
-
"""把输出文件定位到 skill 的 official-docs/output/ 内。"""
|
|
85
|
-
raw = Path(value).expanduser()
|
|
86
|
-
resolved = raw.resolve() if raw.is_absolute() else (OUTPUT_DIR / raw.name).resolve()
|
|
87
|
-
if resolved.suffix.lower() not in allowed_suffixes:
|
|
88
|
-
resolved = resolved.with_suffix(default_suffix)
|
|
89
|
-
if not _is_within(resolved, OUTPUT_DIR.resolve()):
|
|
90
|
-
raise ValueError(f"输出文件必须位于 official-docs/output/ 内: {OUTPUT_DIR}")
|
|
91
|
-
return resolved
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# ============================================================
|
|
95
|
-
# 基础工具
|
|
96
|
-
# ============================================================
|
|
97
|
-
|
|
98
|
-
def esc(value: Any) -> str:
|
|
99
|
-
return html.escape(str(value or ""), quote=True)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def safe_url(value: Any) -> str:
|
|
103
|
-
"""外链协议白名单:仅放行 http/https,其余(javascript:/data:/file: 等)返回空串。
|
|
104
|
-
|
|
105
|
-
所有 href 一律经由本函数,非法协议链接不渲染(防点击执行)。
|
|
106
|
-
"""
|
|
107
|
-
url = str(value or "").strip()
|
|
108
|
-
if not url:
|
|
109
|
-
return ""
|
|
110
|
-
try:
|
|
111
|
-
scheme = urlsplit(url).scheme.lower()
|
|
112
|
-
except ValueError:
|
|
113
|
-
return ""
|
|
114
|
-
return url if scheme in ("http", "https") else ""
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
def dumps_for_script(obj: Any) -> str:
|
|
118
|
-
"""嵌入 <script> 的序列化:补全字符级转义防注入(< > & 全转义,不只是 </)。"""
|
|
119
|
-
s = json.dumps(obj, ensure_ascii=False)
|
|
120
|
-
return s.replace("<", "\\u003c").replace(">", "\\u003e").replace("&", "\\u0026")
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def load_json(path: Path) -> Dict[str, Any]:
|
|
124
|
-
with path.open("r", encoding="utf-8") as f:
|
|
125
|
-
data = json.load(f)
|
|
126
|
-
if isinstance(data, dict):
|
|
127
|
-
return data
|
|
128
|
-
return {"data": data}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def unwrap(data: Dict[str, Any]) -> Dict[str, Any]:
|
|
132
|
-
if isinstance(data.get("data"), dict) and data.get("success") is True:
|
|
133
|
-
return data["data"]
|
|
134
|
-
if isinstance(data.get("content"), dict):
|
|
135
|
-
return data["content"]
|
|
136
|
-
return data
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def first_str(*values: Any) -> str:
|
|
140
|
-
for value in values:
|
|
141
|
-
if isinstance(value, str) and value.strip():
|
|
142
|
-
return value.strip()
|
|
143
|
-
if value not in (None, "", [], {}) and not isinstance(value, (dict, list)):
|
|
144
|
-
return str(value).strip()
|
|
145
|
-
return ""
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def short(text: Any, limit: int = 360) -> str:
|
|
149
|
-
value = " ".join(str(text or "").split())
|
|
150
|
-
if len(value) <= limit:
|
|
151
|
-
return value
|
|
152
|
-
return value[:limit].rstrip() + "..."
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
def strip_tags(text: str) -> str:
|
|
156
|
-
return re.sub(r"<[^>]+>", "", text or "")
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def normalize_citations(text: str) -> str:
|
|
160
|
-
text = strip_tags(text)
|
|
161
|
-
text = re.sub(r"【\s*(\d+)\s*】", r"[\1]", text)
|
|
162
|
-
return re.sub(r"\[\^?(\d+)\^?\]", r"[\1]", text)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
def strip_citation_markers(text: str) -> str:
|
|
166
|
-
text = strip_tags(text)
|
|
167
|
-
text = re.sub(r"【\s*\d+\s*】", "", text)
|
|
168
|
-
text = re.sub(r"\[\^?\d+\^?\]", "", text)
|
|
169
|
-
text = re.sub(r"[ \t]+(\n)", r"\1", text)
|
|
170
|
-
text = re.sub(r"\n{3,}", "\n\n", text)
|
|
171
|
-
return text.strip() + ("\n" if text.strip() else "")
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
# ============================================================
|
|
175
|
-
# 素材四分类
|
|
176
|
-
# ============================================================
|
|
177
|
-
|
|
178
|
-
KIND_CATALOG = {
|
|
179
|
-
"policy": ("政策依据", "pol"),
|
|
180
|
-
"data": ("数据支撑", "dat"),
|
|
181
|
-
"case": ("参考案例", "cas"),
|
|
182
|
-
"reference": ("表述参考", "ref"),
|
|
183
|
-
"material": ("材料", "mat"),
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
def normalize_kind(raw: str) -> Tuple[str, str]:
|
|
188
|
-
"""把来源类型文本归一化为(类型键, 中文标签);css 类名查 KIND_CATALOG。"""
|
|
189
|
-
text = str(raw or "")
|
|
190
|
-
if "政策" in text or "法规" in text or "依据" in text or "policy" in text.lower():
|
|
191
|
-
key = "policy"
|
|
192
|
-
elif "数据" in text or "统计" in text or "指标" in text or "data" in text.lower():
|
|
193
|
-
key = "data"
|
|
194
|
-
elif "案例" in text or "经验" in text or "做法" in text or "case" in text.lower():
|
|
195
|
-
key = "case"
|
|
196
|
-
elif "表述" in text or "行文" in text or "reference" in text.lower():
|
|
197
|
-
key = "reference"
|
|
198
|
-
else:
|
|
199
|
-
key = "material"
|
|
200
|
-
label, _css = KIND_CATALOG[key]
|
|
201
|
-
return key, label
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
def parse_year_month(raw: str) -> Optional[Tuple[int, int]]:
|
|
205
|
-
"""从日期文本提取(年, 月);识别 2025年8月 / 2025-08 / 2025.08 / 2025-08-15。"""
|
|
206
|
-
text = str(raw or "").strip()
|
|
207
|
-
if not text:
|
|
208
|
-
return None
|
|
209
|
-
m = re.search(r"(20\d{2})\s*[年./-]\s*(\d{1,2})", text)
|
|
210
|
-
if m:
|
|
211
|
-
return int(m.group(1)), min(int(m.group(2)), 12)
|
|
212
|
-
m = re.search(r"(20\d{2})", text)
|
|
213
|
-
if m:
|
|
214
|
-
return int(m.group(1)), 1
|
|
215
|
-
return None
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
# ============================================================
|
|
219
|
-
# 素材提取(数据层:材料级编号优先 + 位置兜底 + 双形态 JSON)
|
|
220
|
-
# ============================================================
|
|
221
|
-
|
|
222
|
-
def clean_paragraph_noise(text: str) -> str:
|
|
223
|
-
"""清洗接口段落文本中的附件链接噪音。
|
|
224
|
-
|
|
225
|
-
接口段落内容格式为「段落标题 https://attach.dknowc.cn/file/<正文>」——
|
|
226
|
-
URL 前是段落标题(已由标题链单独展示),URL 本身是附件地址(卡片有"查看全文"入口)。
|
|
227
|
-
摘录只保留 URL 之后的正文;无该前缀时兜底剔除文本中的裸 URL。
|
|
228
|
-
"""
|
|
229
|
-
value = str(text or "")
|
|
230
|
-
m = re.search(r"https?://\S*attach\.dknowc\.cn/file/", value)
|
|
231
|
-
if m:
|
|
232
|
-
return value[m.end():].strip()
|
|
233
|
-
value = re.sub(r"https?://\S+", " ", value)
|
|
234
|
-
return re.sub(r"[ \t]{2,}", " ", value).strip()
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
def paragraph_text(item: Dict[str, Any]) -> str:
|
|
238
|
-
paragraphs = item.get("content") or item.get("段落") or item.get("paragraphs") or item.get("paragraphList")
|
|
239
|
-
if isinstance(paragraphs, list):
|
|
240
|
-
chunks = []
|
|
241
|
-
for para in paragraphs:
|
|
242
|
-
if isinstance(para, dict):
|
|
243
|
-
chunk = first_str(para.get("text"), para.get("内容"), para.get("content"), para.get("summary"), para.get("标题"), para.get("title"))
|
|
244
|
-
else:
|
|
245
|
-
chunk = str(para)
|
|
246
|
-
chunk = clean_paragraph_noise(chunk)
|
|
247
|
-
if chunk:
|
|
248
|
-
chunks.append(chunk)
|
|
249
|
-
text = "\n".join(chunks)
|
|
250
|
-
if text:
|
|
251
|
-
return text
|
|
252
|
-
return clean_paragraph_noise(first_str(
|
|
253
|
-
item.get("摘录"),
|
|
254
|
-
item.get("摘要"),
|
|
255
|
-
item.get("相关段落"),
|
|
256
|
-
item.get("支撑内容"),
|
|
257
|
-
item.get("support"),
|
|
258
|
-
item.get("全文"),
|
|
259
|
-
item.get("content"),
|
|
260
|
-
item.get("text"),
|
|
261
|
-
item.get("snippet"),
|
|
262
|
-
))
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
def content_segments(item: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
266
|
-
paragraphs = item.get("content") or item.get("段落") or item.get("paragraphs") or item.get("paragraphList")
|
|
267
|
-
segments: List[Dict[str, str]] = []
|
|
268
|
-
if not isinstance(paragraphs, list):
|
|
269
|
-
return segments
|
|
270
|
-
for para in paragraphs:
|
|
271
|
-
if isinstance(para, dict):
|
|
272
|
-
text = first_str(para.get("text"), para.get("内容"), para.get("content"), para.get("summary"))
|
|
273
|
-
title = first_str(para.get("title"), para.get("标题"), para.get("name"))
|
|
274
|
-
pid = first_str(para.get("id"), para.get("idx"), para.get("index"), para.get("seq"), para.get("编号"))
|
|
275
|
-
if text or title:
|
|
276
|
-
segments.append({"id": pid, "title": title, "text": text})
|
|
277
|
-
else:
|
|
278
|
-
text = first_str(para)
|
|
279
|
-
if text:
|
|
280
|
-
segments.append({"id": "", "title": "", "text": text})
|
|
281
|
-
return segments
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict[str, str]] = None) -> Dict[str, str]:
|
|
285
|
-
vo = item.get("vo") if isinstance(item.get("vo"), dict) else {}
|
|
286
|
-
segment = segment or {}
|
|
287
|
-
# 材料级编号(角标/编号/materialIndex 等)优先;段落 id 是文章内段落序号(各篇独立
|
|
288
|
-
# 从 1 起,多篇同为 "1" 会互相冲突导致角标错乱),彻底不用作材料编号。
|
|
289
|
-
explicit_id = first_str(
|
|
290
|
-
item.get("角标"),
|
|
291
|
-
item.get("编号"),
|
|
292
|
-
item.get("materialIndex"),
|
|
293
|
-
item.get("referenceIndex"),
|
|
294
|
-
item.get("serialNo"),
|
|
295
|
-
item.get("引用编号"),
|
|
296
|
-
item.get("index"),
|
|
297
|
-
item.get("idx"),
|
|
298
|
-
item.get("seq"),
|
|
299
|
-
vo.get("index"),
|
|
300
|
-
vo.get("idx"),
|
|
301
|
-
)
|
|
302
|
-
if explicit_id:
|
|
303
|
-
match = re.search(r"\d+", explicit_id)
|
|
304
|
-
explicit_id = match.group(0) if match else ""
|
|
305
|
-
source = {
|
|
306
|
-
"id": explicit_id or str(index),
|
|
307
|
-
"title": first_str(
|
|
308
|
-
item.get("文章标题"),
|
|
309
|
-
item.get("material_name"),
|
|
310
|
-
item.get("材料名称"),
|
|
311
|
-
item.get("title"),
|
|
312
|
-
item.get("标题"),
|
|
313
|
-
item.get("name"),
|
|
314
|
-
vo.get("showTitle"),
|
|
315
|
-
vo.get("title"),
|
|
316
|
-
"未命名来源文章",
|
|
317
|
-
),
|
|
318
|
-
"agency": first_str(
|
|
319
|
-
item.get("unit") if not isinstance(item.get("unit"), list) else "、".join(str(x) for x in item.get("unit")[:3]),
|
|
320
|
-
item.get("sourceElement"),
|
|
321
|
-
item.get("数据源"),
|
|
322
|
-
item.get("发布或实施机构"),
|
|
323
|
-
item.get("发布机关"),
|
|
324
|
-
item.get("来源"),
|
|
325
|
-
vo.get("typeName"),
|
|
326
|
-
vo.get("sourceName"),
|
|
327
|
-
),
|
|
328
|
-
"date": first_str(item.get("发布日期"), item.get("date"), item.get("发布时间"), item.get("createDate"), vo.get("dateTime"), vo.get("createDate")),
|
|
329
|
-
"url": first_str(item.get("sourceUrl"), item.get("source_url"), item.get("源网址"), item.get("原文链接"), item.get("url"), item.get("原文"), vo.get("sourceUrl"), vo.get("url")),
|
|
330
|
-
"policy_url": first_str(item.get("policyUrl"), item.get("policy_url"), item.get("知识专库原文"),
|
|
331
|
-
item.get("知识专库链接"), vo.get("policyUrl")),
|
|
332
|
-
"excerpt": segment.get("text") or paragraph_text(item),
|
|
333
|
-
"section": first_str(item.get("正文对应"), item.get("section"), item.get("支撑")),
|
|
334
|
-
"kind": first_str(item.get("类型"), item.get("type"), item.get("素材类型"), vo.get("typeName"), "材料"),
|
|
335
|
-
"verify_note": first_str(item.get("核验"), item.get("verification"), item.get("核验说明")),
|
|
336
|
-
"area": first_str(item.get("intentionArea"), item.get("area"), item.get("地域")),
|
|
337
|
-
}
|
|
338
|
-
# 段落级数据(多段分块展示用):每段 {chain:[文章,章节,子节...], text}
|
|
339
|
-
# 段落标题自带 > 层级,拆级成面包屑;段落标题与文章标题相同或缺失时链只含文章一级。
|
|
340
|
-
segments = []
|
|
341
|
-
for seg in content_segments(item):
|
|
342
|
-
seg_title = first_str(seg.get("title"))
|
|
343
|
-
levels = [lvl.strip() for lvl in re.split(r"\s*>\s*", seg_title) if lvl.strip()] if seg_title else []
|
|
344
|
-
if levels and levels[0] == source["title"]:
|
|
345
|
-
levels = levels[1:]
|
|
346
|
-
seg_text = clean_paragraph_noise(seg.get("text"))
|
|
347
|
-
chain_lvls = [source["title"]] + levels
|
|
348
|
-
segments.append({"chain": chain_lvls, "text": strip_leading_chain(seg_text, chain_lvls)})
|
|
349
|
-
source["segments"] = segments
|
|
350
|
-
# 首段章节位置(兼容旧单行引用处)
|
|
351
|
-
first_chain = segments[0]["chain"][1:] if segments else []
|
|
352
|
-
source["doc_section"] = " › ".join(first_chain)
|
|
353
|
-
source["chain_full"] = " › ".join(segments[0]["chain"]) if segments else ""
|
|
354
|
-
# 发文字号:必须是标准格式(〔年份〕序号号);描述性文字("XX印发"类自造
|
|
355
|
-
# 描述)不显示、当无文号处理(对齐公文写作 3.7.3,实测模型把文号写成
|
|
356
|
-
# "中办、国办 2026 年印发"类描述导致关键性行失真)。
|
|
357
|
-
_dn = first_str(item.get("文号"), item.get("发文字号"), item.get("doc_number"))
|
|
358
|
-
source["doc_number"] = _dn if re.search(r"〔\d{4}〕\s*\d+\s*号", _dn) else ""
|
|
359
|
-
# V2 文章级新字段(生效/失效日期、文章类型):只认接口字段,空则不显示;
|
|
360
|
-
# 文号不从段落正文提取(V2 的 policyFiles.writtenText 实测为空,文号统一取文章级字段)。
|
|
361
|
-
source["effective_date"] = first_str(item.get("生效日期"), item.get("effective_date"))
|
|
362
|
-
source["expiry_date"] = first_str(item.get("失效日期"), item.get("expiry_date"))
|
|
363
|
-
source["article_type"] = first_str(item.get("文章类型"), item.get("article_type"))
|
|
364
|
-
# 所属搜索条件(多路检索分组)与引用状态(未引用=接口召回但正文未采用)
|
|
365
|
-
source["search_key"] = first_str(item.get("搜索条件"), item.get("search_key"))
|
|
366
|
-
source["used"] = item.get("已引用", item.get("used", True))
|
|
367
|
-
if not isinstance(source["used"], bool):
|
|
368
|
-
source["used"] = True
|
|
369
|
-
# 存档快照(接口 screenShotPath):**附加回看入口**,与原文链接并存展示。
|
|
370
|
-
# 2026-10-08 起不做链接连通性检测(链接原样给出):接口返回的链接
|
|
371
|
-
# 原样进报告,"打不开"不再由脚本判定、也不隐藏链接。
|
|
372
|
-
source["snapshot"] = first_str(item.get("快照链接"), item.get("snapshot"), item.get("screenShotPath"))
|
|
373
|
-
# 发布日期可信度(实测:「高」=模型治理入库、标题模型精抽;「较高」=门户抓取、标题规则提取)
|
|
374
|
-
source["conf"] = first_str(item.get("发布日期可信度"), item.get("可信度"), item.get("confidence"))
|
|
375
|
-
key, label = normalize_kind(source["kind"])
|
|
376
|
-
source["type_key"] = key
|
|
377
|
-
source["type_label"] = label
|
|
378
|
-
source["type_css"] = KIND_CATALOG[key][1]
|
|
379
|
-
live_url = bool(source["url"] and source["url"] != "接口未返回")
|
|
380
|
-
source["has_link"] = live_url or bool(source["policy_url"]) or bool(source["snapshot"])
|
|
381
|
-
# 核验状态只看摘录可比对;原文链接死活与快照有无是回看通道问题,不影响核验结论
|
|
382
|
-
# (PPT 提醒制:数据缺口不判不通过,卡片与指标行温和提醒)
|
|
383
|
-
source["verified"] = bool(source["excerpt"])
|
|
384
|
-
return source
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
def extract_articles_from_search(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
388
|
-
# 兼容两种形态:原始接口的 content.data.检索文章(嵌套)与手工合并 JSON 的
|
|
389
|
-
# 顶层 检索文章(Agent 合并时常剥掉接口包装,与 self_check 平级)。
|
|
390
|
-
content = payload.get("content") if isinstance(payload.get("content"), dict) else payload
|
|
391
|
-
data = content.get("data") if isinstance(content.get("data"), dict) else content.get("data")
|
|
392
|
-
articles: List[Dict[str, Any]] = []
|
|
393
|
-
if isinstance(data, dict) and isinstance(data.get("检索文章"), list):
|
|
394
|
-
articles.extend(x for x in data["检索文章"] if isinstance(x, dict))
|
|
395
|
-
if isinstance(payload.get("检索文章"), list):
|
|
396
|
-
articles.extend(x for x in payload["检索文章"] if isinstance(x, dict))
|
|
397
|
-
return articles
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
def extract_articles_from_deep(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
401
|
-
events = payload.get("events")
|
|
402
|
-
if isinstance(events, list):
|
|
403
|
-
for event in events:
|
|
404
|
-
if isinstance(event, list) and len(event) == 2:
|
|
405
|
-
name, obj = event
|
|
406
|
-
elif isinstance(event, dict):
|
|
407
|
-
name, obj = event.get("event"), event
|
|
408
|
-
else:
|
|
409
|
-
continue
|
|
410
|
-
if name == "result" and isinstance(obj, dict):
|
|
411
|
-
data = obj.get("data")
|
|
412
|
-
result_list = data.get("list") if isinstance(data, dict) else None
|
|
413
|
-
if isinstance(result_list, list):
|
|
414
|
-
return [x for x in result_list if isinstance(x, dict)]
|
|
415
|
-
data = payload.get("data")
|
|
416
|
-
result_list = data.get("list") if isinstance(data, dict) else None
|
|
417
|
-
if isinstance(result_list, list):
|
|
418
|
-
return [x for x in result_list if isinstance(x, dict)]
|
|
419
|
-
return []
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
def extract_reference_materials(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
423
|
-
materials = payload.get("referenceMaterials")
|
|
424
|
-
if isinstance(materials, list):
|
|
425
|
-
return [x for x in materials if isinstance(x, dict)]
|
|
426
|
-
return []
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
def collect_raw_articles(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
430
|
-
"""链接检测/快照校验的作用对象:全部原始材料 dict(含未引用召回),就地修改生效。"""
|
|
431
|
-
raws: List[Dict[str, Any]] = []
|
|
432
|
-
raws.extend(extract_reference_materials(payload))
|
|
433
|
-
raws.extend(extract_articles_from_search(payload))
|
|
434
|
-
raws.extend(extract_articles_from_deep(payload))
|
|
435
|
-
recalled = payload.get("recalled_materials") or payload.get("召回材料")
|
|
436
|
-
if isinstance(recalled, list):
|
|
437
|
-
raws.extend(x for x in recalled if isinstance(x, dict))
|
|
438
|
-
return raws
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
def _dedupe_key(source: Dict[str, Any]) -> tuple:
|
|
442
|
-
"""归一去重键:标题 + 原网址(对齐公文 3.7.8 / 可信搜索 1.4.4 的同款修复)。
|
|
443
|
-
|
|
444
|
-
旧键含 id(材料编号),而 id 要么是位置兜底序号、要么是角标号——同一篇文章被
|
|
445
|
-
多路召回或按段落返回多条片段时,各条 id 不同,含 id 的键**等于从不去重**,
|
|
446
|
-
同名卡片会成批出现(实测《医疗保障法》重复 17 张)。改为:
|
|
447
|
-
标题去空白、URL 去尾斜杠后组键;单边缺失退用其一,均缺失退用摘录前缀
|
|
448
|
-
(避免把"信息都缺"的不同材料并成一张)。
|
|
449
|
-
"""
|
|
450
|
-
title = re.sub(r"\s+", "", str(source.get("title") or ""))
|
|
451
|
-
url = str(source.get("url") or "").strip().rstrip("/")
|
|
452
|
-
if title and url:
|
|
453
|
-
return ("t+u", title, url)
|
|
454
|
-
if title:
|
|
455
|
-
return ("t", title)
|
|
456
|
-
if url:
|
|
457
|
-
return ("u", url)
|
|
458
|
-
return ("x", re.sub(r"\s+", "", (source.get("excerpt") or "")[:80]))
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
def extract_sources(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
462
|
-
raw_sources: List[Dict[str, Any]] = []
|
|
463
|
-
raw_sources.extend(extract_reference_materials(payload))
|
|
464
|
-
raw_sources.extend(extract_articles_from_search(payload))
|
|
465
|
-
raw_sources.extend(extract_articles_from_deep(payload))
|
|
466
|
-
# 未引用召回材料(接口召回但正文未采用,agent 筛选后全量放入 recalled_materials):
|
|
467
|
-
# 进面板「未引用」分组,不占正文角标编号,不参与核验统计。
|
|
468
|
-
recalled = payload.get("recalled_materials") or payload.get("召回材料")
|
|
469
|
-
if isinstance(recalled, list):
|
|
470
|
-
raw_sources.extend({**{"已引用": False}, **x} for x in recalled if isinstance(x, dict))
|
|
471
|
-
|
|
472
|
-
sources: List[Dict[str, Any]] = []
|
|
473
|
-
by_key: Dict[tuple, Dict[str, Any]] = {}
|
|
474
|
-
for item in raw_sources:
|
|
475
|
-
# 一篇材料一张卡:段落合并为摘录(paragraph_text 拼接全部段落),不按段落拆卡。
|
|
476
|
-
source = source_from_article(item, len(sources) + 1)
|
|
477
|
-
key = _dedupe_key(source)
|
|
478
|
-
existing = by_key.get(key)
|
|
479
|
-
if existing is not None:
|
|
480
|
-
# 同文再次出现:**不新建卡**(消除重复卡片),把它的编号并入已有卡——
|
|
481
|
-
# 提纲里同一篇文章可能占多个角标(如 [8] 与 [13]),合并后卡上并列显示
|
|
482
|
-
# 全部编号,正文引用任一编号都能定位到这张卡(既去重、又不产生"未绑定"红项)。
|
|
483
|
-
sid = str(source["id"] or "").strip()
|
|
484
|
-
if sid and sid not in existing["all_ids"]:
|
|
485
|
-
existing["all_ids"].append(sid)
|
|
486
|
-
# 已引用优先:未引用召回与已引用同名同链时,以已引用为准(不留两张卡)
|
|
487
|
-
if source.get("used", True) and not existing.get("used", True):
|
|
488
|
-
existing["used"] = True
|
|
489
|
-
continue
|
|
490
|
-
source["all_ids"] = [str(source["id"])] if source.get("id") else []
|
|
491
|
-
by_key[key] = source
|
|
492
|
-
sources.append(source)
|
|
493
|
-
return sources
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
def collect_material_ids(source: Dict[str, Any]) -> List[str]:
|
|
497
|
-
"""材料的全部编号(主编号 + 同文异号并入的其它编号),用于角标绑定与卡片显示。"""
|
|
498
|
-
ids = [str(i) for i in (source.get("all_ids") or []) if str(i).strip()]
|
|
499
|
-
main = str(source.get("id") or "").strip()
|
|
500
|
-
if main and main not in ids:
|
|
501
|
-
ids.insert(0, main)
|
|
502
|
-
return ids
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
def extract_answer(payload: Dict[str, Any]) -> str:
|
|
506
|
-
resp = payload.get("resp")
|
|
507
|
-
if isinstance(resp, dict):
|
|
508
|
-
answer = first_str(resp.get("content"), resp.get("answer"), resp.get("text"))
|
|
509
|
-
if answer:
|
|
510
|
-
return normalize_citations(answer)
|
|
511
|
-
answer = first_str(payload.get("answer"), payload.get("contentText"), payload.get("text"))
|
|
512
|
-
if answer:
|
|
513
|
-
return normalize_citations(answer)
|
|
514
|
-
articles = extract_articles_from_search(payload)
|
|
515
|
-
if articles:
|
|
516
|
-
rows = ["可信搜索召回了以下重点来源文章:"]
|
|
517
|
-
for idx, item in enumerate(articles[:8], start=1):
|
|
518
|
-
rows.append(f"[{idx}] {first_str(item.get('文章标题'), item.get('title'), item.get('标题'), '未命名材料')}")
|
|
519
|
-
return "\n".join(rows)
|
|
520
|
-
deep_articles = extract_articles_from_deep(payload)
|
|
521
|
-
if deep_articles:
|
|
522
|
-
rows = ["深度搜索召回了以下重点来源文章:"]
|
|
523
|
-
for idx, item in enumerate(deep_articles[:8], start=1):
|
|
524
|
-
vo = item.get("vo") if isinstance(item.get("vo"), dict) else {}
|
|
525
|
-
rows.append(f"[{idx}] {first_str(vo.get('showTitle'), vo.get('title'), item.get('title'), '未命名材料')}")
|
|
526
|
-
return "\n".join(rows)
|
|
527
|
-
return "接口返回中未识别到正文内容;请查看知识专库或原始 JSON。"
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
def extract_question(payload: Dict[str, Any]) -> str:
|
|
531
|
-
content = payload.get("content") if isinstance(payload.get("content"), dict) else payload
|
|
532
|
-
data = content.get("data") if isinstance(content.get("data"), dict) else {}
|
|
533
|
-
return first_str(
|
|
534
|
-
payload.get("question"),
|
|
535
|
-
payload.get("input"),
|
|
536
|
-
payload.get("query"),
|
|
537
|
-
data.get("用户问题"),
|
|
538
|
-
content.get("query"),
|
|
539
|
-
content.get("question"),
|
|
540
|
-
)
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
def citation_ids(answer: str) -> List[str]:
|
|
544
|
-
ids: List[str] = []
|
|
545
|
-
for match in re.finditer(r"\[(\d+)\]", answer):
|
|
546
|
-
item = match.group(1)
|
|
547
|
-
if item not in ids:
|
|
548
|
-
ids.append(item)
|
|
549
|
-
return ids
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
# ============================================================
|
|
553
|
-
# 核验计算(报告级)
|
|
554
|
-
# ============================================================
|
|
555
|
-
|
|
556
|
-
SELF_CHECK_ITEMS = [
|
|
557
|
-
("fact_basis", "事实有据"),
|
|
558
|
-
("quality", "质检通过"),
|
|
559
|
-
("placeholders", "无占位残留"),
|
|
560
|
-
("chart_sources", "图表有来源注"),
|
|
561
|
-
("caliber", "口径一致"),
|
|
562
|
-
]
|
|
563
|
-
|
|
564
|
-
SELF_CHECK_LABELS = dict(SELF_CHECK_ITEMS)
|
|
565
|
-
SELF_CHECK_LABELS.update({
|
|
566
|
-
"事实有据": "事实有据", "质检通过": "质检通过", "无占位残留": "无占位残留",
|
|
567
|
-
"图表有来源注": "图表有来源注", "口径一致": "口径一致",
|
|
568
|
-
})
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
def classify_check_value(raw: Any) -> Tuple[str, str]:
|
|
572
|
-
"""把自检项的值解析为(状态, 核验说明)。
|
|
573
|
-
|
|
574
|
-
兼容多种写法:`pass` / `true` / `通过` / `通过:说明文字` / `✓` 等;
|
|
575
|
-
值后面的说明文字保留下来供核验单展示。红项(fail)只给显式声明的
|
|
576
|
-
"未通过";无法识别的描述性文本按"未记录"(none)处理不判红——
|
|
577
|
-
自检书写格式走样不应被放大成核验红项(对齐公文写作 3.7.3,实测
|
|
578
|
-
模型写入"备注"等额外键导致交付前检查误判红)。
|
|
579
|
-
"""
|
|
580
|
-
text = str(raw or "").strip()
|
|
581
|
-
lowered = text.lower()
|
|
582
|
-
for prefix in ("未通过", "不通过", "不合格", "fail", "false", "否", "✗", "no"):
|
|
583
|
-
if lowered.startswith(prefix):
|
|
584
|
-
return "fail", text[len(prefix):].lstrip("::,,、 ").strip()
|
|
585
|
-
for prefix in ("已通过", "通过", "合格", "pass", "ok", "true", "是", "✓", "yes"):
|
|
586
|
-
if lowered.startswith(prefix):
|
|
587
|
-
return "pass", text[len(prefix):].lstrip("::,,、 ").strip()
|
|
588
|
-
return "none", text
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
def normalize_self_check(raw: Any) -> Optional[Dict[str, Tuple[str, str]]]:
|
|
592
|
-
if not isinstance(raw, dict):
|
|
593
|
-
return None
|
|
594
|
-
items: Dict[str, Tuple[str, str]] = {}
|
|
595
|
-
for key, value in raw.items():
|
|
596
|
-
# 只认五项标准自检键(英文/中文变体映射);白名单外的键(备注、待核验、
|
|
597
|
-
# 下一步补充等描述性额外键)不计入核验单——分母不被撑大,多余键不构成
|
|
598
|
-
# "交付前检查"定义的核验项。
|
|
599
|
-
label = SELF_CHECK_LABELS.get(key) or SELF_CHECK_LABELS.get(str(key))
|
|
600
|
-
if label is None:
|
|
601
|
-
continue
|
|
602
|
-
status, note = classify_check_value(value)
|
|
603
|
-
items[label] = (status, note)
|
|
604
|
-
return items or None
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Dict[str, Any],
|
|
608
|
-
generated_at: Optional[datetime] = None) -> Dict[str, Any]:
|
|
609
|
-
"""核验报告单数据。只计算脚本真实可得的结果,不虚构通过。"""
|
|
610
|
-
generated_at = generated_at or datetime.now()
|
|
611
|
-
|
|
612
|
-
# ① 依据溯源:摘录可比对 + 原文链接可回看。
|
|
613
|
-
# 只统计被正文引用的材料——未引用召回材料未进入正文核验流程,其缺链在自身卡片上如实标注,
|
|
614
|
-
# 不应拖累"正文依据可交付"的报告级结论。
|
|
615
|
-
# PPT 提醒制:缺原文链接(接口对部分治理库文章不返回源网址,属数据源覆盖问题)与
|
|
616
|
-
# 缺摘录均降级为提醒,不参与核验判定——报告级只拦真实错误。
|
|
617
|
-
cited_sources = [s for s in sources if s.get("used", True)]
|
|
618
|
-
missing_links = [s["title"] for s in cited_sources if not s.get("has_link")]
|
|
619
|
-
missing_excerpts = [s["title"] for s in cited_sources if not (s.get("excerpt") or "").strip()]
|
|
620
|
-
trace_passed = len(cited_sources) - len(missing_excerpts)
|
|
621
|
-
|
|
622
|
-
# ② 引用绑定:正文角标与来源卡一一对应(按角标出现次数计,与用户在正文中数到的一致)
|
|
623
|
-
cited = citation_ids(answer)
|
|
624
|
-
all_marks = re.findall(r"\[(\d+)\]", answer)
|
|
625
|
-
source_ids = set()
|
|
626
|
-
for s in sources:
|
|
627
|
-
source_ids.update(collect_material_ids(s))
|
|
628
|
-
unbound_ids = [cid for cid in cited if cid not in source_ids]
|
|
629
|
-
unbound = [cid for cid in unbound_ids for _ in range(all_marks.count(cid))]
|
|
630
|
-
no_citation = bool(sources) and not cited
|
|
631
|
-
|
|
632
|
-
# ③ 时效检查:材料日期范围与历史材料计数
|
|
633
|
-
# 统计口径(对齐公文 3.7.6):③材料新旧/④材料构成只算正文引用的来源文章——
|
|
634
|
-
# sources 含未引用召回,其未来日期/类型会把时效范围与构成写歪。
|
|
635
|
-
dated = [parse_year_month(s.get("date")) for s in cited_sources]
|
|
636
|
-
dated = [d for d in dated if d]
|
|
637
|
-
freshness = None
|
|
638
|
-
old_count = 0
|
|
639
|
-
if dated:
|
|
640
|
-
freshness = {
|
|
641
|
-
"min": min(dated),
|
|
642
|
-
"max": max(dated),
|
|
643
|
-
"old_count": sum(1 for y, _ in dated if y <= generated_at.year - 3),
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
# ④ 类型覆盖:素材四分类分布
|
|
647
|
-
coverage = {key: 0 for key in KIND_CATALOG}
|
|
648
|
-
for s in cited_sources:
|
|
649
|
-
coverage[s.get("type_key", "material")] = coverage.get(s.get("type_key", "material"), 0) + 1
|
|
650
|
-
|
|
651
|
-
# ⑤ 交付前检查:由检索/溯源 JSON 的 self_check 传入,未传入如实显示未记录
|
|
652
|
-
self_check_raw = None
|
|
653
|
-
for holder in (payload, payload.get("content") if isinstance(payload.get("content"), dict) else {}):
|
|
654
|
-
self_check_raw = self_check_raw or holder.get("selfCheck") or holder.get("self_check")
|
|
655
|
-
self_items = normalize_self_check(self_check_raw)
|
|
656
|
-
self_check = None
|
|
657
|
-
if self_items:
|
|
658
|
-
passed = sum(1 for status, _ in self_items.values() if status == "pass")
|
|
659
|
-
fails = sum(1 for status, _ in self_items.values() if status == "fail")
|
|
660
|
-
# 状态由显式 fail 决定;none(描述性值/未记录)不判红也不拖垮通过
|
|
661
|
-
status = "fail" if fails else ("pass" if passed else "missing")
|
|
662
|
-
self_check = {"items": self_items, "passed": passed, "total": len(self_items),
|
|
663
|
-
"status": status}
|
|
664
|
-
else:
|
|
665
|
-
self_check = {"items": {}, "passed": 0, "total": len(SELF_CHECK_ITEMS), "status": "missing"}
|
|
666
|
-
|
|
667
|
-
# 政策效力:无法自动判定现行效力,列出建议人工复核
|
|
668
|
-
policy_count = coverage.get("policy", 0)
|
|
669
|
-
|
|
670
|
-
# 核验判定(PPT 提醒制):只有真实错误才判不通过(无素材 / 正文无角标 / 角标未绑定);
|
|
671
|
-
# 数据缺口(缺链/缺摘录)只提醒不影响判定。
|
|
672
|
-
trace_ok = bool(cited_sources)
|
|
673
|
-
binding_ok = (not unbound) and not no_citation
|
|
674
|
-
overall_passed = trace_ok and binding_ok
|
|
675
|
-
|
|
676
|
-
reasons = []
|
|
677
|
-
if not sources:
|
|
678
|
-
reasons.append("没有找到来源文章")
|
|
679
|
-
if no_citation:
|
|
680
|
-
reasons.append("正文里没有来源角标,对不上来源文章")
|
|
681
|
-
if unbound:
|
|
682
|
-
reasons.append(f"有 {len(unbound)} 处角标找不到对应来源文章")
|
|
683
|
-
if self_check["status"] == "fail":
|
|
684
|
-
reasons.append("交付前检查有没过的项")
|
|
685
|
-
|
|
686
|
-
return {
|
|
687
|
-
"overall": {
|
|
688
|
-
"passed": overall_passed,
|
|
689
|
-
"label": "核验完成,正文依据逐条对过原文" if overall_passed else "核验未完全通过",
|
|
690
|
-
"reasons": reasons,
|
|
691
|
-
},
|
|
692
|
-
"traceability": {"total": len(cited_sources), "passed": trace_passed,
|
|
693
|
-
"missing_links": missing_links, "missing_excerpts": missing_excerpts},
|
|
694
|
-
"binding": {"total": len(all_marks), "bound": len(all_marks) - len(unbound), "unbound": unbound_ids, "no_citation": no_citation},
|
|
695
|
-
"freshness": freshness,
|
|
696
|
-
"coverage": coverage,
|
|
697
|
-
"self_check": self_check,
|
|
698
|
-
"policy_count": policy_count,
|
|
699
|
-
"manual_checks": [str(x) for x in (payload.get("verificationChecks") or payload.get("verification_checks") or []) if str(x).strip()],
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
# ============================================================
|
|
704
|
-
# 过程回顾 / 热词(真实计算,不虚构流程)
|
|
705
|
-
# ============================================================
|
|
706
|
-
|
|
707
|
-
def compute_process_stats(sources: List[Dict[str, str]], answer: str,
|
|
708
|
-
call_log: Optional[List[Dict[str, Any]]] = None) -> Dict[str, Any]:
|
|
709
|
-
"""过程回顾条数据:检索次数、每组检索的召回/采用数、入库与引用计数。
|
|
710
|
-
|
|
711
|
-
全部来自素材自带的真实字段(search_key 分组、used 引用状态、正文角标计数),
|
|
712
|
-
不虚构任何流程步骤。call_log=合并 JSON 顶层「检索记录」(可选项,每条
|
|
713
|
-
{purpose, query, 通道, new_articles, added_paragraphs},由合并补搜轮时按合并
|
|
714
|
-
前后差值如实填写):存在时过程条按真实调用次数统计,补搜路展示
|
|
715
|
-
「新增 N 篇 · 补充 K 段」,让补搜有没有用一眼可见。
|
|
716
|
-
"""
|
|
717
|
-
order: List[str] = []
|
|
718
|
-
for s in sources:
|
|
719
|
-
key = (s.get("search_key") or "").strip()
|
|
720
|
-
if key and key not in order:
|
|
721
|
-
order.append(key)
|
|
722
|
-
cond_rows = []
|
|
723
|
-
for key in order:
|
|
724
|
-
group = [s for s in sources if (s.get("search_key") or "").strip() == key]
|
|
725
|
-
cond_rows.append({
|
|
726
|
-
"key": key,
|
|
727
|
-
"total": len(group),
|
|
728
|
-
"used": sum(1 for s in group if s.get("used", True)),
|
|
729
|
-
})
|
|
730
|
-
n_searches = len(cond_rows) or (1 if sources else 0)
|
|
731
|
-
used_count = sum(1 for s in sources if s.get("used", True))
|
|
732
|
-
unused_count = len(sources) - used_count
|
|
733
|
-
n_cite_marks = len(re.findall(r"\[(\d+)\]", answer))
|
|
734
|
-
# 检索记录(可选):主检索/补搜逐次记录;补搜路的增量来自记录中的真实差值
|
|
735
|
-
log_rows: List[Dict[str, Any]] = []
|
|
736
|
-
n_supplement = 0
|
|
737
|
-
if isinstance(call_log, list) and call_log:
|
|
738
|
-
for entry in call_log:
|
|
739
|
-
if not isinstance(entry, dict):
|
|
740
|
-
continue
|
|
741
|
-
is_supp = str(entry.get("通道") or entry.get("channel") or "").find("补搜") >= 0 \
|
|
742
|
-
or str(entry.get("purpose") or "").find("补搜") >= 0
|
|
743
|
-
if is_supp:
|
|
744
|
-
n_supplement += 1
|
|
745
|
-
log_rows.append({
|
|
746
|
-
"purpose": first_str(entry.get("purpose"), entry.get("方向"), ""),
|
|
747
|
-
"query": first_str(entry.get("query"), entry.get("检索词"), ""),
|
|
748
|
-
"channel": first_str(entry.get("通道"), entry.get("channel"), "主检索" if not is_supp else "补搜"),
|
|
749
|
-
"is_supp": is_supp,
|
|
750
|
-
"new_articles": entry.get("new_articles", entry.get("新增文章")),
|
|
751
|
-
"added_paragraphs": entry.get("added_paragraphs", entry.get("补充段落")),
|
|
752
|
-
})
|
|
753
|
-
return {
|
|
754
|
-
"conds": cond_rows,
|
|
755
|
-
"n_searches": n_searches,
|
|
756
|
-
"has_cond_detail": bool(cond_rows),
|
|
757
|
-
"n_materials": len(sources),
|
|
758
|
-
"used_count": used_count,
|
|
759
|
-
"unused_count": unused_count,
|
|
760
|
-
"n_cite_marks": n_cite_marks,
|
|
761
|
-
"call_log": log_rows,
|
|
762
|
-
"n_main_calls": (len(log_rows) - n_supplement) if log_rows else 0,
|
|
763
|
-
"n_supplement": n_supplement,
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
HOT_STOP = {
|
|
768
|
-
"关于", "通知", "工作", "意见", "方案", "实施", "有关", "问题", "情况", "报告", "总结",
|
|
769
|
-
"制度", "体系", "机制", "指导", "贯彻", "落实", "进一步", "以及", "其他", "相关", "以下",
|
|
770
|
-
"以上", "共和国", "人民", "中华", "国务院", "人民政府", "办公厅", "印发", "试行",
|
|
771
|
-
"办法", "条例", "若干", "的重点", "有所", "一个", "方面", "方式", "内容", "基本",
|
|
772
|
-
"发展", "建设", "政策", "产业", "企业", "应用", "改革", "目标", "任务", "规划",
|
|
773
|
-
"领域", "措施", "支持", "行动", "服务", "管理", "政府",
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
def extract_hot_terms(answer: str, sources: List[Dict[str, str]], top: int = 8) -> List[str]:
|
|
778
|
-
"""知识专库热词:材料标题(加权)+ 检索条件 + 正文的高频 2-4 字词,真实统计。
|
|
779
|
-
|
|
780
|
-
泛词过滤:出现在超过 60% 材料标题中的词(如库内全部材料共有的主题词)
|
|
781
|
-
无法筛出子集,没有筛选价值,剔除。
|
|
782
|
-
"""
|
|
783
|
-
corpus_parts: List[str] = []
|
|
784
|
-
for s in sources:
|
|
785
|
-
if s.get("title"):
|
|
786
|
-
corpus_parts.extend([s["title"]] * 3)
|
|
787
|
-
if s.get("search_key"):
|
|
788
|
-
corpus_parts.extend([s["search_key"]] * 2)
|
|
789
|
-
clean_answer = re.sub(r"\[\d+\]", "", answer or "")
|
|
790
|
-
corpus_parts.append(clean_answer)
|
|
791
|
-
corpus = "\n".join(corpus_parts)
|
|
792
|
-
|
|
793
|
-
counts: Dict[str, int] = {}
|
|
794
|
-
for run in re.findall(r"[一-鿿]{2,}", corpus):
|
|
795
|
-
for n in (2, 3, 4):
|
|
796
|
-
for i in range(len(run) - n + 1):
|
|
797
|
-
gram = run[i:i + n]
|
|
798
|
-
counts[gram] = counts.get(gram, 0) + 1
|
|
799
|
-
|
|
800
|
-
titles = [s.get("title") or "" for s in sources]
|
|
801
|
-
n_titles = max(1, len(titles))
|
|
802
|
-
df_limit = max(1, int(n_titles * 0.6))
|
|
803
|
-
|
|
804
|
-
cands = [(g, c) for g, c in counts.items()
|
|
805
|
-
if c >= 2 and g not in HOT_STOP and "的" not in g and not any(ch.isdigit() for ch in g)
|
|
806
|
-
and sum(1 for t in titles if g in t) <= df_limit]
|
|
807
|
-
cands.sort(key=lambda x: (-x[1], -len(x[0])))
|
|
808
|
-
kept: List[Tuple[str, int]] = []
|
|
809
|
-
for gram, count in cands:
|
|
810
|
-
redundant = False
|
|
811
|
-
for kgram, kcount in kept:
|
|
812
|
-
# 短词是已入选高频长词的子串且计数接近 → 被长词覆盖,剔除
|
|
813
|
-
if gram in kgram and kcount >= count * 0.6:
|
|
814
|
-
redundant = True
|
|
815
|
-
break
|
|
816
|
-
if not redundant:
|
|
817
|
-
kept.append((gram, count))
|
|
818
|
-
if len(kept) >= top:
|
|
819
|
-
break
|
|
820
|
-
return [g for g, _ in kept]
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
# ============================================================
|
|
824
|
-
# 正文解析与分节
|
|
825
|
-
# ============================================================
|
|
826
|
-
|
|
827
|
-
def render_inline_markdown(text: str, citation_repl) -> str:
|
|
828
|
-
body = esc(text)
|
|
829
|
-
body = re.sub(r"`([^`]+)`", r"<code>\1</code>", body)
|
|
830
|
-
body = re.sub(r"\*\*(.+?)\*\*", r"<strong>\1</strong>", body)
|
|
831
|
-
body = re.sub(r"__(.+?)__", r"<strong>\1</strong>", body)
|
|
832
|
-
body = re.sub(r"(?<!\*)\*([^*\n]+)\*(?!\*)", r"<em>\1</em>", body)
|
|
833
|
-
body = re.sub(r"(?<!_)_([^_\n]+_)(?!_)", r"<em>\1</em>", body)
|
|
834
|
-
body = re.sub(r"\[(\d+)\]", citation_repl, body)
|
|
835
|
-
return body
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
def is_markdown_table_separator(line: str) -> bool:
|
|
839
|
-
stripped = line.strip().strip("|")
|
|
840
|
-
if not stripped:
|
|
841
|
-
return False
|
|
842
|
-
cells = [cell.strip() for cell in stripped.split("|")]
|
|
843
|
-
# GFM 语义:分隔行每格只需 1 个及以上短横线(允许 : 对齐标记)。
|
|
844
|
-
# 兼容按表头宽度对齐写出的 "--" 等短分隔,避免整表退化为普通段落。
|
|
845
|
-
return all(re.fullmatch(r":?-+:?", cell or "") for cell in cells)
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
def split_markdown_table_row(line: str) -> List[str]:
|
|
849
|
-
return [cell.strip() for cell in line.strip().strip("|").split("|")]
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
def render_markdown_table(lines: List[str], citation_repl) -> str:
|
|
853
|
-
header = split_markdown_table_row(lines[0])
|
|
854
|
-
body_lines = lines[2:] if len(lines) > 1 and is_markdown_table_separator(lines[1]) else lines[1:]
|
|
855
|
-
head_html = "".join(f"<th>{render_inline_markdown(cell, citation_repl)}</th>" for cell in header)
|
|
856
|
-
rows = []
|
|
857
|
-
for line in body_lines:
|
|
858
|
-
cells = split_markdown_table_row(line)
|
|
859
|
-
if len(cells) < len(header): # 行内缺格时补空,保持列对齐
|
|
860
|
-
cells = cells + [""] * (len(header) - len(cells))
|
|
861
|
-
rows.append("<tr>" + "".join(f"<td>{render_inline_markdown(cell, citation_repl)}</td>" for cell in cells) + "</tr>")
|
|
862
|
-
wide_cls = " wide" if len(header) >= 4 else ""
|
|
863
|
-
return f'<div class="tbl-wrap"><table class="data-tbl{wide_cls}"><thead><tr>{head_html}</tr></thead><tbody>{"".join(rows)}</tbody></table></div>'
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
_TABLE_ALLOWED_TAGS = {"table", "thead", "tbody", "tr", "td", "th", "br"}
|
|
867
|
-
_TABLE_VOID_TAGS = {"br"}
|
|
868
|
-
_TABLE_SKIP_CONTENT_TAGS = {"script", "style"}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
class _TableSanitizer(HTMLParser):
|
|
872
|
-
"""表格 HTML 元素级白名单(替代正则清洗,防标签注入与属性注入):
|
|
873
|
-
|
|
874
|
-
- 只放行 table/thead/tbody/tr/td/th/br,输出不带任何属性;
|
|
875
|
-
- 其余标签一律丢弃(文本继续走 handle_data,统一转义);
|
|
876
|
-
- script/style 连内容一起丢弃;
|
|
877
|
-
- 乱序/未闭合标签按栈自平衡,不产生悬空标签;
|
|
878
|
-
- 解析异常由调用方兜底为整体转义。
|
|
879
|
-
"""
|
|
880
|
-
|
|
881
|
-
def __init__(self) -> None:
|
|
882
|
-
super().__init__(convert_charrefs=True)
|
|
883
|
-
self.out: List[str] = []
|
|
884
|
-
self.stack: List[str] = []
|
|
885
|
-
self.skip_depth = 0
|
|
886
|
-
|
|
887
|
-
def handle_starttag(self, tag: str, attrs) -> None:
|
|
888
|
-
tag = tag.lower()
|
|
889
|
-
if tag in _TABLE_SKIP_CONTENT_TAGS:
|
|
890
|
-
self.skip_depth += 1
|
|
891
|
-
return
|
|
892
|
-
if self.skip_depth or tag not in _TABLE_ALLOWED_TAGS:
|
|
893
|
-
return
|
|
894
|
-
if tag in _TABLE_VOID_TAGS:
|
|
895
|
-
self.out.append("<br>")
|
|
896
|
-
return
|
|
897
|
-
self.out.append(f"<{tag}>")
|
|
898
|
-
self.stack.append(tag)
|
|
899
|
-
|
|
900
|
-
def handle_startendtag(self, tag: str, attrs) -> None:
|
|
901
|
-
self.handle_starttag(tag, attrs)
|
|
902
|
-
self.handle_endtag(tag)
|
|
903
|
-
|
|
904
|
-
def handle_endtag(self, tag: str) -> None:
|
|
905
|
-
tag = tag.lower()
|
|
906
|
-
if tag in _TABLE_SKIP_CONTENT_TAGS:
|
|
907
|
-
self.skip_depth = max(0, self.skip_depth - 1)
|
|
908
|
-
return
|
|
909
|
-
if self.skip_depth or tag not in _TABLE_ALLOWED_TAGS or tag in _TABLE_VOID_TAGS:
|
|
910
|
-
return
|
|
911
|
-
if tag in self.stack:
|
|
912
|
-
while self.stack:
|
|
913
|
-
top = self.stack.pop()
|
|
914
|
-
self.out.append(f"</{top}>")
|
|
915
|
-
if top == tag:
|
|
916
|
-
break
|
|
917
|
-
|
|
918
|
-
def handle_data(self, data: str) -> None:
|
|
919
|
-
if not self.skip_depth:
|
|
920
|
-
self.out.append(html.escape(data, quote=False))
|
|
921
|
-
|
|
922
|
-
def close(self) -> None:
|
|
923
|
-
super().close()
|
|
924
|
-
while self.stack:
|
|
925
|
-
self.out.append(f"</{self.stack.pop()}>")
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
def _fix_thead_rows(table_html: str) -> str:
|
|
929
|
-
"""修正源表格把多行数据包进 <thead> 的畸形结构:只保留第一行为表头,其余移入 <tbody>。
|
|
930
|
-
|
|
931
|
-
政府门户抓取的表格常把数据行一起包在 thead 里(如统计分类表 4 行数据全在
|
|
932
|
-
thead、仅最后 1 行在 tbody)。白名单清洗只保结构不改行归属,CSS 又给 thead
|
|
933
|
-
单元格加表头底色——数据行整片变"表头色"。此处把 thead 第 2 行起全部并入
|
|
934
|
-
tbody(无 tbody 则新建),只有真正的首行作表头。
|
|
935
|
-
"""
|
|
936
|
-
m = re.search(r"<thead>(.*?)</thead>", table_html, flags=re.S)
|
|
937
|
-
if not m:
|
|
938
|
-
return table_html
|
|
939
|
-
rows = re.findall(r"<tr>.*?</tr>", m.group(1), flags=re.S)
|
|
940
|
-
if len(rows) <= 1:
|
|
941
|
-
return table_html
|
|
942
|
-
head = f"<thead>{rows[0]}</thead>"
|
|
943
|
-
moved = "".join(rows[1:])
|
|
944
|
-
rest = table_html[m.end():]
|
|
945
|
-
tb = re.search(r"<tbody>(.*?)</tbody>", rest, flags=re.S)
|
|
946
|
-
if tb:
|
|
947
|
-
rest = rest[:tb.start()] + f"<tbody>{moved}{tb.group(1)}</tbody>" + rest[tb.end():]
|
|
948
|
-
else:
|
|
949
|
-
rest = f"<tbody>{moved}</tbody>" + rest
|
|
950
|
-
return table_html[:m.start()] + head + rest
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
def sanitize_table_html(text: str) -> str:
|
|
954
|
-
"""清洗接口表格 HTML:只保留表格结构标签,属性丢弃、文本转义、脚本样式连内容丢弃。"""
|
|
955
|
-
parser = _TableSanitizer()
|
|
956
|
-
try:
|
|
957
|
-
parser.feed(str(text or ""))
|
|
958
|
-
parser.close()
|
|
959
|
-
except Exception: # 解析异常兜底:整体转义,宁可不渲染表格
|
|
960
|
-
return html.escape(str(text or ""), quote=False)
|
|
961
|
-
return _fix_thead_rows("".join(parser.out))
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
def render_excerpt_html(text: str) -> str:
|
|
965
|
-
value = str(text or "")
|
|
966
|
-
if "<table" not in value.lower():
|
|
967
|
-
return f'<div class="sc-excerpt plain">{esc(value)}</div>'
|
|
968
|
-
return f'<div class="sc-excerpt rich">{sanitize_table_html(value)}</div>'
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str, Any]] = None) -> Tuple[List[Dict[str, Any]], set]:
|
|
972
|
-
"""把正文 Markdown 解析为结构化块;同时收集全部角标。
|
|
973
|
-
|
|
974
|
-
角标渲染为原型式 jb 胶囊(编号圆徽章 + 材料标题),点击原地展开溯源卡;
|
|
975
|
-
表格单元格内的角标同样就地变胶囊(证据在含角标的单元格内,不挂表外)。
|
|
976
|
-
"""
|
|
977
|
-
|
|
978
|
-
def jb_html(cid: str) -> str:
|
|
979
|
-
jb = chip_map.get(cid)
|
|
980
|
-
if not jb:
|
|
981
|
-
return ""
|
|
982
|
-
# 链接原样给出(不做死活检测);无原文链接但有存档快照时,快照作为附加入口。
|
|
983
|
-
# href 一律经 safe_url 协议白名单(仅 http/https),非法协议不渲染。
|
|
984
|
-
jb_url = safe_url(jb.get("url")) or safe_url(jb.get("snapshot"))
|
|
985
|
-
if jb_url:
|
|
986
|
-
btn_txt = "查看全文" if safe_url(jb.get("url")) else "查看存档全文"
|
|
987
|
-
link = (f'<a class="jb-src" href="{esc(jb_url)}" target="_blank" rel="noopener noreferrer">'
|
|
988
|
-
f'{ARROW_SVG}<span>{btn_txt}</span></a>')
|
|
989
|
-
else:
|
|
990
|
-
link = ""
|
|
991
|
-
# 原文直达区展示标题链(多段分块,各段带链——快速人工核验的核心抓手)
|
|
992
|
-
segs = jb.get("segments") or []
|
|
993
|
-
if segs:
|
|
994
|
-
quote = ""
|
|
995
|
-
seg_idx = -1
|
|
996
|
-
for seg in segs:
|
|
997
|
-
text = (seg.get("text") or "").strip()
|
|
998
|
-
if not text:
|
|
999
|
-
continue
|
|
1000
|
-
seg_idx += 1
|
|
1001
|
-
if "<table" in text.lower():
|
|
1002
|
-
# 表格不能静态写进 span(解析器会拆散):此处留占位,
|
|
1003
|
-
# 表格数据由 render_html 汇总注入页尾 JSON,展开时 JS 填充
|
|
1004
|
-
tbl_key = f"{cid}-{seg_idx}"
|
|
1005
|
-
jb.setdefault("_tables", {})[tbl_key] = sanitize_table_html(text)
|
|
1006
|
-
body_txt = f'<span class="sc-excerpt rich tbl-holder" data-tbl="{esc(tbl_key)}"></span>'
|
|
1007
|
-
else:
|
|
1008
|
-
body_txt = f'<span class="sc-excerpt">{esc(text)}</span>'
|
|
1009
|
-
inner = f'<i class="jb-no">{esc(cid)}</i>{body_txt}'
|
|
1010
|
-
item = f'<span class="jb-quote" role="button" tabindex="0">{inner}</span>'
|
|
1011
|
-
quote += render_crumb(seg.get("chain") or []) + item
|
|
1012
|
-
elif jb["excerpt"]:
|
|
1013
|
-
inner = f'<i class="jb-no">{esc(cid)}</i><span>{esc(jb["excerpt"])}</span>'
|
|
1014
|
-
quote = f'<span class="jb-quote" role="button" tabindex="0">{inner}</span>'
|
|
1015
|
-
else:
|
|
1016
|
-
quote = ""
|
|
1017
|
-
site_html = (f'<span class="jb-site"><span class="dot"></span>{esc(jb.get("site") or "")}</span>'
|
|
1018
|
-
if (jb.get("site") or "").strip() else "")
|
|
1019
|
-
return (
|
|
1020
|
-
f'<span class="jb" data-cite="{esc(cid)}">'
|
|
1021
|
-
f'<button class="jb-name" type="button" aria-expanded="false">{CARET_SVG}'
|
|
1022
|
-
f'<i class="jb-id">{esc(cid)}</i>'
|
|
1023
|
-
f'<span class="jb-txt">{esc(jb["title"])}</span></button>'
|
|
1024
|
-
f'<span class="jb-body"><span class="jb-head"><span class="jb-label">{SRC_ICO_SVG}溯源原文:</span>{link}</span>'
|
|
1025
|
-
f'{site_html}'
|
|
1026
|
-
f'{quote}</span></span>'
|
|
1027
|
-
)
|
|
1028
|
-
|
|
1029
|
-
def make_block_repl(block_text: str):
|
|
1030
|
-
"""按块构造角标替换器:同块同材料只保留最后一次出现的角标(前处整体删除),
|
|
1031
|
-
最后一处挂 jb 胶囊——一块中同一材料只出现一次,杜绝重复引用刷屏。"""
|
|
1032
|
-
remaining: Dict[str, int] = {}
|
|
1033
|
-
for cid in re.findall(r"\[(\d+)\]", block_text):
|
|
1034
|
-
remaining[cid] = remaining.get(cid, 0) + 1
|
|
1035
|
-
|
|
1036
|
-
def repl(match: re.Match[str]) -> str:
|
|
1037
|
-
cid = match.group(1)
|
|
1038
|
-
remaining[cid] = max(0, remaining.get(cid, 1) - 1)
|
|
1039
|
-
if remaining[cid] > 0:
|
|
1040
|
-
return ""
|
|
1041
|
-
if cid in chip_map:
|
|
1042
|
-
return jb_html(cid)
|
|
1043
|
-
# 未绑定角标(无对应材料):红色数字警示,绝不按位置猜测
|
|
1044
|
-
return f'<sup class="cite unresolved" data-cite="{esc(cid)}" title="核验依据 [{esc(cid)}?]">{esc(cid)}?</sup>'
|
|
1045
|
-
|
|
1046
|
-
return repl
|
|
1047
|
-
|
|
1048
|
-
blocks: List[Dict[str, Any]] = []
|
|
1049
|
-
lines = answer.split("\n")
|
|
1050
|
-
idx = 0
|
|
1051
|
-
while idx < len(lines):
|
|
1052
|
-
block = lines[idx].strip()
|
|
1053
|
-
if not block:
|
|
1054
|
-
idx += 1
|
|
1055
|
-
continue
|
|
1056
|
-
# 引文胶囊位置规范:角标与后随标点换位——标点紧跟文字,胶囊放标点之后
|
|
1057
|
-
# (避免胶囊把句号挤到下一行孤悬,对齐深知晓原型"…内容。~出处"形态)
|
|
1058
|
-
# 连续角标序列整体换位(如 [13][14];→ ;[13][14]):只换单个角标会让标点
|
|
1059
|
-
# 被夹在两个胶囊之间(实测截图反馈)。
|
|
1060
|
-
block = re.sub(r"((?:\[\d+\])+)([。;,、!?:;,.])", r"\2\1", block)
|
|
1061
|
-
ids = citation_ids(block)
|
|
1062
|
-
repl = make_block_repl(block)
|
|
1063
|
-
heading_match = re.match(r"^(#{1,4})\s+(.+)$", block)
|
|
1064
|
-
if heading_match:
|
|
1065
|
-
blocks.append({"kind": "heading", "level": len(heading_match.group(1)),
|
|
1066
|
-
"text": heading_match.group(2).strip(), "cites": ids, "repl": repl})
|
|
1067
|
-
idx += 1
|
|
1068
|
-
elif "|" in block and idx + 1 < len(lines) and is_markdown_table_separator(lines[idx + 1]):
|
|
1069
|
-
table_lines = [block, lines[idx + 1].strip()]
|
|
1070
|
-
idx += 2
|
|
1071
|
-
while idx < len(lines) and "|" in lines[idx].strip() and lines[idx].strip():
|
|
1072
|
-
table_lines.append(lines[idx].strip())
|
|
1073
|
-
idx += 1
|
|
1074
|
-
repl = make_block_repl("\n".join(table_lines))
|
|
1075
|
-
blocks.append({"kind": "table", "html": render_markdown_table(table_lines, repl), "cites": citation_ids("\n".join(table_lines))})
|
|
1076
|
-
elif block in {"---", "***"}:
|
|
1077
|
-
blocks.append({"kind": "hr", "html": '<hr class="doc-divider">', "cites": []})
|
|
1078
|
-
idx += 1
|
|
1079
|
-
elif re.match(r"^[-*]\s+", block):
|
|
1080
|
-
body = render_inline_markdown(re.sub(r"^[-*]\s+", "", block), repl)
|
|
1081
|
-
blocks.append({"kind": "list_item", "numbered": False, "html": body, "cites": ids})
|
|
1082
|
-
idx += 1
|
|
1083
|
-
elif re.match(r"^\d+[.)]\s+", block):
|
|
1084
|
-
number = re.match(r"^(\d+)[.)]\s+", block).group(1)
|
|
1085
|
-
body = render_inline_markdown(re.sub(r"^\d+[.)]\s+", "", block), repl)
|
|
1086
|
-
blocks.append({"kind": "list_item", "numbered": True, "number": number, "html": body, "cites": ids})
|
|
1087
|
-
idx += 1
|
|
1088
|
-
else:
|
|
1089
|
-
blocks.append({"kind": "para", "html": render_inline_markdown(block, repl), "cites": ids})
|
|
1090
|
-
idx += 1
|
|
1091
|
-
return blocks, valid_ids
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
def split_heading_number(text: str) -> Tuple[Optional[str], str]:
|
|
1095
|
-
m = re.match(r"^\s*([一二三四五六七八九十]+|\d+)\s*[、..]\s*(.+)$", text)
|
|
1096
|
-
if m:
|
|
1097
|
-
return m.group(1), m.group(2)
|
|
1098
|
-
return None, text
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
def group_sections(blocks: List[Dict[str, Any]]) -> Tuple[Optional[str], List[Dict[str, Any]]]:
|
|
1102
|
-
"""按标题层级切分章节。返回(报告标题, 章节列表)。
|
|
1103
|
-
|
|
1104
|
-
规则:最浅层级标题若唯一且居文首,视为报告标题提出;其下一级为章节边界。
|
|
1105
|
-
无标题的短正文整篇一节。
|
|
1106
|
-
"""
|
|
1107
|
-
if not blocks:
|
|
1108
|
-
return None, [{"title": None, "blocks": []}]
|
|
1109
|
-
heading_indexes = [i for i, b in enumerate(blocks) if b["kind"] == "heading"]
|
|
1110
|
-
if not heading_indexes:
|
|
1111
|
-
return None, [{"title": None, "blocks": blocks}]
|
|
1112
|
-
|
|
1113
|
-
levels = sorted({blocks[i]["level"] for i in heading_indexes})
|
|
1114
|
-
shallow = levels[0]
|
|
1115
|
-
shallow_indexes = [i for i in heading_indexes if blocks[i]["level"] == shallow]
|
|
1116
|
-
|
|
1117
|
-
doc_title = None
|
|
1118
|
-
boundary = shallow
|
|
1119
|
-
if len(shallow_indexes) == 1 and heading_indexes[0] == shallow_indexes[0]:
|
|
1120
|
-
doc_title = blocks[shallow_indexes[0]]["text"]
|
|
1121
|
-
blocks = blocks[shallow_indexes[0] + 1:]
|
|
1122
|
-
if len(levels) > 1:
|
|
1123
|
-
boundary = levels[1]
|
|
1124
|
-
|
|
1125
|
-
sections: List[Dict[str, Any]] = []
|
|
1126
|
-
current: Dict[str, Any] = {"title": None, "blocks": []}
|
|
1127
|
-
for b in blocks:
|
|
1128
|
-
if b["kind"] == "heading" and b["level"] <= boundary:
|
|
1129
|
-
if current["title"] is not None or current["blocks"]:
|
|
1130
|
-
sections.append(current)
|
|
1131
|
-
current = {"title": b["text"], "blocks": []}
|
|
1132
|
-
else:
|
|
1133
|
-
current["blocks"].append(b)
|
|
1134
|
-
if current["title"] is not None or current["blocks"]:
|
|
1135
|
-
sections.append(current)
|
|
1136
|
-
return doc_title, sections
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
# ============================================================
|
|
1140
|
-
# 各部分渲染
|
|
1141
|
-
# ============================================================
|
|
1142
|
-
|
|
1143
|
-
def build_chip_data(sources: List[Dict[str, str]]) -> Dict[str, Dict[str, Any]]:
|
|
1144
|
-
"""行内引文胶囊数据:id → {title, site, url, excerpt, segments}。
|
|
1145
|
-
|
|
1146
|
-
角标后渲染原型式 jb(行内小胶囊,点击展开块级卡)。摘录展示完整
|
|
1147
|
-
原文原段、不截断——块内去重后重复量可控,核对场景下就地读全文。
|
|
1148
|
-
"""
|
|
1149
|
-
chip_map: Dict[str, Dict[str, Any]] = {}
|
|
1150
|
-
material_ids = []
|
|
1151
|
-
for source in sources:
|
|
1152
|
-
for cid in collect_material_ids(source):
|
|
1153
|
-
material_ids.append((cid, source))
|
|
1154
|
-
for cid, source in material_ids:
|
|
1155
|
-
if cid in chip_map:
|
|
1156
|
-
continue
|
|
1157
|
-
meta_bits = [v for v in [source.get("agency"), source.get("date")] if v and v != "未知来源"]
|
|
1158
|
-
url = source.get("url") if (source.get("url") and source["url"] != "接口未返回") else (source.get("policy_url") or "")
|
|
1159
|
-
site_bits = ([source["doc_number"]] if source.get("doc_number") else []) + meta_bits
|
|
1160
|
-
chip_map[cid] = {
|
|
1161
|
-
"title": short(source.get("title") or "未命名来源文章", 30),
|
|
1162
|
-
"site": " · ".join(site_bits) or "来源站点",
|
|
1163
|
-
"url": url,
|
|
1164
|
-
"snapshot": source.get("snapshot") or "",
|
|
1165
|
-
"excerpt": (source.get("excerpt") or "").strip(),
|
|
1166
|
-
"segments": source.get("segments") or [],
|
|
1167
|
-
}
|
|
1168
|
-
return chip_map
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
def render_source_links(url: str, policy_url: str = "", snapshot: str = "") -> str:
|
|
1172
|
-
"""链接区:接口返回的链接**原样展示**(不做连通性检测、不隐藏);
|
|
1173
|
-
存档快照作为**附加回看入口**与原文链接并存,文案如实区分不冒充原文。
|
|
1174
|
-
href 一律经 safe_url 协议白名单(仅 http/https),非法协议不渲染。"""
|
|
1175
|
-
links = []
|
|
1176
|
-
url = safe_url(url)
|
|
1177
|
-
snapshot = safe_url(snapshot)
|
|
1178
|
-
policy_url = safe_url(policy_url)
|
|
1179
|
-
if url and url != "接口未返回":
|
|
1180
|
-
links.append(f'<a href="{esc(url)}" target="_blank" rel="noopener">查看全文 ↗</a>')
|
|
1181
|
-
if snapshot:
|
|
1182
|
-
links.append(f'<a class="snap" href="{esc(snapshot)}" target="_blank" rel="noopener">查看存档全文 ↗</a>')
|
|
1183
|
-
if policy_url:
|
|
1184
|
-
links.append(f'<a href="{esc(policy_url)}" target="_blank" rel="noopener">知识专库原文 ↗</a>')
|
|
1185
|
-
if not links:
|
|
1186
|
-
return ""
|
|
1187
|
-
return '<div class="sc-links">' + "".join(f"<span>{link}</span>" for link in links) + "</div>"
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
1191
|
-
"""核验报告单:报告级核验结论 + 五项指标(PPT 双版 + 提醒制口径)。"""
|
|
1192
|
-
stage_label = STAGE_LABELS.get(stage, "成稿版")
|
|
1193
|
-
manual_checks_html = "".join("<br>· " + esc(x) for x in v.get("manual_checks", []))
|
|
1194
|
-
ov = v["overall"]
|
|
1195
|
-
state = "ok" if ov["passed"] else "fail"
|
|
1196
|
-
stamp = '<span class="v-stamp">已核验</span>' if ov["passed"] else '<span class="v-stamp bad">核验未通过</span>'
|
|
1197
|
-
reasons_html = ""
|
|
1198
|
-
if ov["reasons"]:
|
|
1199
|
-
reasons_html = '<div class="v-reasons">' + ";".join(esc(r) for r in ov["reasons"]) + "</div>"
|
|
1200
|
-
|
|
1201
|
-
tr = v["traceability"]
|
|
1202
|
-
n_missing = len(set(tr["missing_links"]) | set(tr["missing_excerpts"]))
|
|
1203
|
-
if not tr["total"]:
|
|
1204
|
-
tr_html = ('<div class="vi"><span class="s fail">✗ 依据溯源 0/0</span>'
|
|
1205
|
-
'<span class="d">未识别到来源文章</span></div>')
|
|
1206
|
-
elif n_missing:
|
|
1207
|
-
# PPT 提醒制:数据缺口恒绿,附温和提醒(缺口明细在材料卡上如实标注)
|
|
1208
|
-
tr_html = (f'<div class="vi"><span class="s ok">✓ 依据溯源 {tr["total"]}/{tr["total"]}</span>'
|
|
1209
|
-
f'<span class="d">每篇来源文章的摘录可比对;{n_missing} 篇原文链接或摘录待补,卡片已标注,汇报前请注意核对</span></div>')
|
|
1210
|
-
else:
|
|
1211
|
-
tr_html = (f'<div class="vi"><span class="s ok">✓ 依据溯源 {tr["passed"]}/{tr["total"]}</span>'
|
|
1212
|
-
f'<span class="d">每篇来源文章的摘录可比对,原文或存档快照可回看</span></div>')
|
|
1213
|
-
|
|
1214
|
-
bd = v["binding"]
|
|
1215
|
-
if bd.get("no_citation"):
|
|
1216
|
-
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 0/0</span>'
|
|
1217
|
-
f'<span class="d">正文里没有来源角标,{v["traceability"]["total"]} 篇来源文章对不上正文</span></div>')
|
|
1218
|
-
elif not bd["total"]:
|
|
1219
|
-
bd_html = '<div class="vi"><span class="s none">— 引用对应 0/0</span><span class="d">正文里没有来源角标</span></div>'
|
|
1220
|
-
elif not bd["unbound"]:
|
|
1221
|
-
bd_html = (f'<div class="vi"><span class="s ok">✓ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
1222
|
-
f'<span class="d">正文每处 [n] 都能找到对应来源文章</span></div>')
|
|
1223
|
-
else:
|
|
1224
|
-
unbound_text = "、".join(f"[{esc(x)}]" for x in bd["unbound"][:8])
|
|
1225
|
-
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
1226
|
-
f'<span class="d">对不上的角标 {unbound_text}</span></div>')
|
|
1227
|
-
|
|
1228
|
-
fr = v["freshness"]
|
|
1229
|
-
if fr:
|
|
1230
|
-
rng = f"{fr['min'][0]}-{fr['min'][1]:02d}~{fr['max'][0]}-{fr['max'][1]:02d}"
|
|
1231
|
-
# 「N 条年头较久,按参考口径使用」半句已移除(长期有效的政策法规会被误判"年头较久",
|
|
1232
|
-
# 且"按参考口径使用"读者无从理解);old_count 仍在 freshness 中照常计算。
|
|
1233
|
-
fr_html = f'<div class="vi"><span class="s ok">✓ 材料新旧 已核</span><span class="d">材料日期 {esc(rng)}</span></div>'
|
|
1234
|
-
else:
|
|
1235
|
-
fr_html = '<div class="vi"><span class="s none">— 材料新旧 未记录</span><span class="d">材料没标发布日期</span></div>'
|
|
1236
|
-
|
|
1237
|
-
cov = v["coverage"]
|
|
1238
|
-
parts = [f"{KIND_CATALOG[k][0]} {cov[k]}" for k in ("policy", "data", "case", "reference") if cov.get(k)]
|
|
1239
|
-
cov_state = "ok" if cov.get("policy") or cov.get("data") or cov.get("case") else "none"
|
|
1240
|
-
cov_html = (f'<div class="vi"><span class="s {cov_state}">{"✓" if cov_state == "ok" else "—"} 材料构成</span>'
|
|
1241
|
-
f'<span class="d">{esc(" · ".join(parts)) if parts else "材料没标类型(合并 JSON 可加「类型」字段)"}</span></div>')
|
|
1242
|
-
|
|
1243
|
-
sc = v["self_check"]
|
|
1244
|
-
if sc["status"] == "pass":
|
|
1245
|
-
notes = ";".join(note for _, note in sc["items"].values() if note)
|
|
1246
|
-
title_attr = f' title="{esc(notes)}"' if notes else ""
|
|
1247
|
-
item_names = "、".join(sc["items"].keys()) if sc["items"] else "、".join(label for _, label in SELF_CHECK_ITEMS)
|
|
1248
|
-
none_count = sum(1 for status, _ in sc["items"].values() if status == "none")
|
|
1249
|
-
none_note = f"({none_count} 项未记录)" if none_count else ""
|
|
1250
|
-
sc_html = (f'<div class="vi"><span class="s ok"{title_attr}>✓ 交付前检查 {sc["passed"]}/{sc["total"]}{esc(none_note)}</span>'
|
|
1251
|
-
f'<span class="d">{esc(item_names)}{esc(" · 悬停查看说明" if notes else "")}</span></div>')
|
|
1252
|
-
elif sc["status"] == "fail":
|
|
1253
|
-
failed_parts = []
|
|
1254
|
-
for label, (status, note) in sc["items"].items():
|
|
1255
|
-
if status == "fail":
|
|
1256
|
-
suffix = f"({note[:40]}…)" if len(note) > 40 else (f"({note})" if note else "")
|
|
1257
|
-
failed_parts.append(label + suffix)
|
|
1258
|
-
sc_html = (f'<div class="vi"><span class="s fail">✗ 交付前检查 {sc["passed"]}/{sc["total"]}</span>'
|
|
1259
|
-
f'<span class="d">没过的项:{esc("、".join(failed_parts))}</span></div>')
|
|
1260
|
-
else:
|
|
1261
|
-
default_names = "、".join(label for _, label in SELF_CHECK_ITEMS)
|
|
1262
|
-
sc_html = (f'<div class="vi"><span class="s none">— 交付前检查 未记录</span>'
|
|
1263
|
-
f'<span class="d">检索 JSON 没写入 self_check(默认查:{esc(default_names)})</span></div>')
|
|
1264
|
-
|
|
1265
|
-
# 3.7.2 起「现行效力」提示行移除:该提示对用户无操作价值,policy_count
|
|
1266
|
-
# 保留在计算层不再展示(对齐公文写作 3.7.2 口径)。
|
|
1267
|
-
|
|
1268
|
-
what = "提纲页面规划" if stage == "outline" else "页面级结论"
|
|
1269
|
-
return f"""
|
|
1270
|
-
<div class="verify {state}">
|
|
1271
|
-
<div class="v-head"><span class="v-shield">{'✓' if ov['passed'] else '!'}</span>{esc(ov['label'])}({esc(stage_label)}){stamp}</div>
|
|
1272
|
-
{reasons_html}
|
|
1273
|
-
<div class="v-grid">
|
|
1274
|
-
{tr_html}{bd_html}{fr_html}{cov_html}{sc_html}
|
|
1275
|
-
</div>
|
|
1276
|
-
<div class="v-note">核验方式:先用深知可信搜索找权威来源,再把{esc(what)}的每处依据和原文逐条比对(都能点开原文回看),最后做了交付前五项检查。{manual_checks_html}</div>
|
|
1277
|
-
</div>"""
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
SRC_ICO_SVG = ('<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.8" '
|
|
1281
|
-
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'
|
|
1282
|
-
'<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/>'
|
|
1283
|
-
'<path d="M9 13h6M9 17h4"/></svg>')
|
|
1284
|
-
ARROW_SVG = ('<svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2.2" '
|
|
1285
|
-
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7M9 7h8v8"/></svg>')
|
|
1286
|
-
CARET_SVG = ('<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.4" '
|
|
1287
|
-
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>')
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str, str]]) -> str:
|
|
1291
|
-
"""正文渲染(原型复刻):chapter(h2)+ lead/para 段落文档流 + 句后 jb 引文胶囊。
|
|
1292
|
-
|
|
1293
|
-
同一块内同一材料只保留最后一处角标与胶囊(make_block_repl 去重);
|
|
1294
|
-
提纲页面规划表等 markdown 表格内角标同样就地变胶囊(证据在含角标的单元格内)。
|
|
1295
|
-
"""
|
|
1296
|
-
parts: List[str] = []
|
|
1297
|
-
first_para = True
|
|
1298
|
-
source_ids = {s["id"] for s in sources}
|
|
1299
|
-
for sec_idx, sec in enumerate(sections, 1):
|
|
1300
|
-
number, title_text = split_heading_number(sec["title"] or "")
|
|
1301
|
-
chapter_title = f"{number}、{title_text}" if (number and title_text) else (title_text or "")
|
|
1302
|
-
sec_cites: List[str] = []
|
|
1303
|
-
for b in sec["blocks"]:
|
|
1304
|
-
for cid in b.get("cites", []):
|
|
1305
|
-
if cid not in sec_cites:
|
|
1306
|
-
sec_cites.append(cid)
|
|
1307
|
-
if chapter_title:
|
|
1308
|
-
badge_html = ""
|
|
1309
|
-
if sec_cites:
|
|
1310
|
-
unbound = sum(1 for cid in sec_cites if cid not in source_ids)
|
|
1311
|
-
state = "bad" if unbound else ""
|
|
1312
|
-
text = f"本章引用 {len(sec_cites)} 处" + (f" · {unbound} 处未绑定" if unbound else " · 已核验")
|
|
1313
|
-
badge_html = f'<span class="sec-badge {state}">{esc(text)}</span>'
|
|
1314
|
-
parts.append(f'<section class="chapter" id="sec-{sec_idx}">'
|
|
1315
|
-
f'<header class="ch-head"><h2>{esc(chapter_title)}</h2>{badge_html}</header>')
|
|
1316
|
-
for b in sec["blocks"]:
|
|
1317
|
-
if b["kind"] == "heading":
|
|
1318
|
-
parts.append(f'<p class="para"><b class="kw">{esc(b["text"])}</b></p>')
|
|
1319
|
-
first_para = False
|
|
1320
|
-
continue
|
|
1321
|
-
cls = "lead" if first_para else "para"
|
|
1322
|
-
first_para = False
|
|
1323
|
-
if b["kind"] == "list_item":
|
|
1324
|
-
marker = f'{esc(b.get("number", "•"))}.' if b.get("numbered") else "•"
|
|
1325
|
-
parts.append(f'<p class="{cls}"><b class="kw">{marker}</b> {b["html"]}</p>')
|
|
1326
|
-
elif b["kind"] == "hr":
|
|
1327
|
-
parts.append('<hr class="doc-divider">')
|
|
1328
|
-
else:
|
|
1329
|
-
parts.append(f'<p class="{cls}">{b["html"]}</p>')
|
|
1330
|
-
if chapter_title:
|
|
1331
|
-
parts.append("</section>")
|
|
1332
|
-
return "\n".join(parts)
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
def strip_leading_chain(text: str, chain: List[str]) -> str:
|
|
1336
|
-
"""剥掉段落文本开头与标题链各级重复的前缀。
|
|
1337
|
-
|
|
1338
|
-
接口部分材料的"内容"字段自带段落标题前缀(个别还重复两遍),标题链已承载
|
|
1339
|
-
位置信息,摘录开头再出现同级文本即冗余;逐级最长匹配剥离,无重复则原样返回。
|
|
1340
|
-
"""
|
|
1341
|
-
t = (text or "").strip()
|
|
1342
|
-
cands = set()
|
|
1343
|
-
for lvl in chain:
|
|
1344
|
-
lvl = (lvl or "").strip()
|
|
1345
|
-
if lvl:
|
|
1346
|
-
cands.add(lvl)
|
|
1347
|
-
# 粘连标题(接口未给分隔符,如"建设交通强省5.民航和低空")拆出编号尾部子串
|
|
1348
|
-
parts = re.split(r"(?<=[一-鿿])(?=\d+[.、])", lvl)
|
|
1349
|
-
if len(parts) > 1 and parts[-1].strip():
|
|
1350
|
-
cands.add(parts[-1].strip())
|
|
1351
|
-
levels = sorted(cands, key=len, reverse=True)
|
|
1352
|
-
changed = True
|
|
1353
|
-
while changed and t:
|
|
1354
|
-
changed = False
|
|
1355
|
-
for lvl in levels:
|
|
1356
|
-
if t.startswith(lvl):
|
|
1357
|
-
t = t[len(lvl):].lstrip(" \n\r\t、。;;,,").strip()
|
|
1358
|
-
changed = True
|
|
1359
|
-
break
|
|
1360
|
-
return t
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
def render_crumb(chain: List[str]) -> str:
|
|
1364
|
-
"""面包屑标题链:文章 › 章 › 节(标题链是模型生成的结构化位置,核验核心抓手)。
|
|
1365
|
-
|
|
1366
|
-
降级规则(对齐公文写作 3.7.2):段落本身无章节层级(链上只有文章名)时不显示
|
|
1367
|
-
标题链行——材料卡标题已是文章名,单独一行重复文章名对定位无增量。
|
|
1368
|
-
"""
|
|
1369
|
-
parts = [esc(level) for level in chain if level]
|
|
1370
|
-
if len(parts) <= 1:
|
|
1371
|
-
return ""
|
|
1372
|
-
return '<span class="crumb">' + ' <i>›</i> '.join(parts) + "</span>"
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
def render_segments(source: Dict[str, Any]) -> str:
|
|
1376
|
-
"""多段分块摘录:每段独立区块,各带自己的标题链——段落结构与位置直接可见。"""
|
|
1377
|
-
segments = source.get("segments") or []
|
|
1378
|
-
if not segments:
|
|
1379
|
-
return render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")
|
|
1380
|
-
blocks = []
|
|
1381
|
-
for seg in segments:
|
|
1382
|
-
text = (seg.get("text") or "").strip()
|
|
1383
|
-
if not text:
|
|
1384
|
-
continue
|
|
1385
|
-
blocks.append(f'<div class="seg-block">{render_crumb(seg.get("chain") or [])}'
|
|
1386
|
-
f'{render_excerpt_html(text)}</div>')
|
|
1387
|
-
return "".join(blocks) if blocks else render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
def render_source_card(source: Dict[str, str], for_print: bool = False) -> str:
|
|
1391
|
-
if not source.get("used", True):
|
|
1392
|
-
# 未引用召回材料:不标"已核验"(未进入正文核验流程),只标可否查看
|
|
1393
|
-
vk = ('<span class="sc-vk" style="color:var(--muted)">可查看全文</span>' if source.get("has_link")
|
|
1394
|
-
else '<span class="sc-vk warn">待补链接</span>')
|
|
1395
|
-
note_html = ""
|
|
1396
|
-
elif source.get("verified"):
|
|
1397
|
-
note = source.get("verify_note") or "摘录可比对,可回看原文"
|
|
1398
|
-
if not source.get("has_link"):
|
|
1399
|
-
# PPT 提醒制:无原文链接不改变核验状态,卡片附温和提醒
|
|
1400
|
-
note = "摘录可比对;本条无原文链接,请留意核对"
|
|
1401
|
-
vk = f'<span class="sc-vk ok" title="{esc(note)}">✓ 已核验</span>'
|
|
1402
|
-
if not source.get("has_link"):
|
|
1403
|
-
vk += '<span class="sc-vk warn">◐ 无原文链接</span>'
|
|
1404
|
-
note_html = f'<div class="sc-vnote">{esc(short(note, 90))}</div>' if source.get("verify_note") else ""
|
|
1405
|
-
else:
|
|
1406
|
-
reason = "待补原文链接" if not source.get("has_link") else "待补摘录"
|
|
1407
|
-
vk = f'<span class="sc-vk warn">◐ {reason}</span>'
|
|
1408
|
-
note_html = ""
|
|
1409
|
-
links = render_source_links(source.get("url"), source.get("policy_url", ""), source.get("snapshot", ""))
|
|
1410
|
-
# 关键性行:有文号时"文号 · 生效/失效 · 类型 · 数据源 · 日期",空字段自动跳过
|
|
1411
|
-
eff = source.get("effective_date")
|
|
1412
|
-
exp = source.get("expiry_date")
|
|
1413
|
-
eff_txt = f"生效 {eff}" if eff else ""
|
|
1414
|
-
exp_txt = f"失效 {exp}" if exp else ""
|
|
1415
|
-
meta_parts = [v for v in [source.get("doc_number"), eff_txt, exp_txt, source.get("article_type"),
|
|
1416
|
-
source.get("agency"), source.get("date"), source.get("area")]
|
|
1417
|
-
if v and v != "未知来源"]
|
|
1418
|
-
meta = " | ".join(meta_parts)
|
|
1419
|
-
# 高可信徽标:仅"发布日期可信度=高"(模型治理入库、标题模型精抽)的材料;"较高"(门户抓取)不标。
|
|
1420
|
-
conf_badge = ""
|
|
1421
|
-
if source.get("conf") == "高":
|
|
1422
|
-
conf_badge = ('<span class="sc-conf" title="发布日期可信度:高。内容经模型治理入库,'
|
|
1423
|
-
'标题为模型从原文动态抽取,非规则提取">高可信</span>')
|
|
1424
|
-
# 已引用材料显示角标编号(同文异号时并列显示全部,如 [8][13]);未引用召回材料显示"未引用"灰标
|
|
1425
|
-
if source.get("used", True):
|
|
1426
|
-
ids = sorted(collect_material_ids(source), key=lambda x: (int(x) if x.isdigit() else 10 ** 9, x))
|
|
1427
|
-
id_html = "".join(f'<span class="sc-id">[{esc(i)}]</span>' for i in ids)
|
|
1428
|
-
else:
|
|
1429
|
-
id_html = '<span class="sc-unused">未引用</span>'
|
|
1430
|
-
body_html = (f'<div class="sc-head">{id_html}'
|
|
1431
|
-
f'<span class="sc-type">{esc(source["type_label"])}</span>{conf_badge}{vk}</div>'
|
|
1432
|
-
f'<h4>{esc(source.get("title"))}</h4>'
|
|
1433
|
-
f'<div class="sc-meta">{esc(meta)}</div>'
|
|
1434
|
-
f'{note_html}'
|
|
1435
|
-
f'{render_segments(source)}'
|
|
1436
|
-
f'{links}')
|
|
1437
|
-
if for_print:
|
|
1438
|
-
# 打印附录版:无交互属性,避免与专库卡片 id 冲突
|
|
1439
|
-
return f'<article class="scard print-only {source["type_css"]}">{body_html}</article>'
|
|
1440
|
-
unused_attr = "" if source.get("used", True) else ' data-unused="1"'
|
|
1441
|
-
all_ids_attr = ",".join(collect_material_ids(source))
|
|
1442
|
-
return (
|
|
1443
|
-
f'<article class="scard {source["type_css"]}" id="src-{esc(source["id"])}" data-type="{esc(source["type_key"])}" '
|
|
1444
|
-
f'data-cite-id="{esc(source["id"])}" data-cite-ids="{esc(all_ids_attr)}" '
|
|
1445
|
-
f'data-search="{esc(source.get("search_key", ""))}"{unused_attr}>{body_html}</article>'
|
|
1446
|
-
)
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> str:
|
|
1450
|
-
"""过程回顾条:静态回放真实流程。无思考流数据,不做"深度思考"步骤。"""
|
|
1451
|
-
ov = verification["overall"]
|
|
1452
|
-
tr = verification["traceability"]
|
|
1453
|
-
first_query = stats["conds"][0]["key"] if stats["conds"] else ""
|
|
1454
|
-
detail_rows = "".join(
|
|
1455
|
-
f'<div class="pd-row"><b>{esc(row["key"])}</b>'
|
|
1456
|
-
f'<span>召回 {row["total"]} 条 · 正文采用 {row["used"]} 条</span></div>'
|
|
1457
|
-
for row in stats["conds"]
|
|
1458
|
-
) or '<div class="pd-row"><span>本次溯源 JSON 未记录各次检索条件</span></div>'
|
|
1459
|
-
# 检索记录存在时,明细补一行补搜说明(新增 N 篇 · 补充 K 段),补搜有没有用一眼可见
|
|
1460
|
-
call_log = stats.get("call_log") or []
|
|
1461
|
-
for entry in call_log:
|
|
1462
|
-
if not entry.get("is_supp"):
|
|
1463
|
-
continue
|
|
1464
|
-
na = entry.get("new_articles")
|
|
1465
|
-
np_ = entry.get("added_paragraphs")
|
|
1466
|
-
inc_parts = []
|
|
1467
|
-
if isinstance(na, int):
|
|
1468
|
-
inc_parts.append(f"新增 {na} 篇")
|
|
1469
|
-
if isinstance(np_, int):
|
|
1470
|
-
inc_parts.append(f"补充 {np_} 段")
|
|
1471
|
-
inc_txt = " · ".join(inc_parts) if inc_parts else "增量未记录"
|
|
1472
|
-
label = esc(entry.get("purpose") or entry.get("query") or "缺口补搜")
|
|
1473
|
-
detail_rows += (f'<div class="pd-row"><b>补搜 · {label}</b>'
|
|
1474
|
-
f'<span>{inc_txt}</span></div>')
|
|
1475
|
-
detail_hint = f'{esc(short(first_query, 26))}…' if (stats["n_searches"] > 1 and first_query) else "查看检索明细"
|
|
1476
|
-
if stats["n_searches"] > 1:
|
|
1477
|
-
step1_sub = f"共 {stats['n_searches']} 路检索 · {detail_hint}"
|
|
1478
|
-
elif first_query:
|
|
1479
|
-
step1_sub = esc(short(first_query, 26))
|
|
1480
|
-
else:
|
|
1481
|
-
step1_sub = "深知可信搜索"
|
|
1482
|
-
step4_state = "done" if ov["passed"] else "bad"
|
|
1483
|
-
step4_icon = "✓" if ov["passed"] else "!"
|
|
1484
|
-
step4_label = "核验完成" if ov["passed"] else "核验未完全通过"
|
|
1485
|
-
step4_sub = "结论:正文依据逐条对过原文" if ov["passed"] else esc(short(";".join(ov["reasons"]) or "见核验报告单", 30))
|
|
1486
|
-
n_supp = stats.get("n_supplement") or 0
|
|
1487
|
-
step1_title = f"深知检索 {stats['n_searches']} 路" + (f" · 补搜 {n_supp} 次" if n_supp else "")
|
|
1488
|
-
return f"""
|
|
1489
|
-
<section class="process" aria-label="生成过程回顾">
|
|
1490
|
-
<div class="p-head"><b>过程回顾</b><span>数字来自本次任务的真实记录</span></div>
|
|
1491
|
-
<ol class="p-steps">
|
|
1492
|
-
<li class="p-step expandable" id="p-step-search" role="button" tabindex="0" title="展开各路检索明细">
|
|
1493
|
-
<span class="p-no">1</span>
|
|
1494
|
-
<div class="p-txt"><b>{step1_title}</b><i>{step1_sub}</i></div>
|
|
1495
|
-
</li>
|
|
1496
|
-
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1497
|
-
<li class="p-step">
|
|
1498
|
-
<span class="p-no">2</span>
|
|
1499
|
-
<div class="p-txt"><b>来源文章入库 {stats['n_materials']} 篇</b><i>正文采用 {stats['used_count']} · 召回未采用 {stats['unused_count']}</i></div>
|
|
1500
|
-
</li>
|
|
1501
|
-
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1502
|
-
<li class="p-step">
|
|
1503
|
-
<span class="p-no">3</span>
|
|
1504
|
-
<div class="p-txt"><b>逐条比对原文</b><i>依据溯源 {tr['passed']}/{tr['total']} · 摘录可比对</i></div>
|
|
1505
|
-
</li>
|
|
1506
|
-
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1507
|
-
<li class="p-step {step4_state}">
|
|
1508
|
-
<span class="p-no">{step4_icon}</span>
|
|
1509
|
-
<div class="p-txt"><b>{esc(step4_label)}</b><i>{step4_sub}</i></div>
|
|
1510
|
-
</li>
|
|
1511
|
-
</ol>
|
|
1512
|
-
<div class="p-detail" id="p-detail">{detail_rows}</div>
|
|
1513
|
-
</section>"""
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
def render_library_view(sources: List[Dict[str, str]], hot_terms: List[str]) -> str:
|
|
1517
|
-
"""知识专库全屏视图:大搜索 + 热词 + 检索分组 tabs + 材料卡列表。"""
|
|
1518
|
-
if not sources:
|
|
1519
|
-
return ('<section class="view" id="view-library" aria-label="知识专库">'
|
|
1520
|
-
'<div class="lib-empty">接口返回中未识别到可展示的来源文章。</div></section>')
|
|
1521
|
-
used_sources = [s for s in sources if s.get("used", True)]
|
|
1522
|
-
unused_sources = [s for s in sources if not s.get("used", True)]
|
|
1523
|
-
|
|
1524
|
-
# tabs = 检索分组(全部 / 各路检索 / 未引用),数字真实统计
|
|
1525
|
-
conds: List[Tuple[str, int]] = []
|
|
1526
|
-
for s in sources:
|
|
1527
|
-
key = (s.get("search_key") or "").strip()
|
|
1528
|
-
if not key:
|
|
1529
|
-
continue
|
|
1530
|
-
for i, (name, count) in enumerate(conds):
|
|
1531
|
-
if name == key:
|
|
1532
|
-
conds[i] = (name, count + 1)
|
|
1533
|
-
break
|
|
1534
|
-
else:
|
|
1535
|
-
conds.append((key, 1))
|
|
1536
|
-
tabs = [f'<button class="on" data-cond="" type="button">全部({len(sources)})</button>']
|
|
1537
|
-
for name, count in conds:
|
|
1538
|
-
tabs.append(f'<button data-cond="{esc(name)}" type="button">{esc(name)}({count})</button>')
|
|
1539
|
-
if unused_sources:
|
|
1540
|
-
tabs.append(f'<button data-cond="__unused__" type="button">未引用({len(unused_sources)})</button>')
|
|
1541
|
-
|
|
1542
|
-
hot_html = ""
|
|
1543
|
-
if hot_terms:
|
|
1544
|
-
hot_items = "".join(f'<button class="hot-term" type="button">{esc(term)}</button>' for term in hot_terms)
|
|
1545
|
-
hot_html = f'<div class="hot-terms" aria-label="热门搜索词"><span class="hot-label">大家都在搜</span>{hot_items}</div>'
|
|
1546
|
-
|
|
1547
|
-
cards_html = "".join(render_source_card(s) for s in used_sources)
|
|
1548
|
-
cards_html += "".join(render_source_card(s) for s in unused_sources)
|
|
1549
|
-
|
|
1550
|
-
cited_verified = sum(1 for s in used_sources if s.get("verified"))
|
|
1551
|
-
badge = "全部已核验" if used_sources and cited_verified == len(used_sources) else f"{cited_verified}/{len(used_sources)} 已核验"
|
|
1552
|
-
return f"""
|
|
1553
|
-
<section class="view" id="view-library" aria-label="知识专库">
|
|
1554
|
-
<div class="lib-head">
|
|
1555
|
-
<div class="lib-title"><b>知识专库</b>
|
|
1556
|
-
<span>共 {len(sources)} 条 · 已引用 {len(used_sources)} · {esc(badge)}</span>
|
|
1557
|
-
</div>
|
|
1558
|
-
<div class="lib-searchWrap">
|
|
1559
|
-
<span class="lib-searchIcon" aria-hidden="true">⌕</span>
|
|
1560
|
-
<input class="lib-search" type="search" placeholder="搜索标题 / 来源 / 摘录…" aria-label="搜索来源文章">
|
|
1561
|
-
</div>
|
|
1562
|
-
{hot_html}
|
|
1563
|
-
<div class="lib-tabs" role="tablist" aria-label="按检索分组筛选">{"".join(tabs)}</div>
|
|
1564
|
-
</div>
|
|
1565
|
-
<div class="lib-list" id="lib-list">{cards_html}</div>
|
|
1566
|
-
<div class="lib-empty hide" id="lib-empty">没有符合当前筛选的来源文章。</div>
|
|
1567
|
-
<div class="lib-foot">材料来源:深知可信搜索 · 每条摘录均取自原文原段</div>
|
|
1568
|
-
</section>"""
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
def render_toc(sections: List[Dict[str, Any]]) -> str:
|
|
1572
|
-
"""章节目录(滚动 spy):长报告(≥6 个有标题的章节)显示,桌面端左侧浮动。"""
|
|
1573
|
-
items = []
|
|
1574
|
-
for i, sec in enumerate(sections, 1):
|
|
1575
|
-
title = (sec.get("title") or "").strip()
|
|
1576
|
-
if not title:
|
|
1577
|
-
# 无标题节=正文开头的导语/摘要段(第一个章节标题之前的内容),不是正式章节。
|
|
1578
|
-
# 此前会被兜底成「第 N 节」列进目录(一条读者看不懂的灰色占位项),且该节
|
|
1579
|
-
# 不生成 <section id="sec-i">、锚点根本不存在,点了没反应=死链。内容仍照常
|
|
1580
|
-
# 在正文里展示,只是不占目录条目、不参与滚动高亮。
|
|
1581
|
-
continue
|
|
1582
|
-
number, title_text = split_heading_number(title)
|
|
1583
|
-
label = f"{number} {title_text}" if (number and title_text) else title_text
|
|
1584
|
-
items.append(f'<a href="#sec-{i}">{esc(short(label, 16))}</a>')
|
|
1585
|
-
if len(items) < 6:
|
|
1586
|
-
return ""
|
|
1587
|
-
return f'<nav class="toc" aria-label="章节目录">{"".join(items)}</nav>'
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
def render_print_appendix(sources: List[Dict[str, str]]) -> str:
|
|
1591
|
-
"""打印归档附录:全部材料卡全展开(屏幕不显示,仅打印)。"""
|
|
1592
|
-
if not sources:
|
|
1593
|
-
return ""
|
|
1594
|
-
cards = "".join(render_source_card(s, for_print=True) for s in sources)
|
|
1595
|
-
return (f'<section class="print-appendix" aria-label="来源文章附录(打印归档)">'
|
|
1596
|
-
f'<h3>来源文章(全 {len(sources)} 篇)</h3>{cards}</section>')
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
def _next_version_path(path: Path) -> Path:
|
|
1600
|
-
"""输出文件已存在时不覆盖:自动改为 原名_v2 / _v3 … 另存。
|
|
1601
|
-
|
|
1602
|
-
追加修改后重跑渲染时,旧版本保留、新版本号递增——不覆盖已交付内容,
|
|
1603
|
-
也不会再靠宿主目录里的 "名字 (2)" 兜底。命名与交付重名规则一致(同名 _v2 副本化)。
|
|
1604
|
-
"""
|
|
1605
|
-
if not path.exists():
|
|
1606
|
-
return path
|
|
1607
|
-
for index in range(2, 100):
|
|
1608
|
-
candidate = path.with_name(f"{path.stem}_v{index}{path.suffix}")
|
|
1609
|
-
if not candidate.exists():
|
|
1610
|
-
print(f"提示:{path.name} 已存在,本次输出改为 {candidate.name}(不覆盖旧版)。")
|
|
1611
|
-
return candidate
|
|
1612
|
-
raise SystemExit(f"错误:{path.name} 的版本号 _v2~_v99 均已占用,请清理 {path.parent} 后重试。")
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
def safe_output_filename(question: str, timestamp: datetime, fallback: str = "dknowc_search_trace", suffix_ext: str = ".html") -> str:
|
|
1616
|
-
raw = question.strip() or fallback
|
|
1617
|
-
normalized = re.sub(r"\s+", "_", raw)
|
|
1618
|
-
normalized = re.sub(r"[\\/:*?\"<>|#%&{}$!@`+=;',。、?!:;“”‘’()()【】《》\[\]]+", "", normalized)
|
|
1619
|
-
normalized = normalized.strip("._-")
|
|
1620
|
-
if not normalized:
|
|
1621
|
-
normalized = fallback
|
|
1622
|
-
suffix = timestamp.strftime("%Y%m%d_%H%M")
|
|
1623
|
-
stem = normalized[:32].strip("._-") or fallback
|
|
1624
|
-
return f"{stem}_{suffix}{suffix_ext}"
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
# ============================================================
|
|
1628
|
-
# 链接活性检测与快照兜底(生成时真实检测,就地改写材料 dict)
|
|
1629
|
-
# ============================================================
|
|
1630
|
-
|
|
1631
|
-
def normalize_snapshot_url(raw: str) -> str:
|
|
1632
|
-
"""快照链接规范化:补全 /A/ 层级;非 attach 域原样返回(由调用方弃用)。"""
|
|
1633
|
-
s = (raw or "").strip()
|
|
1634
|
-
base = "https://attach.dknowc.cn/snapshot/"
|
|
1635
|
-
if s.startswith(base + "A/"):
|
|
1636
|
-
return s
|
|
1637
|
-
if s.startswith(base):
|
|
1638
|
-
return base + "A/" + s[len(base):]
|
|
1639
|
-
return s
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
def apply_snapshots(articles: List[Dict[str, Any]]) -> Tuple[int, int]:
|
|
1643
|
-
"""快照兜底预处理:路径补全(/A/ 层级)+ 纯本地格式校验,非法路径弃用。
|
|
1644
|
-
|
|
1645
|
-
不做网络可达检测:attach 前置雷池 WAF 的拦截与请求方 IP 风控相关
|
|
1646
|
-
(检测机高频请求会被拦而普通用户正常),可达性实测会误杀好快照;
|
|
1647
|
-
快照文件本身的存在性由可信搜索侧的数据质量保障。
|
|
1648
|
-
"""
|
|
1649
|
-
fixed = dropped = 0
|
|
1650
|
-
for a in articles:
|
|
1651
|
-
raw = first_str(a.get("快照链接"), a.get("snapshot"), a.get("screenShotPath"), a.get("screenshot_path"))
|
|
1652
|
-
if not raw:
|
|
1653
|
-
continue
|
|
1654
|
-
normalized = normalize_snapshot_url(raw)
|
|
1655
|
-
if normalized != raw:
|
|
1656
|
-
fixed += 1
|
|
1657
|
-
if normalized.startswith("https://attach.dknowc.cn/snapshot/A/"):
|
|
1658
|
-
a["快照链接"] = normalized
|
|
1659
|
-
else:
|
|
1660
|
-
a["快照链接"] = ""
|
|
1661
|
-
dropped += 1
|
|
1662
|
-
return fixed, dropped
|
|
1663
|
-
# ============================================================
|
|
1664
|
-
# 样式与脚本(独立常量,避免模板转义)
|
|
1665
|
-
# ============================================================
|
|
1666
|
-
|
|
1667
|
-
PAGE_CSS = """
|
|
1668
|
-
:root{
|
|
1669
|
-
--navy:#20242c; --navy-2:#3a4152;
|
|
1670
|
-
--ink:#1f2328; --muted:#6b7280; --line:#e5e7eb; --line-strong:#cbd2dd;
|
|
1671
|
-
--brand:#6512ad; --brand-2:#8b5cf6; --brand-soft:#ede9fe;
|
|
1672
|
-
--grad:linear-gradient(135deg,#6512ad,#8b5cf6);
|
|
1673
|
-
--policy:#0f9d6e; --policy-soft:#e3f5ee;
|
|
1674
|
-
--case:#9a6700; --case-soft:#fdf3dc;
|
|
1675
|
-
--ref:#4b5563; --ref-soft:#f0f1f4;
|
|
1676
|
-
--warn:#9a6700; --danger:#e5484d; --ok:#0f9d6e;
|
|
1677
|
-
--shadow-1:0 1px 3px rgba(24,20,40,.04),0 8px 30px rgba(24,20,40,.08);
|
|
1678
|
-
--shadow-2:0 3px 9px rgba(101,18,173,.22),0 14px 36px rgba(24,20,40,.14);
|
|
1679
|
-
--primary-bright:#8b5cf6; --tint:#f3edfc; --tint-2:#faf7ff; --tint-bd:#e9dff9;
|
|
1680
|
-
--tint-strong:#e6d9f9; --tint-bd-strong:#d3bef0; --body-c:#3b4152; --card-bd:#e8e6f0;
|
|
1681
|
-
}
|
|
1682
|
-
*{box-sizing:border-box}
|
|
1683
|
-
html{scroll-behavior:smooth}
|
|
1684
|
-
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,"PingFang SC","HarmonyOS Sans SC","Microsoft YaHei",sans-serif;
|
|
1685
|
-
color:var(--ink);background:#f4f5f7;line-height:1.75;font-size:14.5px}
|
|
1686
|
-
a{color:var(--brand)}
|
|
1687
|
-
|
|
1688
|
-
/* ===== 顶栏 ===== */
|
|
1689
|
-
.topbar{position:sticky;top:0;z-index:50;display:flex;justify-content:space-between;align-items:center;gap:10px;
|
|
1690
|
-
padding:9px 22px;background:rgba(255,255,255,.92);backdrop-filter:blur(10px);
|
|
1691
|
-
border-bottom:1px solid var(--line)}
|
|
1692
|
-
.tb-left{display:flex;align-items:center;gap:10px;min-width:0}
|
|
1693
|
-
.tb-stamp{flex:none;font-size:12.5px;font-weight:800;color:var(--navy);letter-spacing:4px;text-indent:4px}
|
|
1694
|
-
.tb-stamp::before,.tb-stamp::after{content:"";display:inline-block;width:22px;border-top:1px solid var(--line-strong);
|
|
1695
|
-
vertical-align:middle;margin:0 6px}
|
|
1696
|
-
.tb-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:13px}
|
|
1697
|
-
.tb-right{display:flex;align-items:center;gap:8px;flex:none}
|
|
1698
|
-
.view-switch{display:inline-flex;border:1px solid var(--line);border-radius:999px;overflow:hidden;background:#fff}
|
|
1699
|
-
.view-switch button{border:0;background:transparent;color:var(--muted);font-size:12.5px;font-weight:700;
|
|
1700
|
-
padding:5px 14px;cursor:pointer}
|
|
1701
|
-
.view-switch button.on{background:var(--grad);color:#fff}
|
|
1702
|
-
.tb-tools{display:flex;gap:6px}
|
|
1703
|
-
.tb-tools button{border:1px solid var(--line);border-radius:8px;background:#fff;color:#3b3550;
|
|
1704
|
-
font-size:12.5px;font-weight:700;padding:5px 11px;cursor:pointer}
|
|
1705
|
-
.tb-tools button:hover{border-color:var(--brand-2);color:var(--brand)}
|
|
1706
|
-
.tb-tools button[aria-pressed="true"]{background:var(--grad);border-color:var(--brand);color:#fff}
|
|
1707
|
-
.print-menu{position:relative;display:inline-flex}
|
|
1708
|
-
.print-drop{position:absolute;top:calc(100% + 6px);right:0;z-index:70;display:flex;flex-direction:column;gap:4px;
|
|
1709
|
-
min-width:190px;padding:6px;background:#fff;border:1px solid var(--tint-bd);border-radius:10px;
|
|
1710
|
-
box-shadow:var(--shadow-2);text-align:left}
|
|
1711
|
-
.print-drop[hidden]{display:none}
|
|
1712
|
-
.print-drop button{border:0;background:none;border-radius:7px;color:var(--ink);font-size:12.5px;font-weight:600;
|
|
1713
|
-
padding:8px 12px;cursor:pointer;text-align:left;font-family:inherit;white-space:nowrap}
|
|
1714
|
-
.print-drop button:hover{background:var(--tint);color:var(--brand)}
|
|
1715
|
-
.progress{position:absolute;left:0;right:0;bottom:-1px;height:2px;background:transparent}
|
|
1716
|
-
.progress i{display:block;height:100%;width:0;background:linear-gradient(90deg,#6512ad,#8b5cf6)}
|
|
1717
|
-
|
|
1718
|
-
/* ===== Hero ===== */
|
|
1719
|
-
.hero{position:relative;background:linear-gradient(180deg,#fbfaff 0%,#f7f4fd 100%);
|
|
1720
|
-
color:var(--ink);padding:32px 22px 58px;text-align:center;border-bottom:1px solid var(--line)}
|
|
1721
|
-
.r-badge{display:inline-flex;align-items:center;gap:14px;margin:0 0 8px;
|
|
1722
|
-
background:var(--grad);color:#fff;border-radius:999px;padding:4px 22px;
|
|
1723
|
-
font-size:15px;font-weight:800;letter-spacing:7px;text-indent:7px;line-height:1.6;
|
|
1724
|
-
box-shadow:0 2px 8px rgba(101,18,173,.22)}
|
|
1725
|
-
.hero h1{margin:0 0 10px;font-size:24px;line-height:1.5;max-width:860px;margin-left:auto;margin-right:auto;color:var(--ink)}
|
|
1726
|
-
.hero .meta{color:var(--muted);font-size:13px;letter-spacing:.5px}
|
|
1727
|
-
/* 「原问题」行:用户原始需求全文(不能独立使用时最容易被问"这是回答什么的") */
|
|
1728
|
-
.hero-q{display:flex;gap:9px;align-items:flex-start;max-width:860px;margin:2px auto 10px;
|
|
1729
|
-
padding:9px 14px;border:1px dashed var(--tint-bd-strong);border-radius:10px;background:#fff;text-align:left}
|
|
1730
|
-
.hero-q .q-tag{flex:none;font-size:11px;font-weight:800;color:#fff;background:var(--grad);
|
|
1731
|
-
border-radius:5px;padding:1px 8px;margin-top:3px;letter-spacing:1px}
|
|
1732
|
-
.hero-q .q-txt{font-size:13px;line-height:1.75;color:#4b4658;word-break:break-word}
|
|
1733
|
-
.hero-switch{margin-top:16px;display:flex;justify-content:center}
|
|
1734
|
-
.hero-switch .view-switch{border-color:#d9c9f4;background:#fff;box-shadow:0 1px 3px rgba(24,20,40,.04)}
|
|
1735
|
-
.hero-switch .view-switch button{color:#70678a;padding:6px 22px;font-size:13px}
|
|
1736
|
-
.hero-switch .view-switch button.on{background:var(--grad);color:#fff}
|
|
1737
|
-
|
|
1738
|
-
/* ===== 容器与视图 ===== */
|
|
1739
|
-
.container{max-width:1080px;margin:0 auto;padding:0 18px}
|
|
1740
|
-
.app[data-view="library"] #view-report{display:none}
|
|
1741
|
-
/* 专库视图下隐藏章节目录(toc 渲染在 .app 之外,视图切换只驱动 .app[data-view],
|
|
1742
|
-
此前切到专库后目录仍挂在左侧;兄弟选择器为主、括号内写法兼容目录日后移入 .app 内) */
|
|
1743
|
-
.app[data-view="library"] ~ .toc,.app[data-view="library"] .toc{display:none}
|
|
1744
|
-
#view-library{display:none}
|
|
1745
|
-
.app[data-view="library"] #view-library{display:block}
|
|
1746
|
-
|
|
1747
|
-
/* ===== 过程回顾条 ===== */
|
|
1748
|
-
.process{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow-1);
|
|
1749
|
-
padding:15px 20px 13px;margin:-36px auto 16px;position:relative}
|
|
1750
|
-
.p-head{display:flex;align-items:baseline;gap:10px;margin-bottom:10px}
|
|
1751
|
-
.p-head b{font-size:14.5px;color:var(--navy);letter-spacing:1px}
|
|
1752
|
-
.p-head span{font-size:11.5px;color:var(--muted)}
|
|
1753
|
-
.p-steps{list-style:none;display:flex;align-items:stretch;gap:8px;margin:0;padding:0;flex-wrap:wrap}
|
|
1754
|
-
.p-step{display:flex;gap:9px;align-items:center;min-width:0;flex:1 1 150px;
|
|
1755
|
-
border:1px solid var(--line);border-radius:10px;padding:8px 11px;background:#fafbfc}
|
|
1756
|
-
.p-no{flex:none;width:24px;height:24px;border-radius:50%;background:var(--grad);color:#fff;
|
|
1757
|
-
display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:800}
|
|
1758
|
-
.p-txt{min-width:0}
|
|
1759
|
-
.p-txt b{display:block;font-size:12.8px;color:var(--navy);line-height:1.5}
|
|
1760
|
-
.p-txt i{display:block;font-style:normal;font-size:11px;color:var(--muted);line-height:1.5;
|
|
1761
|
-
overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1762
|
-
.p-step.done{border-color:#bfe8da;background:#f2faf7}
|
|
1763
|
-
.p-step.done .p-no{background:var(--ok)}
|
|
1764
|
-
.p-step.bad{border-color:#f6c9cb;background:#fffafa}
|
|
1765
|
-
.p-step.bad .p-no{background:var(--danger)}
|
|
1766
|
-
.p-step.expandable{cursor:pointer}
|
|
1767
|
-
.p-step.expandable:hover{border-color:var(--brand)}
|
|
1768
|
-
.p-arrow{align-self:center;color:#b9c6d9;font-size:16px;font-weight:700;flex:none}
|
|
1769
|
-
.p-detail{display:none;margin-top:10px;border-top:1px dashed var(--line-strong);padding-top:9px}
|
|
1770
|
-
.p-detail.show{display:block}
|
|
1771
|
-
.pd-row{display:flex;justify-content:space-between;gap:14px;padding:3px 2px;font-size:12.3px;flex-wrap:wrap}
|
|
1772
|
-
.pd-row b{color:var(--navy);font-weight:700;min-width:0}
|
|
1773
|
-
.pd-row span{color:var(--muted)}
|
|
1774
|
-
|
|
1775
|
-
/* ===== 核验报告视图 ===== */
|
|
1776
|
-
#view-report{padding-bottom:26px}
|
|
1777
|
-
.warn-box{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
|
|
1778
|
-
background:#fdf3f3;color:#8f2626;font-size:13.5px;line-height:1.7}
|
|
1779
|
-
.verify{margin:0 0 16px;background:#fff;border:1px solid #bfe8da;border-left:4px solid var(--ok);
|
|
1780
|
-
border-radius:14px;padding:16px 20px;box-shadow:var(--shadow-1)}
|
|
1781
|
-
.verify.fail{border-color:#f6c9cb;border-left-color:var(--danger);background:#fffafa}
|
|
1782
|
-
.v-head{display:flex;align-items:center;gap:9px;font-size:15px;font-weight:800;color:var(--ok)}
|
|
1783
|
-
.verify.fail .v-head{color:var(--danger)}
|
|
1784
|
-
.v-shield{display:inline-flex;width:22px;height:22px;border-radius:50%;background:var(--ok);color:#fff;
|
|
1785
|
-
align-items:center;justify-content:center;font-size:12px;flex:none}
|
|
1786
|
-
.verify.fail .v-shield{background:var(--danger)}
|
|
1787
|
-
.v-stamp{margin-left:auto;font-size:11px;border:1.5px solid var(--ok);color:var(--ok);border-radius:5px;
|
|
1788
|
-
padding:1px 8px;letter-spacing:2px;flex:none}
|
|
1789
|
-
.v-stamp.bad{border-color:var(--danger);color:var(--danger)}
|
|
1790
|
-
.v-reasons{margin-top:6px;font-size:12.5px;color:var(--danger)}
|
|
1791
|
-
.v-grid{display:grid;grid-template-columns:1fr 1fr;gap:4px 20px;margin-top:10px}
|
|
1792
|
-
.vi{display:flex;gap:7px;align-items:baseline;font-size:12.5px;color:#3b3550;line-height:1.7;min-width:0}
|
|
1793
|
-
.vi .s{font-weight:800;flex:none}
|
|
1794
|
-
.vi .s.ok{color:var(--ok)}
|
|
1795
|
-
.vi .s.warn{color:var(--warn)}
|
|
1796
|
-
.vi .s.fail{color:var(--danger)}
|
|
1797
|
-
.vi .s.man{color:var(--case)}
|
|
1798
|
-
.vi .s.none{color:var(--muted)}
|
|
1799
|
-
.vi .d{color:var(--muted);min-width:0}
|
|
1800
|
-
.v-note{margin-top:11px;padding-top:9px;border-top:1px dashed var(--line);font-size:11.5px;color:var(--muted);line-height:1.7}
|
|
1801
|
-
|
|
1802
|
-
/* 正文(原型复刻):章节 / 段落 / 角标 / 句后引文胶囊 */
|
|
1803
|
-
.doc-paper{background:#fff;border-radius:14px;box-shadow:var(--shadow-1);padding:26px 34px 22px;margin:0 0 16px}
|
|
1804
|
-
.chapter{margin:40px 0 0}
|
|
1805
|
-
.chapter:first-child{margin-top:6px}
|
|
1806
|
-
.ch-head{display:flex;align-items:center;gap:14px;margin-bottom:18px;scroll-margin-top:86px}
|
|
1807
|
-
.ch-head h2{font-size:19.5px;font-weight:700;color:var(--ink);letter-spacing:.2px;line-height:1.4;flex:1;min-width:0}
|
|
1808
|
-
.ch-head::after{content:"";flex-basis:110px;height:1px;background:linear-gradient(90deg,#e9dff9,transparent);order:3;flex-grow:0;flex-shrink:0}
|
|
1809
|
-
.ch-head .sec-badge{order:4;flex:none;font-size:11.5px;color:var(--ok);background:var(--policy-soft);border-radius:6px;padding:2px 9px;font-weight:700}
|
|
1810
|
-
.ch-head .sec-badge.bad{color:var(--danger);background:#fdecec}
|
|
1811
|
-
@media(min-width:1000px){.ch-head::after{flex-basis:200px}}
|
|
1812
|
-
.lead{font-size:15.5px;line-height:1.95;color:var(--body-c);margin:14px 0;padding:0 2px;word-break:break-word}
|
|
1813
|
-
.para{font-size:15.5px;line-height:1.95;color:var(--body-c);margin:14px 0;padding:0 2px;word-break:break-word}
|
|
1814
|
-
.para b.kw,.lead b.kw{font-weight:600;color:var(--ink)}
|
|
1815
|
-
.doc-divider{border:0;border-top:1px solid var(--line);margin:18px 0}
|
|
1816
|
-
code{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#3f3d52;
|
|
1817
|
-
font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px}
|
|
1818
|
-
.tbl-wrap{max-width:100%;overflow-x:auto;margin:8px 0}
|
|
1819
|
-
.data-tbl{width:100%;border-collapse:collapse;border:1px solid var(--line);font-size:13px}
|
|
1820
|
-
.data-tbl th,.data-tbl td{border:1px solid var(--line);padding:8px 10px;text-align:left;vertical-align:top;line-height:1.65}
|
|
1821
|
-
.data-tbl th{background:#f5f6f8;font-weight:700;color:#3f3d52}
|
|
1822
|
-
.data-tbl.wide{min-width:560px}
|
|
1823
|
-
|
|
1824
|
-
/* 角标 */
|
|
1825
|
-
.cite{display:inline-flex;align-items:center;justify-content:center;min-width:19px;height:18px;padding:0 5px;margin:0 2px 2px 3px;font-size:10.5px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--brand);background:var(--tint);border:1px solid var(--tint-bd);border-radius:5px;cursor:pointer;vertical-align:super;line-height:1;transition:.14s;position:relative;top:-1px;user-select:none;font-family:inherit}
|
|
1826
|
-
.cite:hover{background:var(--brand);border-color:var(--brand);color:#fff}
|
|
1827
|
-
.cite.flash{background:var(--primary-bright);border-color:var(--primary-bright);color:#fff}
|
|
1828
|
-
.cite.unresolved{color:var(--danger);border-color:#f6c9cb;background:#fdf7f7}
|
|
1829
|
-
|
|
1830
|
-
/* 行内引文 jb(原型复刻):角标后小胶囊,点击展开块级卡(溯源原文+引文摘录) */
|
|
1831
|
-
.jb{display:inline-block;vertical-align:top;max-width:100%;margin:2px 4px 2px 0;position:relative}
|
|
1832
|
-
.jb.active{display:block;margin:12px 0 2px;max-width:none}
|
|
1833
|
-
.jb-name{display:inline-flex;align-items:center;gap:6px;max-width:380px;min-height:26px;padding:4px 13px;border-radius:13px;border:1px solid var(--tint-bd);background:var(--tint);color:#540e8f;font-family:inherit;font-size:12px;font-weight:600;line-height:18px;cursor:pointer;transition:.16s;white-space:nowrap}
|
|
1834
|
-
.jb-name:hover{background:#fff;border-color:var(--brand)}
|
|
1835
|
-
.jb-name .jb-id{flex:none;width:18px;height:18px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-style:normal;font-size:10.5px;font-weight:800;font-variant-numeric:tabular-nums;color:#fff;background:linear-gradient(135deg,#6512ad,#8b5cf6);box-shadow:0 1px 3px rgba(101,18,173,.28)}
|
|
1836
|
-
.jb-name .jb-txt{overflow:hidden;text-overflow:ellipsis}
|
|
1837
|
-
.jb-name svg{flex:none;transition:transform .2s}
|
|
1838
|
-
.jb.active .jb-name{max-width:100%;white-space:normal;line-height:20px;color:var(--ink);background:#fff;font-size:13.5px;font-weight:700;text-align:left}
|
|
1839
|
-
.jb.active .jb-name svg{transform:rotate(180deg)}
|
|
1840
|
-
.jb-src{display:inline-flex;align-items:center;gap:5px;min-height:26px;padding:4px 13px;border-radius:13px;background:linear-gradient(135deg,#6512ad,#8b5cf6);color:#fff;font-size:11px;font-weight:600;text-decoration:none;box-shadow:0 2px 8px rgba(101,18,173,.22);transition:.15s;flex-shrink:0}
|
|
1841
|
-
.jb-src:hover{filter:brightness(1.1)}
|
|
1842
|
-
.jb-src span{max-width:210px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1843
|
-
.jb-body{display:none}
|
|
1844
|
-
.jb.active .jb-body{position:relative;display:block;margin-top:13px;background:#fff;border:1px solid var(--card-bd);border-radius:12px;padding:13px 15px;box-shadow:var(--shadow-1)}
|
|
1845
|
-
.jb-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap}
|
|
1846
|
-
.jb-label{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:700;color:var(--brand);letter-spacing:.5px}
|
|
1847
|
-
.jb-label svg{flex:none}
|
|
1848
|
-
.jb-site{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:#70678a;background:#f6f4fa;
|
|
1849
|
-
border:1px solid var(--line);border-radius:999px;padding:3.5px 10px;max-width:100%;overflow:hidden;
|
|
1850
|
-
text-overflow:ellipsis;white-space:nowrap;margin:0 0 2px}
|
|
1851
|
-
.jb-site .dot{width:6px;height:6px;border-radius:50%;background:linear-gradient(135deg,#6512ad,#8b5cf6);flex-shrink:0}
|
|
1852
|
-
.jb-quote{display:flex;gap:9px;align-items:flex-start;margin-top:9px;padding:10px 12px;background:#faf9fd;border:1px solid var(--line);border-radius:9px;text-decoration:none;transition:.15s;cursor:pointer}
|
|
1853
|
-
.jb-quote:hover{border-color:var(--brand);background:#f7f4fc}
|
|
1854
|
-
.jb-no{flex:none;width:17px;height:17px;margin-top:4px;border-radius:4px;background:var(--tint);border:1px solid var(--tint-bd);color:var(--brand);font-size:10px;font-weight:700;font-style:normal;display:flex;align-items:center;justify-content:center}
|
|
1855
|
-
.jb-quote span{font-size:12.5px;line-height:1.95;color:#4b4658;word-break:break-word;text-align:justify}
|
|
1856
|
-
.jb-quote .sc-excerpt{flex:1;min-width:0;display:block}
|
|
1857
|
-
a.jb-quote{text-decoration:none}
|
|
1858
|
-
.jb.flash{animation:cardFlash 1.6s ease}
|
|
1859
|
-
@keyframes cardFlash{0%,100%{box-shadow:none}30%{box-shadow:0 0 0 3px rgba(139,92,246,.45)}}
|
|
1860
|
-
.sc-links{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}
|
|
1861
|
-
.sc-links span{display:inline-flex}
|
|
1862
|
-
.sc-links a{display:inline-flex;align-items:center;min-height:24px;padding:3px 9px;border-radius:6px;
|
|
1863
|
-
background:var(--brand-soft);color:var(--brand);font-weight:700;text-decoration:none;font-size:12px}
|
|
1864
|
-
|
|
1865
|
-
/* ===== 知识专库视图 ===== */
|
|
1866
|
-
#view-library{padding:26px 0 30px}
|
|
1867
|
-
.lib-head{max-width:860px;margin:0 auto 16px;text-align:center}
|
|
1868
|
-
.lib-title{margin-bottom:14px}
|
|
1869
|
-
.lib-title b{font-size:17px;color:var(--navy);letter-spacing:2px}
|
|
1870
|
-
.lib-title span{display:block;font-size:12px;color:var(--muted);margin-top:2px}
|
|
1871
|
-
.lib-searchWrap{position:relative;max-width:620px;margin:0 auto}
|
|
1872
|
-
.lib-searchIcon{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#a6adbd;font-size:16px;font-weight:700}
|
|
1873
|
-
.lib-search{width:100%;padding:11px 16px 11px 38px;border:1.5px solid var(--line-strong);border-radius:999px;
|
|
1874
|
-
font-size:14px;background:#fff;box-shadow:var(--shadow-1);outline:none}
|
|
1875
|
-
.lib-search:focus{border-color:var(--brand-2);box-shadow:0 0 0 3px rgba(139,92,246,.18)}
|
|
1876
|
-
.hot-terms{display:flex;flex-wrap:wrap;justify-content:center;gap:7px;margin-top:12px;align-items:center}
|
|
1877
|
-
.hot-label{font-size:12px;color:var(--muted)}
|
|
1878
|
-
.hot-term{border:0;border-radius:999px;background:var(--brand-soft);color:var(--brand);
|
|
1879
|
-
font-size:12.3px;font-weight:700;padding:3px 13px;cursor:pointer}
|
|
1880
|
-
.hot-term:hover{background:var(--grad);color:#fff}
|
|
1881
|
-
.lib-tabs{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:14px}
|
|
1882
|
-
.lib-tabs button{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
|
|
1883
|
-
padding:4px 13px;font-size:12.3px;cursor:pointer}
|
|
1884
|
-
.lib-tabs button.on{background:var(--grad);border-color:var(--brand);color:#fff;font-weight:700}
|
|
1885
|
-
.lib-list{max-width:860px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr);gap:14px}
|
|
1886
|
-
.lib-empty{max-width:860px;margin:30px auto;text-align:center;color:var(--muted);font-size:13.5px}
|
|
1887
|
-
.lib-empty.hide{display:none}
|
|
1888
|
-
.lib-foot{text-align:center;color:var(--muted);font-size:11.5px;padding:18px 0 0;line-height:1.8}
|
|
1889
|
-
|
|
1890
|
-
/* ===== 材料卡 ===== */
|
|
1891
|
-
.scard{min-width:0;border:1px solid var(--line);border-left-width:3px;border-radius:12px;padding:14px 18px;
|
|
1892
|
-
background:#fff;box-shadow:var(--shadow-1);transition:box-shadow .25s}
|
|
1893
|
-
.scard:hover{box-shadow:var(--shadow-2)}
|
|
1894
|
-
.scard.pol{border-left-color:var(--policy)}
|
|
1895
|
-
.scard.dat{border-left-color:var(--brand-2)}
|
|
1896
|
-
.scard.cas{border-left-color:var(--case)}
|
|
1897
|
-
.scard.ref,.scard.mat{border-left-color:var(--ref)}
|
|
1898
|
-
.scard.hl{box-shadow:0 0 0 3px rgba(139,92,246,.35),var(--shadow-2)}
|
|
1899
|
-
.scard.hide{display:none}
|
|
1900
|
-
.sc-head{display:flex;align-items:center;gap:7px;margin-bottom:6px}
|
|
1901
|
-
.sc-id{font-family:monospace;font-weight:800;font-size:11px;color:#fff;background:var(--grad);
|
|
1902
|
-
border-radius:5px;padding:1px 8px}
|
|
1903
|
-
.sc-type{font-size:11px;font-weight:700;border-radius:4px;padding:1px 8px;background:var(--ref-soft);color:var(--ref)}
|
|
1904
|
-
.scard.pol .sc-type{background:var(--policy-soft);color:var(--policy)}
|
|
1905
|
-
.scard.dat .sc-type{background:var(--brand-soft);color:var(--brand)}
|
|
1906
|
-
.scard.cas .sc-type{background:var(--case-soft);color:var(--case)}
|
|
1907
|
-
.sc-vk{margin-left:auto;font-size:11px;font-weight:800;color:var(--ok)}
|
|
1908
|
-
.sc-vk + .sc-vk{margin-left:0}
|
|
1909
|
-
.sc-vk.warn{color:var(--warn)}
|
|
1910
|
-
.sc-unused{font-size:10.5px;font-weight:800;color:var(--muted);background:#efedf4;border-radius:4px;
|
|
1911
|
-
padding:1px 7px;flex:none}
|
|
1912
|
-
.sc-conf{font-size:10.5px;font-weight:800;color:#8a5a00;background:var(--case-soft);border:1px solid #e6cf8f;
|
|
1913
|
-
border-radius:4px;padding:0 7px;flex:none}
|
|
1914
|
-
.scard h4{margin:0 0 5px;font-size:14.5px;color:var(--ink);line-height:1.55}
|
|
1915
|
-
.sc-meta{font-size:11.5px;color:var(--muted)}
|
|
1916
|
-
/* 标题链面包屑(模型生成的结构化位置,核验核心抓手)与多段分块 */
|
|
1917
|
-
.crumb{font-size:11.5px;color:var(--brand);margin:10px 0 4px;font-weight:600;line-height:1.6;
|
|
1918
|
-
padding:3px 9px;background:var(--tint);border-radius:7px;display:inline-block;max-width:100%;
|
|
1919
|
-
overflow-wrap:break-word}
|
|
1920
|
-
.crumb i{font-style:normal;color:#c9b3ec;margin:0 2px;font-weight:400}
|
|
1921
|
-
.seg-block{margin-top:8px}
|
|
1922
|
-
.seg-block:first-child{margin-top:2px}
|
|
1923
|
-
.seg-block .sc-excerpt{margin-top:5px}
|
|
1924
|
-
.sc-vnote{margin-top:5px;font-size:11.3px;color:var(--ok);line-height:1.6}
|
|
1925
|
-
.sc-excerpt{margin:8px 0 0;padding:10px 12px;border:1px solid #eceaf2;border-radius:9px;
|
|
1926
|
-
background:#faf9fd;color:#4a4260;font-size:12.3px;line-height:1.75}
|
|
1927
|
-
.sc-excerpt.rich{overflow-x:auto}
|
|
1928
|
-
.sc-excerpt.rich table{width:max-content;min-width:100%;border-collapse:collapse;background:#fff;font-size:12px}
|
|
1929
|
-
.sc-excerpt.rich td,.sc-excerpt.rich th{min-width:92px;max-width:220px;padding:7px 8px;border:1px solid var(--line);
|
|
1930
|
-
vertical-align:top;word-break:break-word}
|
|
1931
|
-
.sc-excerpt.rich thead td,.sc-excerpt.rich th{background:#f3f4f6;color:#3f3d52;font-weight:700}
|
|
1932
|
-
.scard .sc-links a{font-size:12px}
|
|
1933
|
-
.scard .sc-links{margin-top:4px}
|
|
1934
|
-
.no-link{font-size:11.5px;color:var(--muted)}
|
|
1935
|
-
.sc-links a.snap{background:#faf5ff;border-color:#d9c9f4;color:#5b21b6}
|
|
1936
|
-
.dead-link{font-size:11.5px;color:var(--warn)}
|
|
1937
|
-
|
|
1938
|
-
/* ===== 章节目录(spy,长报告) ===== */
|
|
1939
|
-
.toc{position:fixed;left:calc((100vw - 1080px)/2 - 168px);top:120px;width:140px;max-height:60vh;overflow:auto;
|
|
1940
|
-
display:flex;flex-direction:column;gap:2px;font-size:12px}
|
|
1941
|
-
.toc a{color:var(--muted);text-decoration:none;padding:4px 10px;border-left:2px solid var(--line);
|
|
1942
|
-
line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1943
|
-
.toc a.on{color:var(--brand);border-left-color:var(--brand);font-weight:700}
|
|
1944
|
-
@media (max-width:1460px){.toc{display:none}}
|
|
1945
|
-
|
|
1946
|
-
.foot{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}
|
|
1947
|
-
|
|
1948
|
-
/* ===== 只看正文(纯净阅读态) ===== */
|
|
1949
|
-
body.reading .process,body.reading .verify,body.reading .jb,body.reading .sec-badge,
|
|
1950
|
-
body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!important}
|
|
1951
|
-
|
|
1952
|
-
/* ===== 打印附录 ===== */
|
|
1953
|
-
.print-appendix{display:none}
|
|
1954
|
-
|
|
1955
|
-
/* ===== 移动端 ===== */
|
|
1956
|
-
.sheet-mask{display:none}
|
|
1957
|
-
.sheet{display:none}
|
|
1958
|
-
@media (max-width:680px){
|
|
1959
|
-
body{font-size:14px;line-height:1.8}
|
|
1960
|
-
.topbar{padding:7px 10px;gap:6px}
|
|
1961
|
-
.tb-stamp{font-size:11px;letter-spacing:2px;text-indent:2px}
|
|
1962
|
-
.tb-stamp::before,.tb-stamp::after{width:12px;margin:0 4px}
|
|
1963
|
-
.tb-title{display:none}
|
|
1964
|
-
.topbar .view-switch{display:none}
|
|
1965
|
-
.tb-tools button{font-size:11.5px;padding:4px 8px}
|
|
1966
|
-
.hero{padding:24px 14px 50px}
|
|
1967
|
-
.ch-head{gap:8px;margin-bottom:14px;flex-wrap:nowrap}
|
|
1968
|
-
.ch-head h2{font-size:17px;line-height:1.45}
|
|
1969
|
-
.ch-head::after{display:none}
|
|
1970
|
-
.ch-head .sec-badge{font-size:10.5px;padding:2px 7px;white-space:nowrap}
|
|
1971
|
-
.jb-name{max-width:calc(100vw - 72px)}
|
|
1972
|
-
.r-badge{font-size:13.5px;letter-spacing:6px;text-indent:6px;gap:10px}
|
|
1973
|
-
.hero h1{font-size:18.5px}
|
|
1974
|
-
.hero-q{padding:8px 11px;gap:7px}
|
|
1975
|
-
.hero-q .q-txt{font-size:12.5px}
|
|
1976
|
-
.hero .meta{font-size:11.5px;line-height:1.7}
|
|
1977
|
-
.hero-switch .view-switch button{padding:6px 16px;font-size:12.5px}
|
|
1978
|
-
.process{margin-top:-30px;padding:12px 12px 11px}
|
|
1979
|
-
.p-step{flex:1 1 100%}
|
|
1980
|
-
.p-arrow{display:none}
|
|
1981
|
-
.verify{padding:13px 14px}
|
|
1982
|
-
.v-head{font-size:14px}
|
|
1983
|
-
.v-grid{grid-template-columns:1fr;gap:2px 0}
|
|
1984
|
-
.vi{flex-wrap:wrap;gap:4px 8px}
|
|
1985
|
-
.vi .d{min-width:0}
|
|
1986
|
-
.warn-box{font-size:12.5px;padding:11px 12px}
|
|
1987
|
-
.doc-paper{padding:16px 14px 10px;border-radius:10px}
|
|
1988
|
-
.data-tbl{font-size:12px}
|
|
1989
|
-
.data-tbl th,.data-tbl td{padding:6px 7px;line-height:1.55}
|
|
1990
|
-
.cite{font-size:11px;padding:0 4px}
|
|
1991
|
-
#view-library{padding:18px 0 24px}
|
|
1992
|
-
.lib-search{padding:10px 14px 10px 34px;font-size:13.5px}
|
|
1993
|
-
.lib-tabs{justify-content:flex-start;flex-wrap:nowrap;overflow-x:auto;padding-bottom:4px;
|
|
1994
|
-
-webkit-overflow-scrolling:touch;scrollbar-width:none}
|
|
1995
|
-
.lib-tabs::-webkit-scrollbar{display:none}
|
|
1996
|
-
.lib-tabs button{flex:none}
|
|
1997
|
-
.lib-list{grid-template-columns:minmax(0,1fr);gap:10px}
|
|
1998
|
-
.scard{padding:10px 11px}
|
|
1999
|
-
.crumb{font-size:11px}
|
|
2000
|
-
.sc-excerpt{font-size:11.5px}
|
|
2001
|
-
/* 移动端材料底部弹层:点角标就地弹出材料卡,不跳转打断阅读 */
|
|
2002
|
-
.sheet-mask{display:block;position:fixed;inset:0;background:rgba(11,31,58,.45);z-index:99;opacity:0;
|
|
2003
|
-
pointer-events:none;transition:opacity .2s}
|
|
2004
|
-
.sheet-mask.show{opacity:1;pointer-events:auto}
|
|
2005
|
-
.sheet{display:block;position:fixed;left:0;right:0;bottom:0;z-index:100;background:#fff;
|
|
2006
|
-
border-radius:14px 14px 0 0;box-shadow:0 -8px 30px rgba(11,31,58,.25);
|
|
2007
|
-
max-height:68vh;overflow-y:auto;-webkit-overflow-scrolling:touch;
|
|
2008
|
-
padding:10px 16px 22px;transform:translateY(105%);transition:transform .25s ease}
|
|
2009
|
-
.sheet.show{transform:translateY(0)}
|
|
2010
|
-
.sheet-grab{width:38px;height:4px;border-radius:2px;background:#c9d4e2;margin:2px auto 8px}
|
|
2011
|
-
.sheet-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
|
|
2012
|
-
.sheet-head b{font-size:13.5px;color:var(--navy)}
|
|
2013
|
-
.sheet-close{border:1px solid var(--line);background:#f5f3fa;border-radius:8px;color:#3b4a61;
|
|
2014
|
-
font-size:12.5px;font-weight:700;padding:5px 14px;cursor:pointer}
|
|
2015
|
-
.sheet .scard{box-shadow:none;margin-bottom:0}
|
|
2016
|
-
.sheet .sc-excerpt{display:block;-webkit-line-clamp:unset;cursor:auto}
|
|
2017
|
-
/* 正文表述 ↔ 原文原段 对照区(弹层顶部) */
|
|
2018
|
-
.cmp{margin:0 0 10px;border:1px solid var(--line);border-radius:10px;overflow:hidden}
|
|
2019
|
-
.cmp-tag{font-size:11px;font-weight:800;padding:3px 10px}
|
|
2020
|
-
.cmp-side{padding:9px 12px;font-size:12.8px;line-height:1.7}
|
|
2021
|
-
.cmp-side p{margin:0}
|
|
2022
|
-
.cmp-ai{background:#fbfaff;color:#3f3d52}
|
|
2023
|
-
.cmp-ai .cmp-tag{background:#eef1f6;color:var(--ref)}
|
|
2024
|
-
.cmp-src{background:#f4faf7;color:#2f4a3e;border-top:1px dashed var(--line-strong)}
|
|
2025
|
-
.cmp-src .cmp-tag{background:var(--policy-soft);color:#0b6e4f}
|
|
2026
|
-
.cmp-src .sc-excerpt{display:block;-webkit-line-clamp:unset;background:#fff;cursor:auto;font-size:12px;padding:8px 10px;margin:0}
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
/* ===== 打印归档 ===== */
|
|
2030
|
-
@media print{
|
|
2031
|
-
.topbar,.process .p-detail,.hero-switch,.tb-tools,.view-switch,.lib-head,.toc,.sheet,.sheet-mask,
|
|
2032
|
-
.progress{display:none!important}
|
|
2033
|
-
#view-library{display:none!important}
|
|
2034
|
-
#view-report{display:block!important}
|
|
2035
|
-
.app[data-view="library"] #view-report{display:block!important}
|
|
2036
|
-
.hero{background:none;border:0;color:var(--ink);padding:10px 0 4px}
|
|
2037
|
-
.hero-q{border-color:#bbb;break-inside:avoid}
|
|
2038
|
-
.hero .meta{color:var(--muted)}
|
|
2039
|
-
*{-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
2040
|
-
.process{box-shadow:none;margin:6px 0 12px}
|
|
2041
|
-
.verify{border-color:#bbb;box-shadow:none;break-inside:avoid}
|
|
2042
|
-
.doc-paper{box-shadow:none;border-radius:0;padding:0}
|
|
2043
|
-
body{background:#fff;font-size:12.5px}
|
|
2044
|
-
.sc-excerpt{display:block;-webkit-line-clamp:unset;cursor:auto}
|
|
2045
|
-
.scard{break-inside:avoid}
|
|
2046
|
-
.cite{background:none!important;color:#333!important;text-decoration:none!important}
|
|
2047
|
-
.cite::before{content:"["}.cite::after{content:"]"}
|
|
2048
|
-
.jb{display:inline!important}
|
|
2049
|
-
.jb .jb-name{border:0;background:none;padding:0;color:#333;font-weight:600}
|
|
2050
|
-
.jb .jb-name .jb-id{color:#333;background:none;border:1px solid #999;border-radius:3px}
|
|
2051
|
-
.jb .jb-body{display:none!important}
|
|
2052
|
-
.jb.active{break-inside:avoid}
|
|
2053
|
-
.jb.active .jb-body{display:block!important}
|
|
2054
|
-
.jb.active .jb-body .jb-quote{break-inside:avoid}
|
|
2055
|
-
body.reading .verify,body.reading .process,body.reading .ev-row,body.reading .sec-badge,
|
|
2056
|
-
body.reading .cite{display:none!important}
|
|
2057
|
-
.print-appendix{display:block;break-before:page}
|
|
2058
|
-
body.print-body-only .verify,body.print-body-only .process,body.print-body-only .print-appendix,
|
|
2059
|
-
body.print-body-only .jb,body.print-body-only .foot{display:none!important}
|
|
2060
|
-
.print-appendix h3{font-size:15px;color:var(--navy);border-bottom:1px solid #999;padding-bottom:6px;margin:0 0 12px}
|
|
2061
|
-
.print-appendix .scard{margin-bottom:10px}
|
|
2062
|
-
/* 打印时宽表格贴合页宽(屏幕端靠 .sc-excerpt.rich 横向滚动,纸张上不能滚) */
|
|
2063
|
-
.print-appendix .sc-excerpt.rich,.sc-excerpt.rich{overflow-x:visible}
|
|
2064
|
-
.print-appendix .sc-excerpt.rich table,.sc-excerpt.rich table{width:100%!important;min-width:0}
|
|
2065
|
-
}
|
|
2066
|
-
"""
|
|
2067
|
-
|
|
2068
|
-
PAGE_JS = """
|
|
2069
|
-
(function () {
|
|
2070
|
-
"use strict";
|
|
2071
|
-
function $(sel, root) { return (root || document).querySelector(sel); }
|
|
2072
|
-
function $$(sel, root) { return Array.prototype.slice.call((root || document).querySelectorAll(sel)); }
|
|
2073
|
-
|
|
2074
|
-
var app = $(".app");
|
|
2075
|
-
var isMobile = function () { return window.matchMedia("(max-width:680px)").matches; };
|
|
2076
|
-
|
|
2077
|
-
/* ===== 1. 双视图切换(保存/恢复各自滚动位置) ===== */
|
|
2078
|
-
var savedScroll = { report: 0, library: 0 };
|
|
2079
|
-
function setView(view) {
|
|
2080
|
-
if (!app || app.getAttribute("data-view") === view) return;
|
|
2081
|
-
savedScroll[app.getAttribute("data-view") || "report"] = window.scrollY;
|
|
2082
|
-
app.setAttribute("data-view", view);
|
|
2083
|
-
$$(".view-switch button").forEach(function (b) {
|
|
2084
|
-
b.classList.toggle("on", b.getAttribute("data-view") === view);
|
|
2085
|
-
});
|
|
2086
|
-
window.scrollTo(0, Math.max(0, savedScroll[view] || 0));
|
|
2087
|
-
}
|
|
2088
|
-
$$(".view-switch button").forEach(function (b) {
|
|
2089
|
-
b.addEventListener("click", function () { setView(b.getAttribute("data-view")); });
|
|
2090
|
-
});
|
|
2091
|
-
|
|
2092
|
-
/* ===== 2. 阅读进度条 ===== */
|
|
2093
|
-
var progress = $(".progress i");
|
|
2094
|
-
function updateProgress() {
|
|
2095
|
-
if (!progress) return;
|
|
2096
|
-
var h = document.documentElement;
|
|
2097
|
-
var max = h.scrollHeight - h.clientHeight;
|
|
2098
|
-
progress.style.width = (max > 0 ? Math.min(100, (h.scrollTop / max) * 100) : 0) + "%";
|
|
2099
|
-
}
|
|
2100
|
-
window.addEventListener("scroll", updateProgress, { passive: true });
|
|
2101
|
-
updateProgress();
|
|
2102
|
-
|
|
2103
|
-
/* ===== 3. 只看正文(纯净阅读态切换) ===== */
|
|
2104
|
-
var readBtn = $("#btn-reading");
|
|
2105
|
-
if (readBtn) {
|
|
2106
|
-
readBtn.addEventListener("click", function () {
|
|
2107
|
-
var on = document.body.classList.toggle("reading");
|
|
2108
|
-
readBtn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
2109
|
-
readBtn.textContent = on ? "显示核验" : "只看正文";
|
|
2110
|
-
/* 只看正文只作用于核验报告视图:正在知识专库时切回报告,专库不受影响 */
|
|
2111
|
-
if (on && app && app.getAttribute("data-view") !== "report") setView("report");
|
|
2112
|
-
});
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
/* ===== 4. 复制全文(章节标题 + 段落 + 表格,去角标) ===== */
|
|
2116
|
-
var copyBtn = $("#btn-copy");
|
|
2117
|
-
if (copyBtn) {
|
|
2118
|
-
copyBtn.addEventListener("click", function () {
|
|
2119
|
-
var parts = [];
|
|
2120
|
-
/* 按文档流顺序收集章节标题/段落/表格;克隆后剔除引文胶囊与角标,
|
|
2121
|
-
只复制正文本身(胶囊标题/展开摘录/编号数字均不带出) */
|
|
2122
|
-
var nodes = $$("#view-report .ch-head h2, #view-report .lead, #view-report .para, #view-report .tbl-wrap");
|
|
2123
|
-
nodes.sort(function (a, b) { return (a.compareDocumentPosition(b) & 4) ? -1 : 1; });
|
|
2124
|
-
nodes.forEach(function (el) {
|
|
2125
|
-
var clone = el.cloneNode(true);
|
|
2126
|
-
clone.querySelectorAll(".jb, sup.cite").forEach(function (x) { x.remove(); });
|
|
2127
|
-
var t = clone.textContent.replace(/[ \\t]+/g, " ").trim();
|
|
2128
|
-
if (t) parts.push(t);
|
|
2129
|
-
});
|
|
2130
|
-
var text = parts.filter(Boolean).join("\\n\\n");
|
|
2131
|
-
function done(ok) {
|
|
2132
|
-
var old = copyBtn.textContent;
|
|
2133
|
-
copyBtn.textContent = ok ? "已复制 ✓" : "复制失败";
|
|
2134
|
-
setTimeout(function () { copyBtn.textContent = old; }, 1600);
|
|
2135
|
-
}
|
|
2136
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
2137
|
-
navigator.clipboard.writeText(text).then(function () { done(true); }, function () { done(fallback(text)); });
|
|
2138
|
-
} else {
|
|
2139
|
-
done(fallback(text));
|
|
2140
|
-
}
|
|
2141
|
-
function fallback(value) {
|
|
2142
|
-
try {
|
|
2143
|
-
var ta = document.createElement("textarea");
|
|
2144
|
-
ta.value = value;
|
|
2145
|
-
ta.style.position = "fixed";
|
|
2146
|
-
ta.style.opacity = "0";
|
|
2147
|
-
document.body.appendChild(ta);
|
|
2148
|
-
ta.select();
|
|
2149
|
-
var ok = document.execCommand("copy");
|
|
2150
|
-
document.body.removeChild(ta);
|
|
2151
|
-
return ok;
|
|
2152
|
-
} catch (e) { return false; }
|
|
2153
|
-
}
|
|
2154
|
-
});
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
/* ===== 5. 打印归档(PDF):下拉双选项——只打印正文 / 完整归档 ===== */
|
|
2158
|
-
var printBtn = $("#btn-print");
|
|
2159
|
-
var printDrop = $("#print-drop");
|
|
2160
|
-
function printBy(mode) {
|
|
2161
|
-
if (mode === "body") document.body.classList.add("print-body-only");
|
|
2162
|
-
if (printDrop) printDrop.hidden = true;
|
|
2163
|
-
window.print();
|
|
2164
|
-
}
|
|
2165
|
-
if (printBtn && printDrop) {
|
|
2166
|
-
printBtn.addEventListener("click", function (e) {
|
|
2167
|
-
e.stopPropagation();
|
|
2168
|
-
printDrop.hidden = !printDrop.hidden;
|
|
2169
|
-
});
|
|
2170
|
-
printDrop.addEventListener("click", function (e) {
|
|
2171
|
-
e.stopPropagation();
|
|
2172
|
-
var t = e.target.closest("button");
|
|
2173
|
-
if (!t) return;
|
|
2174
|
-
printBy(t.id === "print-body" ? "body" : "full");
|
|
2175
|
-
});
|
|
2176
|
-
document.addEventListener("click", function () { printDrop.hidden = true; });
|
|
2177
|
-
/* 打印结束移除临时模式(浏览器打印窗口关闭后触发) */
|
|
2178
|
-
window.addEventListener("afterprint", function () { document.body.classList.remove("print-body-only"); });
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
/* ===== 6. 材料卡索引(专库列表内,不含打印附录) ===== */
|
|
2182
|
-
var cards = $$("#lib-list .scard");
|
|
2183
|
-
var byId = {};
|
|
2184
|
-
cards.forEach(function (c) {
|
|
2185
|
-
/* 同文异号的多编号都指向同一张卡(data-cite-ids),任一编号都能定位 */
|
|
2186
|
-
var ids = (c.getAttribute("data-cite-ids") || c.getAttribute("data-cite-id") || "").split(",");
|
|
2187
|
-
ids.forEach(function (id) {
|
|
2188
|
-
id = (id || "").trim();
|
|
2189
|
-
if (id) byId[id] = c;
|
|
2190
|
-
});
|
|
2191
|
-
});
|
|
2192
|
-
|
|
2193
|
-
/* 移动端底部弹层:正文表述 ↔ 原文原段 对照 + 材料卡 */
|
|
2194
|
-
var sheet = $(".sheet");
|
|
2195
|
-
var mask = $(".sheet-mask");
|
|
2196
|
-
function escHtml(s) {
|
|
2197
|
-
var d = document.createElement("div");
|
|
2198
|
-
d.textContent = s;
|
|
2199
|
-
return d.innerHTML;
|
|
2200
|
-
}
|
|
2201
|
-
function sentenceOf(el) {
|
|
2202
|
-
var para = el && el.closest ? el.closest(".para,.lead") : null;
|
|
2203
|
-
return para ? para.innerText.trim() : "";
|
|
2204
|
-
}
|
|
2205
|
-
function openSheet(card, sentence) {
|
|
2206
|
-
if (!sheet) return;
|
|
2207
|
-
var body = sheet.querySelector(".sheet-body");
|
|
2208
|
-
body.innerHTML = "";
|
|
2209
|
-
if (sentence) {
|
|
2210
|
-
var excerpt = card.querySelector(".sc-excerpt");
|
|
2211
|
-
var cmp = document.createElement("div");
|
|
2212
|
-
cmp.className = "cmp";
|
|
2213
|
-
cmp.innerHTML =
|
|
2214
|
-
'<div class="cmp-side cmp-ai"><div class="cmp-tag">正文表述</div><p>' + escHtml(sentence) + '</p></div>' +
|
|
2215
|
-
'<div class="cmp-side cmp-src"><div class="cmp-tag">原文原段</div>' +
|
|
2216
|
-
'<div class="sc-excerpt">' + (excerpt ? excerpt.innerHTML : "") + '</div></div>';
|
|
2217
|
-
body.appendChild(cmp);
|
|
2218
|
-
}
|
|
2219
|
-
var clone = card.cloneNode(true);
|
|
2220
|
-
clone.removeAttribute("id");
|
|
2221
|
-
clone.classList.remove("hide");
|
|
2222
|
-
clone.classList.add("open");
|
|
2223
|
-
body.appendChild(clone);
|
|
2224
|
-
sheet.classList.add("show");
|
|
2225
|
-
mask.classList.add("show");
|
|
2226
|
-
document.body.style.overflow = "hidden";
|
|
2227
|
-
sheet.scrollTop = 0;
|
|
2228
|
-
}
|
|
2229
|
-
function closeSheet() {
|
|
2230
|
-
if (!sheet) return;
|
|
2231
|
-
sheet.classList.remove("show");
|
|
2232
|
-
mask.classList.remove("show");
|
|
2233
|
-
document.body.style.overflow = "";
|
|
2234
|
-
}
|
|
2235
|
-
if (sheet && mask) {
|
|
2236
|
-
mask.addEventListener("click", closeSheet);
|
|
2237
|
-
var closeBtn = sheet.querySelector(".sheet-close");
|
|
2238
|
-
if (closeBtn) closeBtn.addEventListener("click", closeSheet);
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
/* 行内引文 jb(原型行为):点小胶囊 toggle 展开卡;展开卡内引文条目点击进专库。
|
|
2242
|
-
未绑定角标红色警示,绝不按位置猜测。 */
|
|
2243
|
-
var JB_TABLES = {};
|
|
2244
|
-
try {
|
|
2245
|
-
var jbTablesEl = document.getElementById("jb-tables");
|
|
2246
|
-
if (jbTablesEl) JB_TABLES = JSON.parse(jbTablesEl.textContent || "{}");
|
|
2247
|
-
} catch (e) { JB_TABLES = {}; }
|
|
2248
|
-
function fillTableHolders(jb) {
|
|
2249
|
-
jb.querySelectorAll(".tbl-holder[data-tbl]").forEach(function (h) {
|
|
2250
|
-
if (h.getAttribute("data-filled")) return;
|
|
2251
|
-
var html = JB_TABLES[h.getAttribute("data-tbl")];
|
|
2252
|
-
if (html) h.innerHTML = html;
|
|
2253
|
-
h.setAttribute("data-filled", "1");
|
|
2254
|
-
});
|
|
2255
|
-
}
|
|
2256
|
-
function toggleJb(jb, forceOpen) {
|
|
2257
|
-
var open = forceOpen === true ? true : !jb.classList.contains("active");
|
|
2258
|
-
document.querySelectorAll(".jb.active").forEach(function (x) { if (x !== jb) x.classList.remove("active"); });
|
|
2259
|
-
jb.classList.toggle("active", open);
|
|
2260
|
-
if (open) fillTableHolders(jb);
|
|
2261
|
-
var name = jb.querySelector(".jb-name");
|
|
2262
|
-
if (name) name.setAttribute("aria-expanded", open ? "true" : "false");
|
|
2263
|
-
return open;
|
|
2264
|
-
}
|
|
2265
|
-
document.querySelectorAll(".jb-name").forEach(function (name) {
|
|
2266
|
-
name.addEventListener("click", function () { toggleJb(name.closest(".jb")); });
|
|
2267
|
-
});
|
|
2268
|
-
|
|
2269
|
-
/* 引文条目点击 → 知识专库定位对应卡:库内导航看完整材料;
|
|
2270
|
-
外部原文跳转只保留 jb-head 的"查看全文"按钮,动线分离 */
|
|
2271
|
-
function jumpToLibrary(id) {
|
|
2272
|
-
var card = byId[id];
|
|
2273
|
-
if (!card) return;
|
|
2274
|
-
setView("library");
|
|
2275
|
-
card.classList.remove("hide", "open");
|
|
2276
|
-
card.classList.add("hl", "open");
|
|
2277
|
-
requestAnimationFrame(function () {
|
|
2278
|
-
requestAnimationFrame(function () { card.scrollIntoView({ block: "center", behavior: "smooth" }); });
|
|
2279
|
-
});
|
|
2280
|
-
setTimeout(function () { card.classList.remove("hl"); }, 2200);
|
|
2281
|
-
}
|
|
2282
|
-
document.querySelectorAll(".jb-quote").forEach(function (q) {
|
|
2283
|
-
function go() {
|
|
2284
|
-
var jbEl = q.closest(".jb");
|
|
2285
|
-
var id = jbEl && jbEl.getAttribute("data-cite");
|
|
2286
|
-
if (isMobile()) {
|
|
2287
|
-
/* 移动端不跳视图(跳转会打断阅读),就地展开/收起当前 jb */
|
|
2288
|
-
var card = id && byId[id];
|
|
2289
|
-
if (card) { openSheet(card, sentenceOf(q)); return; }
|
|
2290
|
-
}
|
|
2291
|
-
if (id) jumpToLibrary(id);
|
|
2292
|
-
}
|
|
2293
|
-
q.addEventListener("click", go);
|
|
2294
|
-
q.addEventListener("keydown", function (e) {
|
|
2295
|
-
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); go(); }
|
|
2296
|
-
});
|
|
2297
|
-
});
|
|
2298
|
-
document.querySelectorAll("sup.cite").forEach(function (btn) {
|
|
2299
|
-
/* 仅剩未绑定角标(红色数字)走到这里:点击控制台留痕 */
|
|
2300
|
-
btn.addEventListener("click", function () {
|
|
2301
|
-
if (console.error) console.error("[核验] 未绑定角标:", btn.getAttribute("data-cite"));
|
|
2302
|
-
});
|
|
2303
|
-
});
|
|
2304
|
-
|
|
2305
|
-
/* ===== 7. 知识专库:tabs + 搜索 + 热词 ===== */
|
|
2306
|
-
var cond = "";
|
|
2307
|
-
var kw = "";
|
|
2308
|
-
function applyFilter() {
|
|
2309
|
-
var visible = 0;
|
|
2310
|
-
cards.forEach(function (c) {
|
|
2311
|
-
var okCond = !cond;
|
|
2312
|
-
if (cond === "__unused__") okCond = c.getAttribute("data-unused") === "1";
|
|
2313
|
-
else if (cond) okCond = c.getAttribute("data-search") === cond;
|
|
2314
|
-
var okKw = !kw || (c.textContent || "").toLowerCase().indexOf(kw) !== -1;
|
|
2315
|
-
var show = okCond && okKw;
|
|
2316
|
-
c.classList.toggle("hide", !show);
|
|
2317
|
-
if (show) visible++;
|
|
2318
|
-
});
|
|
2319
|
-
var empty = $("#lib-empty");
|
|
2320
|
-
if (empty) empty.classList.toggle("hide", visible !== 0);
|
|
2321
|
-
}
|
|
2322
|
-
$$(".lib-tabs button").forEach(function (b) {
|
|
2323
|
-
b.addEventListener("click", function () {
|
|
2324
|
-
$$(".lib-tabs button").forEach(function (x) { x.classList.remove("on"); });
|
|
2325
|
-
b.classList.add("on");
|
|
2326
|
-
cond = b.getAttribute("data-cond") || "";
|
|
2327
|
-
applyFilter();
|
|
2328
|
-
});
|
|
2329
|
-
});
|
|
2330
|
-
var search = $(".lib-search");
|
|
2331
|
-
if (search) search.addEventListener("input", function () { kw = search.value.trim().toLowerCase(); applyFilter(); });
|
|
2332
|
-
$$(".hot-term").forEach(function (t) {
|
|
2333
|
-
t.addEventListener("click", function () {
|
|
2334
|
-
if (!search) return;
|
|
2335
|
-
search.value = t.textContent.trim();
|
|
2336
|
-
kw = search.value.toLowerCase();
|
|
2337
|
-
applyFilter();
|
|
2338
|
-
if (search.focus) search.focus();
|
|
2339
|
-
});
|
|
2340
|
-
});
|
|
2341
|
-
|
|
2342
|
-
/* ===== 8. 过程回顾条:检索步骤展开 ===== */
|
|
2343
|
-
var pStep = $("#p-step-search");
|
|
2344
|
-
var pDetail = $("#p-detail");
|
|
2345
|
-
if (pStep && pDetail) {
|
|
2346
|
-
function toggleDetail() { pDetail.classList.toggle("show"); }
|
|
2347
|
-
pStep.addEventListener("click", toggleDetail);
|
|
2348
|
-
pStep.addEventListener("keydown", function (e) {
|
|
2349
|
-
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); toggleDetail(); }
|
|
2350
|
-
});
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
/* ===== 9. 章节目录(spy) ===== */
|
|
2354
|
-
var toc = $(".toc");
|
|
2355
|
-
if (toc) {
|
|
2356
|
-
var links = $$("a", toc);
|
|
2357
|
-
var secs = links.map(function (a) { return document.querySelector(a.getAttribute("href")); });
|
|
2358
|
-
links.forEach(function (a) {
|
|
2359
|
-
a.addEventListener("click", function (e) {
|
|
2360
|
-
e.preventDefault();
|
|
2361
|
-
var target = document.querySelector(a.getAttribute("href"));
|
|
2362
|
-
if (!target) return;
|
|
2363
|
-
/* 手动定位而非 scrollIntoView({block:"start"}):后者把标题顶到视口 y=0,
|
|
2364
|
-
会被 sticky 顶栏盖住。偏移量与目录吸顶位置同一基准(顶栏高 + 20px)。 */
|
|
2365
|
-
var bar = document.querySelector(".topbar");
|
|
2366
|
-
var offset = (bar ? bar.offsetHeight : 0) + 20;
|
|
2367
|
-
var y = target.getBoundingClientRect().top + window.scrollY - offset;
|
|
2368
|
-
window.scrollTo({ top: Math.max(0, y), behavior: "smooth" });
|
|
2369
|
-
});
|
|
2370
|
-
});
|
|
2371
|
-
function spy() {
|
|
2372
|
-
var pos = window.scrollY + 130;
|
|
2373
|
-
var current = -1;
|
|
2374
|
-
secs.forEach(function (s, i) { if (s && s.offsetTop <= pos) current = i; });
|
|
2375
|
-
links.forEach(function (a, i) { a.classList.toggle("on", i === current); });
|
|
2376
|
-
}
|
|
2377
|
-
window.addEventListener("scroll", spy, { passive: true });
|
|
2378
|
-
spy();
|
|
2379
|
-
/* 目录纵向定位:此前 CSS 写死 top:120px,目录顶部与页头齐平、离正文很远。
|
|
2380
|
-
改为——初始与正文首节对齐,滚动时吸附在顶栏下方(正文首节上方还有页头、
|
|
2381
|
-
过程回顾与核验报告单,首屏内看不到目录属正常,滚动后自然吸附)。 */
|
|
2382
|
-
var topbar = document.querySelector(".topbar");
|
|
2383
|
-
function placeToc() {
|
|
2384
|
-
var first = secs[0];
|
|
2385
|
-
if (!first) return;
|
|
2386
|
-
var stick = (topbar ? topbar.offsetHeight : 0) + 20;
|
|
2387
|
-
var want = Math.round(first.getBoundingClientRect().top);
|
|
2388
|
-
toc.style.top = Math.max(stick, want) + "px";
|
|
2389
|
-
}
|
|
2390
|
-
window.addEventListener("scroll", placeToc, { passive: true });
|
|
2391
|
-
window.addEventListener("resize", placeToc);
|
|
2392
|
-
placeToc();
|
|
2393
|
-
}
|
|
2394
|
-
})();
|
|
2395
|
-
"""
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
def render_html(payload: Dict[str, Any], title: str, answer_override: str = "", question_override: str = "",
|
|
2399
|
-
generated_at: Optional[datetime] = None, stage: str = "final") -> str:
|
|
2400
|
-
# unwrap 会取出 content 包装;self_check / verification_checks / knowledgeBase 等
|
|
2401
|
-
# 控制字段可能写在原始 JSON 顶层(结构化写法)或 content 内(搜索返回),两边合并查。
|
|
2402
|
-
raw_payload = payload
|
|
2403
|
-
payload = unwrap(payload)
|
|
2404
|
-
for key in ("selfCheck", "self_check", "verificationChecks", "verification_checks",
|
|
2405
|
-
"recalled_materials", "召回材料", "检索文章"):
|
|
2406
|
-
if key in raw_payload and key not in payload:
|
|
2407
|
-
payload[key] = raw_payload[key]
|
|
2408
|
-
answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(payload)
|
|
2409
|
-
sources = align_sources_to_answer(answer, extract_sources(payload))
|
|
2410
|
-
used = citation_ids(answer)
|
|
2411
|
-
# 未引用判定双通道 = JSON 标记(recalled_materials)∪ 正文角标未引用:
|
|
2412
|
-
# 进「未引用」分组,不占角标语义,不参与核验统计。
|
|
2413
|
-
for s in sources:
|
|
2414
|
-
# 一篇文章可能有多个编号(同文异号):正文引用任一编号即视为已引用
|
|
2415
|
-
if not any(i in used for i in collect_material_ids(s)):
|
|
2416
|
-
s["used"] = False
|
|
2417
|
-
# 3.7.2 起知识专库原始召回存档(kb_zone)移除:并行检索下接口返回的
|
|
2418
|
-
# knowledgeBase 链接会错乱不可靠,且未引用召回材料已在专库全量展示,
|
|
2419
|
-
# 对齐公文写作「知识专库链接不进报告」的前提(检索并行化的前置)。
|
|
2420
|
-
generated_at = generated_at or datetime.now()
|
|
2421
|
-
generated = generated_at.strftime("%Y-%m-%d %H:%M")
|
|
2422
|
-
stage_label = STAGE_LABELS.get(stage, "成稿版")
|
|
2423
|
-
|
|
2424
|
-
verification = compute_verification(answer, sources, payload, generated_at)
|
|
2425
|
-
call_log = payload.get("检索记录")
|
|
2426
|
-
if not isinstance(call_log, list):
|
|
2427
|
-
content_layer = payload.get("content") if isinstance(payload.get("content"), dict) else {}
|
|
2428
|
-
call_log = content_layer.get("检索记录") if isinstance(content_layer.get("检索记录"), list) else None
|
|
2429
|
-
process_stats = compute_process_stats(sources, answer, call_log)
|
|
2430
|
-
hot_terms = extract_hot_terms(answer, sources)
|
|
2431
|
-
citation_warning = ""
|
|
2432
|
-
if sources and not used:
|
|
2433
|
-
citation_warning = (
|
|
2434
|
-
'<div class="warn-box"><b>生成检查未通过:正文没有来源角标。</b>'
|
|
2435
|
-
'本报告无法建立"结论-来源文章"核验对应,仅作来源文章清单参考。'
|
|
2436
|
-
'请修正答案文件(提纲版 _outline.md / 成稿版 _answer.txt):在关键事实后标注 [1]、[2] 等角标'
|
|
2437
|
-
'并逐条对应素材清单,然后重新运行 render_trace_html.py 生成核验报告。</div>'
|
|
2438
|
-
)
|
|
2439
|
-
chip_map = build_chip_data(sources)
|
|
2440
|
-
blocks, _ = parse_answer_blocks(answer, {s["id"] for s in sources}, chip_map)
|
|
2441
|
-
# 胶囊内表格数据汇总(span 内静态表格会被解析器拆散,改为页尾 JSON + 展开时 JS 注入)
|
|
2442
|
-
jb_tables: Dict[str, str] = {}
|
|
2443
|
-
for cid, jb in chip_map.items():
|
|
2444
|
-
for key, tbl_html in (jb.pop("_tables", {}) or {}).items():
|
|
2445
|
-
jb_tables[key] = tbl_html
|
|
2446
|
-
doc_title, sections = group_sections(blocks)
|
|
2447
|
-
display_title = doc_title or title
|
|
2448
|
-
report_label = f"{REPORT_NAME}({stage_label})"
|
|
2449
|
-
# 「原问题」行(2026-10-05 反馈:要加上完整的原问题,否则报告无法独立使用):
|
|
2450
|
-
# **只采信 --question 显式传入的用户原话**,不得用报告/演示标题冒充
|
|
2451
|
-
# (标题是正文首行或文件名的来源,不是用户问的话);未传入时整行不渲染。
|
|
2452
|
-
origin_question = (question_override or "").strip()
|
|
2453
|
-
origin_html = ""
|
|
2454
|
-
if origin_question:
|
|
2455
|
-
origin_html = (f'<div class="hero-q"><span class="q-tag">原问题</span>'
|
|
2456
|
-
f'<span class="q-txt">{esc(origin_question)}</span></div>')
|
|
2457
|
-
|
|
2458
|
-
jb_tables_json = dumps_for_script(jb_tables)
|
|
2459
|
-
jb_tables_script = (f'<script type="application/json" id="jb-tables">{jb_tables_json}</script>\n'
|
|
2460
|
-
if jb_tables else "")
|
|
2461
|
-
|
|
2462
|
-
meta_bits = []
|
|
2463
|
-
if process_stats["n_searches"]:
|
|
2464
|
-
meta_bits.append(f"深知检索 {process_stats['n_searches']} 路")
|
|
2465
|
-
if sources:
|
|
2466
|
-
meta_bits.append(f"来源文章 {len(sources)} 篇")
|
|
2467
|
-
if process_stats["n_cite_marks"]:
|
|
2468
|
-
meta_bits.append(f"正文引用 {process_stats['n_cite_marks']} 处")
|
|
2469
|
-
meta_bits.append(f"生成于 {generated}")
|
|
2470
|
-
meta_line = " · ".join(meta_bits)
|
|
2471
|
-
|
|
2472
|
-
return f"""<!doctype html>
|
|
2473
|
-
<html lang="zh-CN">
|
|
2474
|
-
<head>
|
|
2475
|
-
<meta charset="utf-8">
|
|
2476
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2477
|
-
<title>{esc(display_title)} · {esc(report_label)}</title>
|
|
2478
|
-
<style>{PAGE_CSS}</style>
|
|
2479
|
-
</head>
|
|
2480
|
-
<body>
|
|
2481
|
-
|
|
2482
|
-
<header class="topbar">
|
|
2483
|
-
<div class="tb-left">
|
|
2484
|
-
<span class="tb-stamp">{esc(REPORT_NAME)}</span>
|
|
2485
|
-
<span class="tb-title">{esc(display_title)}</span>
|
|
2486
|
-
</div>
|
|
2487
|
-
<div class="tb-right">
|
|
2488
|
-
<div class="view-switch" role="tablist" aria-label="视图切换">
|
|
2489
|
-
<button class="on" data-view="report" type="button">核验报告</button>
|
|
2490
|
-
<button data-view="library" type="button">知识专库</button>
|
|
2491
|
-
</div>
|
|
2492
|
-
<div class="tb-tools">
|
|
2493
|
-
<button id="btn-reading" type="button" aria-pressed="false" title="隐藏核验元素,纯阅读正文">只看正文</button>
|
|
2494
|
-
<button id="btn-copy" type="button" title="复制正文纯文本">复制全文</button>
|
|
2495
|
-
<span class="print-menu">
|
|
2496
|
-
<button id="btn-print" type="button" aria-haspopup="true" title="浏览器打印/另存为 PDF">打印归档 ▾</button>
|
|
2497
|
-
<span class="print-drop" id="print-drop" hidden>
|
|
2498
|
-
<button id="print-body" type="button">只打印正文</button>
|
|
2499
|
-
<button id="print-full" type="button">完整归档(含核验材料)</button>
|
|
2500
|
-
</span>
|
|
2501
|
-
</span>
|
|
2502
|
-
</div>
|
|
2503
|
-
</div>
|
|
2504
|
-
<div class="progress" aria-hidden="true"><i></i></div>
|
|
2505
|
-
</header>
|
|
2506
|
-
|
|
2507
|
-
<div class="hero">
|
|
2508
|
-
<div class="r-badge">{esc(report_label)}</div>
|
|
2509
|
-
<h1>{esc(display_title)}</h1>
|
|
2510
|
-
{origin_html}
|
|
2511
|
-
<div class="meta">{esc(meta_line)} | 素材来源:深知可信搜索</div>
|
|
2512
|
-
<div class="hero-switch">
|
|
2513
|
-
<div class="view-switch" role="tablist" aria-label="视图切换">
|
|
2514
|
-
<button class="on" data-view="report" type="button">核验报告</button>
|
|
2515
|
-
<button data-view="library" type="button">知识专库({len(sources)})</button>
|
|
2516
|
-
</div>
|
|
2517
|
-
</div>
|
|
2518
|
-
</div>
|
|
2519
|
-
|
|
2520
|
-
<div class="app container" data-view="report">
|
|
2521
|
-
{render_process_bar(process_stats, verification)}
|
|
2522
|
-
|
|
2523
|
-
<main class="view" id="view-report" aria-label="核验报告正文">
|
|
2524
|
-
{citation_warning}
|
|
2525
|
-
{render_verify_panel(verification, stage)}
|
|
2526
|
-
<div class="doc-paper">
|
|
2527
|
-
{render_section_cards(sections, sources)}
|
|
2528
|
-
</div>
|
|
2529
|
-
<div class="foot">深知可信PPT · 溯源核验报告 | 内容由 AI 生成,仅供参考</div>
|
|
2530
|
-
</main>
|
|
2531
|
-
|
|
2532
|
-
{render_library_view(sources, hot_terms)}
|
|
2533
|
-
{render_print_appendix(sources)}
|
|
2534
|
-
</div>
|
|
2535
|
-
|
|
2536
|
-
{render_toc(sections)}
|
|
2537
|
-
|
|
2538
|
-
<div class="ev-panel" id="ev-pop" hidden></div>
|
|
2539
|
-
{jb_tables_script}<div class="sheet-mask" aria-hidden="true"></div>
|
|
2540
|
-
<div class="sheet" role="dialog" aria-label="核验材料">
|
|
2541
|
-
<div class="sheet-grab"></div>
|
|
2542
|
-
<div class="sheet-head"><b>依据对照</b><button class="sheet-close" type="button">收起</button></div>
|
|
2543
|
-
<div class="sheet-body"></div>
|
|
2544
|
-
</div>
|
|
2545
|
-
|
|
2546
|
-
<script>{PAGE_JS}</script>
|
|
2547
|
-
</body>
|
|
2548
|
-
</html>"""
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
def align_sources_to_answer(answer: str, sources: List[Dict[str, str]]) -> List[Dict[str, str]]:
|
|
2552
|
-
cited = citation_ids(answer)
|
|
2553
|
-
if not cited or not sources:
|
|
2554
|
-
return sources
|
|
2555
|
-
existing = {source["id"] for source in sources}
|
|
2556
|
-
if existing.intersection(cited):
|
|
2557
|
-
return sources
|
|
2558
|
-
aligned = [dict(source) for source in sources]
|
|
2559
|
-
for idx, citation in enumerate(cited):
|
|
2560
|
-
if idx >= len(aligned):
|
|
2561
|
-
break
|
|
2562
|
-
aligned[idx]["id"] = citation
|
|
2563
|
-
aligned[idx]["all_ids"] = [str(citation)]
|
|
2564
|
-
aligned[idx]["type_key"] = aligned[idx].get("type_key", "material")
|
|
2565
|
-
aligned[idx]["type_label"] = aligned[idx].get("type_label", "材料")
|
|
2566
|
-
aligned[idx]["type_css"] = aligned[idx].get("type_css", "mat")
|
|
2567
|
-
return aligned
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
def main() -> None:
|
|
2571
|
-
parser = argparse.ArgumentParser(description="生成深知可信PPT 溯源核验报告 HTML(提纲版/成稿版)")
|
|
2572
|
-
parser.add_argument("input_json", help="trusted_search.py 或合并后的检索 JSON")
|
|
2573
|
-
parser.add_argument("--output", help="输出 HTML 路径;不传时根据问题自动生成短文件名到 official-docs/output/")
|
|
2574
|
-
parser.add_argument("--title", default="溯源核验报告", help="演示标题;正文首行有标题时以正文为准")
|
|
2575
|
-
parser.add_argument("--answer-file", help="答案文件(提纲版 <项目短名>_outline.md / 成稿版 <项目短名>_answer.txt),关键事实后标 [N] 角标。")
|
|
2576
|
-
parser.add_argument("--clean-md-output", help="输出干净 Markdown 路径;内容来自同一份答案,并移除 [1]、【1】等溯源角标。")
|
|
2577
|
-
parser.add_argument("--question", default="", help="用户需求,用于自动生成文件名。")
|
|
2578
|
-
parser.add_argument("--stage", choices=["outline", "final"], default="final",
|
|
2579
|
-
help="报告版本:outline 提纲版(确认门前事前核验)/ final 成稿版(交付时事后溯源),默认 final。")
|
|
2580
|
-
parser.add_argument("--skip-link-check", action="store_true",
|
|
2581
|
-
help="(已废弃,兼容保留)链接活性检测已于 2026-10-08 整体移除,本参数不再有任何作用")
|
|
2582
|
-
parser.add_argument("--disable-snapshot", action="store_true",
|
|
2583
|
-
help="关闭快照兜底展示(默认启用:原文失效时以存档快照回看)")
|
|
2584
|
-
args = parser.parse_args()
|
|
2585
|
-
if args.disable_snapshot:
|
|
2586
|
-
global SNAPSHOT_ENABLED
|
|
2587
|
-
SNAPSHOT_ENABLED = False
|
|
2588
|
-
|
|
2589
|
-
payload = load_json(_safe_input_path(args.input_json, {".json"}))
|
|
2590
|
-
answer_override = ""
|
|
2591
|
-
if args.answer_file:
|
|
2592
|
-
answer_override = _safe_input_path(args.answer_file, {".txt", ".md"}).read_text(encoding="utf-8")
|
|
2593
|
-
question = args.question.strip() or extract_question(unwrap(payload))
|
|
2594
|
-
unwrapped = unwrap(payload)
|
|
2595
|
-
|
|
2596
|
-
# 存档快照预处理(纯本地路径校验,不发网络请求);接口返回的链接原样进报告
|
|
2597
|
-
raw_articles = collect_raw_articles(unwrapped)
|
|
2598
|
-
if SNAPSHOT_ENABLED and raw_articles:
|
|
2599
|
-
fixed, dropped = apply_snapshots(raw_articles)
|
|
2600
|
-
total_snap = sum(1 for a in raw_articles if (a.get("快照链接") or "").strip())
|
|
2601
|
-
if total_snap or fixed or dropped:
|
|
2602
|
-
print(f"快照校验:{total_snap} 条路径合法放行(补全 /A/ {fixed} 条)/ 弃用 {dropped} 条非法路径(不做网络检测)")
|
|
2603
|
-
|
|
2604
|
-
# 生成前硬校验:有素材而正文无角标时拒绝生成,杜绝产出无核验对应的报告
|
|
2605
|
-
pre_answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(unwrapped)
|
|
2606
|
-
pre_sources = extract_sources(unwrapped)
|
|
2607
|
-
if pre_sources and not citation_ids(pre_answer):
|
|
2608
|
-
print("生成检查未通过:答案正文没有任何 [N] 来源角标,无法建立\"结论-素材\"核验对应。", file=sys.stderr)
|
|
2609
|
-
print(f"请修正答案文件({'提纲版 _outline.md:页面规划表事实要点' if args.stage == 'outline' else '成稿版 _answer.txt:页面级结论文本'}"
|
|
2610
|
-
"的关键事实后标注 [1]、[2] 等角标并逐条对应素材清单),然后重新运行本脚本。", file=sys.stderr)
|
|
2611
|
-
raise SystemExit(2)
|
|
2612
|
-
# 生成前硬校验(反向):正文有角标却识别不到任何素材,多为合并 JSON 结构不符
|
|
2613
|
-
# (渲染器识别 检索文章 的路径:顶层 或 content.data 嵌套),当场报错而非产出 0 卡报告
|
|
2614
|
-
if citation_ids(pre_answer) and not pre_sources:
|
|
2615
|
-
print("生成检查未通过:输入 JSON 未识别到任何素材,但正文包含 [N] 角标。", file=sys.stderr)
|
|
2616
|
-
print("请检查合并 JSON 结构:素材数组须为顶层 {\"检索文章\": [...]} 或原始接口的 content.data.检索文章 形态;"
|
|
2617
|
-
"self_check/verification_checks 放顶层。修正后重新运行本脚本。", file=sys.stderr)
|
|
2618
|
-
raise SystemExit(2)
|
|
2619
|
-
|
|
2620
|
-
generated_at = datetime.now()
|
|
2621
|
-
if args.output:
|
|
2622
|
-
output = _safe_output_path(args.output, {".html", ".htm"}, ".html")
|
|
2623
|
-
else:
|
|
2624
|
-
output = _safe_output_path(safe_output_filename(question, generated_at), {".html", ".htm"}, ".html")
|
|
2625
|
-
output = _next_version_path(output)
|
|
2626
|
-
output.parent.mkdir(parents=True, exist_ok=True)
|
|
2627
|
-
output.write_text(render_html(payload, args.title, answer_override=answer_override,
|
|
2628
|
-
question_override=args.question, generated_at=generated_at, stage=args.stage), encoding="utf-8")
|
|
2629
|
-
print(f"已生成:{output}")
|
|
2630
|
-
if args.clean_md_output:
|
|
2631
|
-
clean_output = _safe_output_path(args.clean_md_output, {".md"}, ".md")
|
|
2632
|
-
else:
|
|
2633
|
-
clean_output = _safe_output_path(output.with_suffix(".clean.md").name, {".md"}, ".md")
|
|
2634
|
-
clean_output = _next_version_path(clean_output)
|
|
2635
|
-
clean_output.parent.mkdir(parents=True, exist_ok=True)
|
|
2636
|
-
clean_answer = strip_citation_markers(answer_override or extract_answer(unwrap(payload)))
|
|
2637
|
-
clean_output.write_text(clean_answer, encoding="utf-8")
|
|
2638
|
-
print(f"已生成干净 Markdown:{clean_output}")
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
if __name__ == "__main__":
|
|
2642
|
-
main()
|