mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
[fix][headless-chat]Fix NPE during word searching process.#1672
This commit is contained in:
@@ -113,10 +113,6 @@ public class NatureHelper {
|
||||
&& StringUtils.isNumeric(nature.split(DictWordType.NATURE_SPILT)[1]);
|
||||
}
|
||||
|
||||
public static boolean isTermNature(String nature) {
|
||||
return isNatureValid(nature) && nature.endsWith(DictWordType.TERM.getType());
|
||||
}
|
||||
|
||||
public static DataSetInfoStat getDataSetStat(List<S2Term> terms) {
|
||||
return DataSetInfoStat.builder()
|
||||
.dataSetCount(getDataSetCount(terms))
|
||||
|
||||
@@ -105,8 +105,7 @@ public class RetrieveServiceImpl implements RetrieveService {
|
||||
Set<SearchResult> searchResults = new LinkedHashSet();
|
||||
DataSetInfoStat dataSetInfoStat = NatureHelper.getDataSetStat(originals);
|
||||
|
||||
List<Long> possibleDataSets =
|
||||
getPossibleDataSets(queryNLReq, originals, dataSetInfoStat, dataSetIds);
|
||||
List<Long> possibleDataSets = getPossibleDataSets(queryNLReq, originals, dataSetIds);
|
||||
|
||||
// 5.1 priority dimension metric
|
||||
boolean existMetricAndDimension =
|
||||
@@ -141,36 +140,19 @@ public class RetrieveServiceImpl implements RetrieveService {
|
||||
}
|
||||
|
||||
private List<Long> getPossibleDataSets(
|
||||
QueryNLReq queryCtx,
|
||||
List<S2Term> originals,
|
||||
DataSetInfoStat dataSetInfoStat,
|
||||
Set<Long> dataSetIds) {
|
||||
QueryNLReq queryCtx, List<S2Term> originals, Set<Long> dataSetIds) {
|
||||
if (CollectionUtils.isNotEmpty(dataSetIds)) {
|
||||
return new ArrayList<>(dataSetIds);
|
||||
}
|
||||
|
||||
List<Long> possibleDataSets = NatureHelper.selectPossibleDataSets(originals);
|
||||
|
||||
Long contextDataset = queryCtx.getContextParseInfo().getDataSetId();
|
||||
|
||||
log.debug(
|
||||
"possibleDataSets:{},dataSetInfoStat:{},contextDataset:{}",
|
||||
possibleDataSets,
|
||||
dataSetInfoStat,
|
||||
contextDataset);
|
||||
|
||||
// If nothing is recognized or only metric are present, then add the contextDataset.
|
||||
if (nothingOrOnlyMetric(dataSetInfoStat)) {
|
||||
return Lists.newArrayList(contextDataset);
|
||||
if (possibleDataSets.isEmpty()) {
|
||||
if (Objects.nonNull(queryCtx.getContextParseInfo())) {
|
||||
possibleDataSets.add(queryCtx.getContextParseInfo().getDataSetId());
|
||||
}
|
||||
}
|
||||
return possibleDataSets;
|
||||
}
|
||||
|
||||
private boolean nothingOrOnlyMetric(DataSetInfoStat modelStat) {
|
||||
return modelStat.getMetricDataSetCount() >= 0
|
||||
&& modelStat.getDimensionDataSetCount() <= 0
|
||||
&& modelStat.getDimensionValueDataSetCount() <= 0
|
||||
&& modelStat.getDataSetCount() <= 0;
|
||||
return possibleDataSets;
|
||||
}
|
||||
|
||||
private Set<SearchResult> searchDimensionValue(
|
||||
|
||||
Reference in New Issue
Block a user