mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 20:25:12 +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]);
|
&& 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) {
|
public static DataSetInfoStat getDataSetStat(List<S2Term> terms) {
|
||||||
return DataSetInfoStat.builder()
|
return DataSetInfoStat.builder()
|
||||||
.dataSetCount(getDataSetCount(terms))
|
.dataSetCount(getDataSetCount(terms))
|
||||||
|
|||||||
@@ -105,8 +105,7 @@ public class RetrieveServiceImpl implements RetrieveService {
|
|||||||
Set<SearchResult> searchResults = new LinkedHashSet();
|
Set<SearchResult> searchResults = new LinkedHashSet();
|
||||||
DataSetInfoStat dataSetInfoStat = NatureHelper.getDataSetStat(originals);
|
DataSetInfoStat dataSetInfoStat = NatureHelper.getDataSetStat(originals);
|
||||||
|
|
||||||
List<Long> possibleDataSets =
|
List<Long> possibleDataSets = getPossibleDataSets(queryNLReq, originals, dataSetIds);
|
||||||
getPossibleDataSets(queryNLReq, originals, dataSetInfoStat, dataSetIds);
|
|
||||||
|
|
||||||
// 5.1 priority dimension metric
|
// 5.1 priority dimension metric
|
||||||
boolean existMetricAndDimension =
|
boolean existMetricAndDimension =
|
||||||
@@ -141,36 +140,19 @@ public class RetrieveServiceImpl implements RetrieveService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Long> getPossibleDataSets(
|
private List<Long> getPossibleDataSets(
|
||||||
QueryNLReq queryCtx,
|
QueryNLReq queryCtx, List<S2Term> originals, Set<Long> dataSetIds) {
|
||||||
List<S2Term> originals,
|
|
||||||
DataSetInfoStat dataSetInfoStat,
|
|
||||||
Set<Long> dataSetIds) {
|
|
||||||
if (CollectionUtils.isNotEmpty(dataSetIds)) {
|
if (CollectionUtils.isNotEmpty(dataSetIds)) {
|
||||||
return new ArrayList<>(dataSetIds);
|
return new ArrayList<>(dataSetIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> possibleDataSets = NatureHelper.selectPossibleDataSets(originals);
|
List<Long> possibleDataSets = NatureHelper.selectPossibleDataSets(originals);
|
||||||
|
if (possibleDataSets.isEmpty()) {
|
||||||
Long contextDataset = queryCtx.getContextParseInfo().getDataSetId();
|
if (Objects.nonNull(queryCtx.getContextParseInfo())) {
|
||||||
|
possibleDataSets.add(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);
|
|
||||||
}
|
}
|
||||||
return possibleDataSets;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean nothingOrOnlyMetric(DataSetInfoStat modelStat) {
|
return possibleDataSets;
|
||||||
return modelStat.getMetricDataSetCount() >= 0
|
|
||||||
&& modelStat.getDimensionDataSetCount() <= 0
|
|
||||||
&& modelStat.getDimensionValueDataSetCount() <= 0
|
|
||||||
&& modelStat.getDataSetCount() <= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<SearchResult> searchDimensionValue(
|
private Set<SearchResult> searchDimensionValue(
|
||||||
|
|||||||
Reference in New Issue
Block a user