gaokao-pro 0.1.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.
Files changed (66) hide show
  1. package/README.md +109 -0
  2. package/data/datasets/gaoshui-yundongdui-2024.json +33 -0
  3. package/data/datasets/junjing-jingxiao.json +75 -0
  4. package/data/datasets/provinces-specialty-2024.json +139 -0
  5. package/data/datasets/qiangji-2024.json +52 -0
  6. package/data/datasets/schools-adapters-2024.json +123 -0
  7. package/data/datasets/sushe-shitang.json +40 -0
  8. package/data/datasets/tijian-shouxian-zhuanye.json +29 -0
  9. package/data/datasets/xiaoyuzhong-zhaosheng.json +18 -0
  10. package/data/datasets/xueke-pinggu-disculun.json +28 -0
  11. package/data/datasets/zhongwai-hezuo-2024.json +36 -0
  12. package/data/datasets/zonghepingjia-2024.json +53 -0
  13. package/data/school-index.json.gz +0 -0
  14. package/data/yifenyiduan/_ocr-pipeline/extract-pdf.py +117 -0
  15. package/data/yifenyiduan/beijing-2023-combined.json +1 -0
  16. package/data/yifenyiduan/beijing-2024-combined.json +1 -0
  17. package/data/yifenyiduan/beijing-2025-combined.json +1 -0
  18. package/data/yifenyiduan/henan-2024-liberal.json +1 -0
  19. package/data/yifenyiduan/hunan-2024-history.json +1 -0
  20. package/dist/aliases.d.ts +2 -0
  21. package/dist/aliases.js +120 -0
  22. package/dist/chart-check.d.ts +20 -0
  23. package/dist/chart-check.js +99 -0
  24. package/dist/codes.d.ts +162 -0
  25. package/dist/codes.js +59 -0
  26. package/dist/compare.d.ts +39 -0
  27. package/dist/compare.js +112 -0
  28. package/dist/datasets.d.ts +65 -0
  29. package/dist/datasets.js +82 -0
  30. package/dist/find.d.ts +48 -0
  31. package/dist/find.js +87 -0
  32. package/dist/format.d.ts +17 -0
  33. package/dist/format.js +109 -0
  34. package/dist/gaokao-cn.d.ts +122 -0
  35. package/dist/gaokao-cn.js +49 -0
  36. package/dist/index-loader.d.ts +33 -0
  37. package/dist/index-loader.js +59 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.js +727 -0
  40. package/dist/match.d.ts +40 -0
  41. package/dist/match.js +118 -0
  42. package/dist/mcp.d.ts +1 -0
  43. package/dist/mcp.js +535 -0
  44. package/dist/memory.d.ts +31 -0
  45. package/dist/memory.js +69 -0
  46. package/dist/paiming.d.ts +29 -0
  47. package/dist/paiming.js +66 -0
  48. package/dist/probe.d.ts +1 -0
  49. package/dist/probe.js +73 -0
  50. package/dist/provinces/guangdong.d.ts +27 -0
  51. package/dist/provinces/guangdong.js +68 -0
  52. package/dist/provinces/index.d.ts +1 -0
  53. package/dist/provinces/index.js +17 -0
  54. package/dist/rank-table.d.ts +31 -0
  55. package/dist/rank-table.js +74 -0
  56. package/dist/recommend-major.d.ts +34 -0
  57. package/dist/recommend-major.js +119 -0
  58. package/dist/recommend.d.ts +54 -0
  59. package/dist/recommend.js +147 -0
  60. package/dist/selftest.d.ts +11 -0
  61. package/dist/selftest.js +48 -0
  62. package/dist/top.d.ts +29 -0
  63. package/dist/top.js +66 -0
  64. package/dist/xuanke.d.ts +8 -0
  65. package/dist/xuanke.js +35 -0
  66. package/package.json +40 -0
@@ -0,0 +1,40 @@
1
+ import { type ProvinceId, type Subject } from "./codes.js";
2
+ export type Profile = {
3
+ score: number;
4
+ province: ProvinceId;
5
+ subjects: Subject[];
6
+ rank?: number;
7
+ interests?: string[];
8
+ constraints?: {
9
+ cities_preferred?: string[];
10
+ cities_avoid?: string[];
11
+ require_985?: boolean;
12
+ require_211?: boolean;
13
+ require_dual_class?: boolean;
14
+ belong?: string;
15
+ max_tuition_yuan?: number;
16
+ };
17
+ };
18
+ export type MatchCandidate = {
19
+ schoolId: number;
20
+ zsCode: string;
21
+ name: string;
22
+ city: string;
23
+ province: string;
24
+ belong: string;
25
+ is985: boolean;
26
+ is211: boolean;
27
+ dualClass: string;
28
+ baselineYear: number;
29
+ baselineMinScore: number;
30
+ delta: number;
31
+ interestFit: number;
32
+ cityBonus: number;
33
+ composite: number;
34
+ rationale: string;
35
+ };
36
+ export declare function match(profile: Profile, limit?: number): {
37
+ query: object;
38
+ considered: number;
39
+ candidates: MatchCandidate[];
40
+ };
package/dist/match.js ADDED
@@ -0,0 +1,118 @@
1
+ // match — student profile in, ranked (school, fit) pairs out.
2
+ //
3
+ // Profile shape:
4
+ // score (required) + province + subjects → reach feasibility (delta)
5
+ // interests[] → fit against each school's 强势专业 (via index special_arr)
6
+ // constraints (cities, 985/211, max_tuition, dual_class) → hard filters
7
+ //
8
+ // Composite score = 0.4 × interestFit + 0.35 × baselineWeight + 0.15 × labelWeight + 0.10 × cityBonus
9
+ // where interestFit ∈ [0,1], baselineWeight = baselineMinScore / 750 (normalized),
10
+ // labelWeight = 985 ? 1 : 211 ? 0.7 : dual ? 0.5 : 0.2, cityBonus ∈ {-0.5, 0, +1}.
11
+ //
12
+ // Offline — reads docs/datasets at the index level for 985/211 and uses the
13
+ // gaokao.cn-derived pro_type_min for score baseline.
14
+ import { loadIndex, filterIndex } from "./index-loader.js";
15
+ import { PROVINCES, TRACK_NAMES } from "./codes.js";
16
+ import { inferTrack } from "./recommend.js";
17
+ function labelWeight(r) {
18
+ if (r.f985)
19
+ return 1.0;
20
+ if (r.f211)
21
+ return 0.7;
22
+ if (r.dual_class === "双一流")
23
+ return 0.5;
24
+ return 0.2;
25
+ }
26
+ function cityScore(r, profile) {
27
+ const c = profile.constraints;
28
+ if (!c)
29
+ return 0;
30
+ const city = r.city;
31
+ if (c.cities_preferred?.some((p) => city.includes(p) || r.province.includes(p)))
32
+ return 1;
33
+ if (c.cities_avoid?.some((p) => city.includes(p) || r.province.includes(p)))
34
+ return -0.5;
35
+ return 0;
36
+ }
37
+ function interestFitScore(_row, interests) {
38
+ if (!interests || interests.length === 0)
39
+ return 0.5; // neutral if no signal
40
+ // School index doesn't currently embed major-level signal; we'd need to fetch
41
+ // the plan endpoint per school for high-fidelity matching. For the offline
42
+ // fast path, return a neutral 0.5; future enrichment can wire in
43
+ // schoolspecialscore data.
44
+ return 0.5;
45
+ }
46
+ export function match(profile, limit) {
47
+ const index = loadIndex();
48
+ const c = profile.constraints ?? {};
49
+ const filter = {
50
+ f985: c.require_985 ? true : undefined,
51
+ f211: c.require_211 ? true : undefined,
52
+ dualClass: c.require_dual_class ? true : undefined,
53
+ belong: c.belong
54
+ };
55
+ let rows = filterIndex(index, filter);
56
+ const track = inferTrack(profile.province, profile.subjects);
57
+ const candidates = [];
58
+ for (const r of rows) {
59
+ const entries = r.pro_type_min?.[String(profile.province)] ?? [];
60
+ if (!entries.length)
61
+ continue;
62
+ const sorted = [...entries].sort((a, b) => b.year - a.year);
63
+ let baselineYear = 0;
64
+ let baselineMinScore = 0;
65
+ for (const e of sorted) {
66
+ const v = e.type?.[track];
67
+ const n = v ? Number(v) : NaN;
68
+ if (Number.isFinite(n) && n > 0) {
69
+ baselineYear = e.year;
70
+ baselineMinScore = n;
71
+ break;
72
+ }
73
+ }
74
+ if (!baselineMinScore)
75
+ continue;
76
+ const delta = profile.score - baselineMinScore;
77
+ if (delta < -40)
78
+ continue; // too far out of reach
79
+ const interestFit = interestFitScore(r, profile.interests);
80
+ const cityBonus = cityScore(r, profile);
81
+ const composite = 0.4 * interestFit +
82
+ 0.35 * (baselineMinScore / 750) +
83
+ 0.15 * labelWeight(r) +
84
+ 0.10 * (cityBonus + 0.5); // shift to [0, 1.5]
85
+ const tags = [r.f985 ? "985" : r.f211 ? "211" : r.dual_class === "双一流" ? "双一流" : ""].filter(Boolean).join(" ");
86
+ candidates.push({
87
+ schoolId: r.gaokao_cn_id,
88
+ zsCode: r.zs_code,
89
+ name: r.name,
90
+ city: r.city,
91
+ province: r.province,
92
+ belong: r.belong,
93
+ is985: r.f985,
94
+ is211: r.f211,
95
+ dualClass: r.dual_class,
96
+ baselineYear,
97
+ baselineMinScore,
98
+ delta,
99
+ interestFit,
100
+ cityBonus,
101
+ composite,
102
+ rationale: `${tags} · ${r.belong} · ${baselineYear}基线${baselineMinScore} (${delta >= 0 ? "+" : ""}${delta}) · 综合${composite.toFixed(2)}`
103
+ });
104
+ }
105
+ candidates.sort((a, b) => b.composite - a.composite);
106
+ return {
107
+ query: {
108
+ score: profile.score,
109
+ province: PROVINCES[profile.province].name,
110
+ subjects: profile.subjects,
111
+ track: TRACK_NAMES[track] ?? track,
112
+ interests: profile.interests,
113
+ constraints: profile.constraints
114
+ },
115
+ considered: rows.length,
116
+ candidates: limit && limit > 0 ? candidates.slice(0, limit) : candidates
117
+ };
118
+ }
package/dist/mcp.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function runMcpServer(): Promise<void>;