|
|
@@ -88,7 +88,8 @@ function convertV8ToGraphV2(runContext, searchResults) {
|
|
|
iteration: roundNum,
|
|
|
is_selected: true,
|
|
|
segment_type: seg.type,
|
|
|
- domain_index: seg.domain_index
|
|
|
+ domain_index: seg.domain_index,
|
|
|
+ domain_type: seg.type // 新增:让可视化显示类型而不是D0
|
|
|
};
|
|
|
|
|
|
edges.push({
|
|
|
@@ -238,13 +239,13 @@ function convertV8ToGraphV2(runContext, searchResults) {
|
|
|
// 为每个 Q 创建节点
|
|
|
Object.keys(round.sug_details).forEach((qText, qIndex) => {
|
|
|
// 从q_list_1中查找对应的q获取分数和理由
|
|
|
- // Round 0: 从q_list_1查找; Round 1+: 从input_q_list查找
|
|
|
+ // Round 0: 从q_list_1查找; Round 1+: 从input_queries查找
|
|
|
let qData = {};
|
|
|
if (roundNum === 0) {
|
|
|
qData = round.q_list_1?.find(q => q.text === qText) || {};
|
|
|
} else {
|
|
|
- // 从当前轮的input_q_list中查找
|
|
|
- qData = round.input_q_list?.find(q => q.text === qText) || {};
|
|
|
+ // 从当前轮的input_queries中查找
|
|
|
+ qData = round.input_queries?.find(q => q.text === qText) || {};
|
|
|
}
|
|
|
const qId = `q_${qText}_r${roundNum}_${qIndex}`;
|
|
|
nodes[qId] = {
|
|
|
@@ -256,7 +257,9 @@ function convertV8ToGraphV2(runContext, searchResults) {
|
|
|
strategy: 'Query',
|
|
|
iteration: roundNum,
|
|
|
is_selected: true,
|
|
|
- type_label: qData.type_label || qData.typeLabel || ''
|
|
|
+ type_label: qData.type_label || qData.typeLabel || '',
|
|
|
+ domain_index: qData.domain_index,
|
|
|
+ domain_type: qData.domain_type || ''
|
|
|
};
|
|
|
|
|
|
edges.push({
|
|
|
@@ -305,7 +308,64 @@ function convertV8ToGraphV2(runContext, searchResults) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- // 步骤2: 筛选并执行搜索
|
|
|
+ // 步骤2: 域内组词(Round 1+)
|
|
|
+ // 兼容旧字段名 domain_combinations_top10
|
|
|
+ const domainCombinations = round.domain_combinations || round.domain_combinations_top10 || [];
|
|
|
+ if (domainCombinations.length > 0) {
|
|
|
+ const combStepId = `step_comb_r${roundNum}`;
|
|
|
+ nodes[combStepId] = {
|
|
|
+ type: 'step',
|
|
|
+ query: `步骤2: 跨${roundNum}个域组合 (${domainCombinations.length}个组合)`,
|
|
|
+ level: roundNum * 10 + 1,
|
|
|
+ relevance_score: 0,
|
|
|
+ strategy: '域内组词',
|
|
|
+ iteration: roundNum,
|
|
|
+ is_selected: true
|
|
|
+ };
|
|
|
+
|
|
|
+ edges.push({
|
|
|
+ from: roundId,
|
|
|
+ to: combStepId,
|
|
|
+ edge_type: 'round_to_step',
|
|
|
+ strategy: '域内组词'
|
|
|
+ });
|
|
|
+
|
|
|
+ iterations[roundNum * 10].push(combStepId);
|
|
|
+
|
|
|
+ // 为每个域内组合创建节点
|
|
|
+ domainCombinations.forEach((comb, combIndex) => {
|
|
|
+ const combId = `comb_${comb.text}_r${roundNum}_${combIndex}`;
|
|
|
+ const domainsStr = comb.domains ? comb.domains.map(d => `D${d}`).join(',') : '';
|
|
|
+
|
|
|
+ nodes[combId] = {
|
|
|
+ type: 'domain_combination',
|
|
|
+ query: `${comb.text}`, // 移除 type_label,稍后在UI中单独显示
|
|
|
+ level: roundNum * 10 + 2,
|
|
|
+ relevance_score: comb.score || 0,
|
|
|
+ evaluationReason: comb.reason || '',
|
|
|
+ strategy: '域内组合',
|
|
|
+ iteration: roundNum,
|
|
|
+ is_selected: true,
|
|
|
+ type_label: comb.type_label || '',
|
|
|
+ source_words: comb.source_words || [],
|
|
|
+ from_segments: comb.from_segments || [],
|
|
|
+ domains: comb.domains || [],
|
|
|
+ domains_str: domainsStr
|
|
|
+ };
|
|
|
+
|
|
|
+ edges.push({
|
|
|
+ from: combStepId,
|
|
|
+ to: combId,
|
|
|
+ edge_type: 'step_to_comb',
|
|
|
+ strategy: '域内组合'
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!iterations[roundNum * 10 + 2]) iterations[roundNum * 10 + 2] = [];
|
|
|
+ iterations[roundNum * 10 + 2].push(combId);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 步骤3: 筛选并执行搜索
|
|
|
const searchStepId = `step_search_r${roundNum}`;
|
|
|
const searchCountText = round.search_count > 0
|
|
|
? `筛选${round.high_score_sug_count}个高分词,搜索${round.search_count}次,${round.total_posts}个帖子`
|
|
|
@@ -313,7 +373,7 @@ function convertV8ToGraphV2(runContext, searchResults) {
|
|
|
|
|
|
nodes[searchStepId] = {
|
|
|
type: 'step',
|
|
|
- query: `步骤2: 筛选并执行搜索 (${searchCountText})`,
|
|
|
+ query: `步骤3: 筛选并执行搜索 (${searchCountText})`,
|
|
|
level: roundNum * 10 + 1,
|
|
|
relevance_score: 0,
|
|
|
strategy: '筛选并执行搜索',
|
|
|
@@ -545,7 +605,7 @@ function convertV8ToGraphV2(runContext, searchResults) {
|
|
|
if (roundNum === 0) {
|
|
|
qData = round.q_list_1?.find(q => q.text === qText) || {};
|
|
|
} else {
|
|
|
- qData = round.input_q_list?.find(q => q.text === qText) || {};
|
|
|
+ qData = round.input_queries?.find(q => q.text === qText) || {};
|
|
|
}
|
|
|
parentQScore = qData.score || 0;
|
|
|
break;
|
|
|
@@ -581,153 +641,56 @@ function convertV8ToGraphV2(runContext, searchResults) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- // 步骤5: 构建下一轮
|
|
|
- const nextRoundStepId = `step_next_round_r${roundNum}`;
|
|
|
- const nextQCount = round.output_q_list?.length || 0;
|
|
|
- const nextSeedCount = round.seed_list_next_size || 0;
|
|
|
-
|
|
|
- nodes[nextRoundStepId] = {
|
|
|
- type: 'step',
|
|
|
- query: `步骤5: 构建下一轮 (${nextQCount}个查询, ${nextSeedCount}个种子)`,
|
|
|
- level: roundNum * 10 + 1,
|
|
|
- relevance_score: 0,
|
|
|
- strategy: '构建下一轮',
|
|
|
- iteration: roundNum,
|
|
|
- is_selected: true
|
|
|
- };
|
|
|
+ // 步骤4: 构建下一轮(Round 1+)
|
|
|
+ const highScoreCombinations = round.high_score_combinations || [];
|
|
|
+ const highGainSugs = round.high_gain_sugs || [];
|
|
|
+ const nextRoundItems = [...highScoreCombinations, ...highGainSugs];
|
|
|
|
|
|
- edges.push({
|
|
|
- from: roundId,
|
|
|
- to: nextRoundStepId,
|
|
|
- edge_type: 'round_to_step',
|
|
|
- strategy: '构建下一轮'
|
|
|
- });
|
|
|
-
|
|
|
- iterations[roundNum * 10].push(nextRoundStepId);
|
|
|
-
|
|
|
- // 5.1: 构建下轮查询
|
|
|
- if (round.output_q_list && round.output_q_list.length > 0) {
|
|
|
- const nextQStepId = `step_next_q_r${roundNum}`;
|
|
|
- nodes[nextQStepId] = {
|
|
|
- type: 'step',
|
|
|
- query: `构建下轮查询 (${nextQCount}个)`,
|
|
|
- level: roundNum * 10 + 2,
|
|
|
- relevance_score: 0,
|
|
|
- strategy: '下轮查询',
|
|
|
- iteration: roundNum,
|
|
|
- is_selected: true
|
|
|
- };
|
|
|
-
|
|
|
- edges.push({
|
|
|
- from: nextRoundStepId,
|
|
|
- to: nextQStepId,
|
|
|
- edge_type: 'step_to_step',
|
|
|
- strategy: '查询'
|
|
|
- });
|
|
|
-
|
|
|
- if (!iterations[roundNum * 10 + 2]) iterations[roundNum * 10 + 2] = [];
|
|
|
- iterations[roundNum * 10 + 2].push(nextQStepId);
|
|
|
-
|
|
|
- // 添加下轮查询列表
|
|
|
- round.output_q_list.forEach((q, qIndex) => {
|
|
|
- const nextQId = `next_q_${q.text}_r${roundNum}_${qIndex}`;
|
|
|
-
|
|
|
- // 根据来源设置strategy
|
|
|
- let strategy;
|
|
|
- if (q.from === 'seg') {
|
|
|
- strategy = '初始分词';
|
|
|
- } else if (q.from === 'add') {
|
|
|
- strategy = '加词';
|
|
|
- } else if (q.from === 'sug') {
|
|
|
- strategy = '调用sug';
|
|
|
- } else {
|
|
|
- strategy = 'Query'; // 默认
|
|
|
- }
|
|
|
-
|
|
|
- nodes[nextQId] = {
|
|
|
- type: 'next_q',
|
|
|
- query: '[Q] ' + q.text,
|
|
|
- level: roundNum * 10 + 3,
|
|
|
- relevance_score: q.score || 0,
|
|
|
- evaluationReason: q.reason || '',
|
|
|
- strategy: strategy,
|
|
|
- iteration: roundNum,
|
|
|
- is_selected: true,
|
|
|
- from_source: q.from,
|
|
|
- type_label: q.type_label || q.typeLabel || ''
|
|
|
- };
|
|
|
-
|
|
|
- edges.push({
|
|
|
- from: nextQStepId,
|
|
|
- to: nextQId,
|
|
|
- edge_type: 'step_to_next_q',
|
|
|
- strategy: strategy
|
|
|
- });
|
|
|
-
|
|
|
- if (!iterations[roundNum * 10 + 3]) iterations[roundNum * 10 + 3] = [];
|
|
|
- iterations[roundNum * 10 + 3].push(nextQId);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 5.2: 构建下轮种子(如果有数据的话)
|
|
|
- if (nextSeedCount > 0 && round.seed_list_next) {
|
|
|
- const nextSeedStepId = `step_next_seed_r${roundNum}`;
|
|
|
- nodes[nextSeedStepId] = {
|
|
|
+ if (nextRoundItems.length > 0) {
|
|
|
+ const nextRoundStepId = `step_next_round_r${roundNum}`;
|
|
|
+ nodes[nextRoundStepId] = {
|
|
|
type: 'step',
|
|
|
- query: `构建下轮种子 (${nextSeedCount}个)`,
|
|
|
- level: roundNum * 10 + 2,
|
|
|
+ query: `步骤4: 构建下一轮 (${nextRoundItems.length}个查询)`,
|
|
|
+ level: roundNum * 10 + 1,
|
|
|
relevance_score: 0,
|
|
|
- strategy: '下轮种子',
|
|
|
+ strategy: '构建下一轮',
|
|
|
iteration: roundNum,
|
|
|
is_selected: true
|
|
|
};
|
|
|
|
|
|
edges.push({
|
|
|
- from: nextRoundStepId,
|
|
|
- to: nextSeedStepId,
|
|
|
- edge_type: 'step_to_step',
|
|
|
- strategy: '种子'
|
|
|
+ from: roundId,
|
|
|
+ to: nextRoundStepId,
|
|
|
+ edge_type: 'round_to_step',
|
|
|
+ strategy: '构建下一轮'
|
|
|
});
|
|
|
|
|
|
- if (!iterations[roundNum * 10 + 2]) iterations[roundNum * 10 + 2] = [];
|
|
|
- iterations[roundNum * 10 + 2].push(nextSeedStepId);
|
|
|
+ iterations[roundNum * 10].push(nextRoundStepId);
|
|
|
|
|
|
- // 添加下轮种子列表
|
|
|
- round.seed_list_next.forEach((seed, seedIndex) => {
|
|
|
- const nextSeedId = `next_seed_${seed.text}_r${roundNum}_${seedIndex}`;
|
|
|
-
|
|
|
- // 根据来源设置strategy
|
|
|
- let strategy;
|
|
|
- if (seed.from === 'seg') {
|
|
|
- strategy = '初始分词';
|
|
|
- } else if (seed.from === 'add') {
|
|
|
- strategy = '加词';
|
|
|
- } else if (seed.from === 'sug') {
|
|
|
- strategy = '调用sug';
|
|
|
- } else {
|
|
|
- strategy = 'Seed'; // 默认
|
|
|
- }
|
|
|
-
|
|
|
- nodes[nextSeedId] = {
|
|
|
- type: 'next_seed',
|
|
|
- query: seed.text,
|
|
|
- level: roundNum * 10 + 3,
|
|
|
- relevance_score: seed.score || 0,
|
|
|
- strategy: strategy,
|
|
|
+ // 创建查询节点
|
|
|
+ nextRoundItems.forEach((item, index) => {
|
|
|
+ const itemId = `next_round_${item.text}_r${roundNum}_${index}`;
|
|
|
+ nodes[itemId] = {
|
|
|
+ type: 'next_round_item',
|
|
|
+ query: '[Q] ' + item.text,
|
|
|
+ level: roundNum * 10 + 2,
|
|
|
+ relevance_score: item.score || 0,
|
|
|
+ strategy: item.type === 'combination' ? '域内组合' : '高增益SUG',
|
|
|
iteration: roundNum,
|
|
|
is_selected: true,
|
|
|
- from_source: seed.from
|
|
|
+ type_label: item.type_label || '',
|
|
|
+ item_type: item.type
|
|
|
};
|
|
|
|
|
|
edges.push({
|
|
|
- from: nextSeedStepId,
|
|
|
- to: nextSeedId,
|
|
|
- edge_type: 'step_to_next_seed',
|
|
|
- strategy: strategy
|
|
|
+ from: nextRoundStepId,
|
|
|
+ to: itemId,
|
|
|
+ edge_type: 'step_to_next_round',
|
|
|
+ strategy: item.type === 'combination' ? '域内组合' : 'SUG'
|
|
|
});
|
|
|
|
|
|
- if (!iterations[roundNum * 10 + 3]) iterations[roundNum * 10 + 3] = [];
|
|
|
- iterations[roundNum * 10 + 3].push(nextSeedId);
|
|
|
+ if (!iterations[roundNum * 10 + 2]) iterations[roundNum * 10 + 2] = [];
|
|
|
+ iterations[roundNum * 10 + 2].push(itemId);
|
|
|
});
|
|
|
}
|
|
|
}
|