ziweidoushu / src /core-engine /knowledge-source.ts
luoly2026
Deploy: Fresh initial commit for Hugging Face
631a7d3
Raw
History Blame Contribute Delete
1.3 kB
import { TIANJI_DICTIONARY } from './tianji-dictionary';
import { BONUS_RULES, PENALTY_RULES, CONFLICT_RESOLUTION, ScoreRule } from './scoring-tables';
export interface AdviceItem {
rule: string;
content: string;
}
export interface ConflictRuleDef {
priority: number;
name: string;
condition: (hasLu: boolean, hasJi: boolean, hasGoodPattern?: boolean, hasBadInteraction?: boolean) => boolean;
action: string;
}
export interface IKnowledgeSource {
getPatternAdvices(): Record<string, AdviceItem>;
getSihuaAdvices(): Record<string, AdviceItem>;
getStarsAdvices(): Record<string, AdviceItem>;
getGeneralAdvices(): Record<string, AdviceItem>;
getBonusRules(): Record<string, ScoreRule>;
getPenaltyRules(): Record<string, ScoreRule>;
getConflictRules(): ConflictRuleDef[];
}
export class LocalKnowledgeSource implements IKnowledgeSource {
getPatternAdvices() { return TIANJI_DICTIONARY.patterns; }
getSihuaAdvices() { return TIANJI_DICTIONARY.sihua; }
getStarsAdvices() { return TIANJI_DICTIONARY.stars; }
getGeneralAdvices() { return TIANJI_DICTIONARY.general; }
getBonusRules() { return BONUS_RULES; }
getPenaltyRules() { return PENALTY_RULES; }
getConflictRules() { return CONFLICT_RESOLUTION; }
}
export const knowledgeSource = new LocalKnowledgeSource();