meeting-importer.js
2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* MeetingImporter — 将会议纪要文本导入知识图谱
*
* 创建 Event:meeting 节点,关联参与者(PARTICIPATED 边)
*/
const { getGraphStore } = require('../../db/GraphStore');
class MeetingImporter {
constructor() {
this.store = getGraphStore();
}
/**
* 导入会议纪要
*
* @param {object} params
* @param {string} params.title - 会议标题
* @param {string} params.date - 会议日期 (YYYY-MM-DD)
* @param {string} params.summary - 会议摘要(必填)
* @param {string} [params.rawText] - 原始会议纪要全文
* @param {string[]} [params.participants] - 参与者姓名或节点 id 列表
* @returns {{eventId: string, linkedParticipants: string[], skippedParticipants: string[]}}
*/
importMeetingNotes(params) {
const {
title,
date,
summary,
rawText,
participants = [],
} = params;
if (!summary) {
throw new Error('importMeetingNotes: summary 为必填字段');
}
const g = this.store;
// 创建 Event:meeting 节点
const eventNode = g.createNode('Event', {
type: 'meeting',
title: title || '未命名会议',
summary,
date: date || new Date().toISOString().slice(0, 10),
rawText: rawText || null,
});
const linkedParticipants = [];
const skippedParticipants = [];
// 关联参与者
for (const p of participants) {
// 先精确查 id,再按名称模糊查
let person = g.getNode(p);
if (!person || person._type !== 'Person') {
const results = g.findByName(p, 'Person');
person = results[0] || null;
}
if (person) {
g.createEdge(person.id, eventNode.id, 'PARTICIPATED');
linkedParticipants.push(person.name || person.id);
} else {
skippedParticipants.push(p);
}
}
return {
eventId: eventNode.id,
linkedParticipants,
skippedParticipants,
};
}
}
module.exports = { MeetingImporter };