mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-06-26 06:39:20 +08:00
Compare commits
3 Commits
ef2f07a59e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de60be3908 | ||
|
|
0868850edd | ||
|
|
6d41ce4c5b |
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -50,8 +51,12 @@ public class HanlpDictMatchStrategy extends SingleMatchStrategy<HanlpMapResult>
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// step3. merge pre/suffix result
|
||||
// sort by similarity (desc) first, then name length (desc), so that
|
||||
// higher-similarity records are inserted first and survive LinkedHashSet dedup
|
||||
hanlpMapResults = hanlpMapResults.stream()
|
||||
.sorted((a, b) -> -(b.getName().length() - a.getName().length()))
|
||||
.sorted(Comparator.comparingDouble(HanlpMapResult::getSimilarity).reversed()
|
||||
.thenComparing((a, b) -> Integer.compare(b.getName().length(),
|
||||
a.getName().length())))
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
|
||||
// step4. filter by similarity
|
||||
|
||||
@@ -123,15 +123,9 @@ public class MapFilter {
|
||||
.filter(SchemaElementMatch::isFullMatched).collect(Collectors.toList());
|
||||
|
||||
if (!fullMatches.isEmpty()) {
|
||||
// If there are objects with similarity=1.0, choose the one with the longest
|
||||
// detectWord and smallest offset
|
||||
SchemaElementMatch bestMatch = fullMatches.stream()
|
||||
.max(Comparator.comparing(
|
||||
(SchemaElementMatch match) -> match.getDetectWord().length()))
|
||||
.orElse(null);
|
||||
if (bestMatch != null) {
|
||||
result.add(bestMatch);
|
||||
}
|
||||
// Keep all records with similarity=1.0, as they may correspond to different
|
||||
// elementIds with the same detectWord
|
||||
result.addAll(fullMatches);
|
||||
} else {
|
||||
// If there are no objects with similarity=1.0, keep all objects with similarity<1.0
|
||||
result.addAll(group);
|
||||
|
||||
@@ -123,8 +123,10 @@ public class DataSetSchemaBuilder {
|
||||
dimToAdd.getExtInfo().put(DimensionConstants.DIMENSION_DATA_TYPE,
|
||||
dim.getDataType());
|
||||
} else {
|
||||
dimToAdd.getExtInfo().put(DimensionConstants.DIMENSION_DATA_TYPE,
|
||||
dataTypeMap.get(dim.getModelId()).get(dim.getBizName()));
|
||||
if (dataTypeMap.containsKey(dim.getModelId())) {
|
||||
dimToAdd.getExtInfo().put(DimensionConstants.DIMENSION_DATA_TYPE,
|
||||
dataTypeMap.get(dim.getModelId()).get(dim.getBizName()));
|
||||
}
|
||||
}
|
||||
if (dim.isTimeDimension()) {
|
||||
String timeFormat =
|
||||
|
||||
@@ -105,7 +105,7 @@ const ModelFieldForm: React.FC<Props> = ({
|
||||
let defaultParams:any = {};
|
||||
if (value === EnumDataSourceType.MEASURES) {
|
||||
defaultParams = {
|
||||
agg: AGG_OPTIONS[0].value,
|
||||
agg: AGG_OPTIONS[AGG_OPTIONS.length - 1].value,
|
||||
classType: EnumDataSourceType.MEASURES,
|
||||
type: EnumDataSourceType.MEASURES,
|
||||
};
|
||||
@@ -217,7 +217,7 @@ const ModelFieldForm: React.FC<Props> = ({
|
||||
handleFieldChange(record, 'agg', value);
|
||||
}}
|
||||
allowClear
|
||||
defaultValue={AGG_OPTIONS[0].value}
|
||||
defaultValue={AGG_OPTIONS[AGG_OPTIONS.length - 1].value}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
{AGG_OPTIONS.map((item) => (
|
||||
|
||||
Reference in New Issue
Block a user