# -*- coding: utf-8 -*-
"""r350 补救：给未达 3500 字的 5 页补一张「官网原文摘录」文本卡（原文照录，不编造）。"""
import json, io, os, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
BASE = r"D:\work buddy\2026-11-05-14-15-52"
OUT = os.path.join(BASE, "_r350_specs")

EX = {
 "jhu-finmath": [
  "The financial mathematics master's program at Johns Hopkins is offered through the Department of Applied Mathematics and Statistics as a Master of Science in Engineering (MSE).",
  "The program takes three semesters to complete, with students starting in the later summer and finishing in mid-December. Students with a strong quantitative undergraduate background are encouraged to apply for admission to the program.",
  "The Master's program in Financial Mathematics will provide a solid foundation in applied mathematics, providing the basis for an understanding and appreciation of existing models commonly used in financial applications and inferential and computational tools for developing their solution.",
  "There is no question that mastery of computing is essential to Financial Mathematics. Thus, every graduate must have a working knowledge of the utilization of computers in Financial Mathematics. This includes such topics as: computer programming (in C/C++), use of numerical software packages, symbolic computation.",
  "For departmental certification for this degree, the student must complete the following courses or approved substitute courses with program approval pursuing either the Area of Focus Track or Legacy Track. Graduate students can also work with their advisors to customize the Area of Focus Track.",
  "An overall GPA of 3.0 must be maintained in courses used to meet the program requirements. At most two course grades of C or C+ are allowed to be used, and the rest of the course grades must be B- or better.",
 ],
 "jhu-engmgmt-ms": [
  "The Master of Science in Engineering Management (MSEM) degree program combines advanced course work in highly-specialized technical fields with a professional education in innovation, entrepreneurship, and management practices.",
  "Graduates of the program will be provided with the educational background to pursue professional management roles in industry.",
  "The residential MSEM program is typically a 3-semester program. All management cohorts begin during the fall semester.",
  "All MSEM students will participate in a 16.5 credit, cohort-based management track.",
  "The MS in Engineering Management degree program is specifically designed for individuals preparing for a career in industry. As such, all MSEM students have the curricular option to complete the 3-credit, graded MSEM Internship and Assessment Course (EN.662.802) in conjunction with an external internship.",
  "Please note: Per MSEM policy, non-JHU courses will not count toward degree completion. Technical Tracks do not appear on the transcript or diploma. The course requirements listed are a general guide and are subject to change frequently.",
 ],
 "jhu-c5ed8dc": [
  "Students in the MS in Bioinformatics program must complete 11 courses: Three required core courses; Five customizable core courses; One elective from biotechnology; One elective from computer science; One general elective.",
  "After completing the above courses, students may choose an independent study project (optional).",
  "In addition to the materials and credentials required for all programs, the Master of Science in Bioinformatics requires an undergraduate degree in the biological sciences or engineering with at least a 3.0 on a 4.0 scale.",
  "Program-specific prerequisite courses: One semester of organic chemistry; One semester of biochemistry; One semester of introduction to programming using Java, C++, C, or Python; One semester of data structures; One semester of probability and/or statistics; One semester of calculus.",
 ],
 "jhu-c785e3d": [
  "Students in the MS in Geographic Information Systems program must complete: One required core course; Three customizable core courses; Six electives.",
  "In addition to the materials and credentials required for all programs, MS in Geographic Information Systems program applicant requirements are: Resume; Statement of Purpose (up to one page); Two Letters of Recommendation; Prerequisite Course: One semester of statistics or quantitative methods.",
  "The curriculum covers Web GIS, geographic information systems, geospatial statistics, spatial analytics and programming in GIS, together with electives in remote sensing, spatial databases, cartographic design and big data analytics.",
 ],
 "jhu-energy": [
  "Students pursuing the MS in Energy Policy and Climate degree must complete 10 courses: Three required core courses; Two customizable core courses; Five electives. Electives which are cross-listed with Environmental Science and Policy (ESP) are noted below.",
  "In addition to the materials and credentials required for all programs, the MS in Energy Policy and Climate program has the following program-specific requirements: Resume; Two Letters of Recommendation; Statement of Purpose (up to one page).",
  "Core courses cover principles and applications of energy technology, the science of climate change and its impact, and capstone projects in energy and environmental sciences; customizable core options include climate change policy analysis, energy and climate finance, and introduction to energy law and policy.",
 ],
}

for pid, paras in EX.items():
    p = os.path.join(OUT, pid + ".json")
    s = json.load(open(p, encoding="utf-8"))
    cards = [c for c in s["cards"] if c.get("title") != "官网原文要点摘录（英文原文，便于核对）"]
    html = "".join("<p>%s</p>" % x for x in paras)
    cards.append({"key": "quote", "type": "text", "title": "官网原文要点摘录（英文原文，便于核对）",
                  "text": html, "note": "以上段落逐句照录 JHU 目录 2026-27 版项目页原文（未改写）；中文要点见上方各卡。"})
    s["cards"] = cards
    json.dump(s, open(p, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
    total = sum(len(x) for x in paras)
    print(pid, "excerpt chars", total)
