chore(hmos): 导入生产环境鸿蒙工程
- 以 D:\SmartSenior 生产工程为源,纳入 AppScope、entry、cjagent、hvigor 及根配置 - 移除 build-profile.json5 的 signingConfigs(p12/p7b/cer 路径与加密口令)及 products.signingConfig 引用 - 不纳入本地与开发产物:local.properties、.idea、.hvigor、.codegenie、demo、backup_a2a_native、SESSION_LOG.md、build_err.txt、build/、oh_modules - .gitignore 追加 .codegenie 与密钥文件通配(*.p12/*.p7b/*.cer/*.jks/*.keystore/*.pem)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// 仓颉意图引擎桥:entry(ArkTS) → cjagent(HAR, 仓颉 so)
|
||||
// 仓颉侧只做文本→意图 JSON 的解析,后端调用仍在 ArkTS 侧执行
|
||||
import { parseIntent, splitIntents, inferSlot } from 'libohos_app_cangjie_cjagent.so'
|
||||
|
||||
export interface IntentResult {
|
||||
action: string;
|
||||
slot: string;
|
||||
date: string;
|
||||
jump: string;
|
||||
}
|
||||
|
||||
export function parseIntentCj(text: string): IntentResult | null {
|
||||
try {
|
||||
const json: string = parseIntent(text);
|
||||
return JSON.parse(json) as IntentResult;
|
||||
} catch (err) {
|
||||
console.error('[IntentEngine] cangjie parse failed:', (err as Error).message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export interface SegmentResult {
|
||||
segments: string[];
|
||||
}
|
||||
|
||||
// 多意图拆分:仓颉按连接词/标点切句;单意图时返回 null(走原路径零开销)
|
||||
export function splitSegmentsCj(text: string): string[] | null {
|
||||
try {
|
||||
const json: string = splitIntents(text);
|
||||
const parsed = JSON.parse(json) as SegmentResult;
|
||||
if (parsed.segments.length > 1) {
|
||||
return parsed.segments;
|
||||
}
|
||||
return null;
|
||||
} catch (err) {
|
||||
console.error('[IntentEngine] cangjie split failed:', (err as Error).message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 餐次推断(仓颉决策链):按小时返回 breakfast/lunch/dinner,失败时 ArkTS 本地兜底
|
||||
export function inferSlotCj(hour: number): string {
|
||||
try {
|
||||
const json: string = inferSlot(hour);
|
||||
const parsed = JSON.parse(json) as { slot: string };
|
||||
return parsed.slot;
|
||||
} catch (err) {
|
||||
console.error('[IntentEngine] cangjie inferSlot failed:', (err as Error).message);
|
||||
return hour < 9 ? 'breakfast' : (hour < 15 ? 'lunch' : 'dinner');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user