mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
[improvement][chat]Modify core workflow of NL2SQLParser, always invoking rule-based parsers first.#1729
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.tencent.supersonic.headless.chat.parser.rule;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElementMatch;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaMapInfo;
|
||||
import com.tencent.supersonic.headless.chat.ChatQueryContext;
|
||||
import com.tencent.supersonic.headless.chat.parser.SemanticParser;
|
||||
import com.tencent.supersonic.headless.chat.query.SemanticQuery;
|
||||
import com.tencent.supersonic.headless.chat.query.rule.RuleSemanticQuery;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -27,6 +29,7 @@ public class RuleSqlParser implements SemanticParser {
|
||||
return;
|
||||
}
|
||||
SchemaMapInfo mapInfo = chatQueryContext.getMapInfo();
|
||||
List<SemanticQuery> candidateQueries = Lists.newArrayList();
|
||||
// iterate all schemaElementMatches to resolve query mode
|
||||
for (Long dataSetId : mapInfo.getMatchedDataSetInfos()) {
|
||||
List<SchemaElementMatch> elementMatches = mapInfo.getMatchedElements(dataSetId);
|
||||
@@ -36,7 +39,10 @@ public class RuleSqlParser implements SemanticParser {
|
||||
query.fillParseInfo(chatQueryContext);
|
||||
chatQueryContext.getCandidateQueries().add(query);
|
||||
}
|
||||
candidateQueries.addAll(chatQueryContext.getCandidateQueries());
|
||||
chatQueryContext.getCandidateQueries().clear();
|
||||
}
|
||||
chatQueryContext.setCandidateQueries(candidateQueries);
|
||||
|
||||
auxiliaryParsers.forEach(p -> p.parse(chatQueryContext));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user