[improvement][chat] The similarity of MapModeEnum.STRICT is 1 (#1851)

This commit is contained in:
lexluo09
2024-10-28 19:58:13 +08:00
committed by GitHub
parent b3d4440781
commit de4384062c
4 changed files with 16 additions and 15 deletions

View File

@@ -20,7 +20,7 @@ import java.util.Set;
public abstract class BaseMatchStrategy<T extends MapResult> implements MatchStrategy<T> {
@Override
public Map<MatchText, List<T>> match(ChatQueryContext chatQueryContext, List<S2Term> terms,
Set<Long> detectDataSetIds) {
Set<Long> detectDataSetIds) {
String text = chatQueryContext.getRequest().getQueryText();
if (Objects.isNull(terms) || StringUtils.isEmpty(text)) {
return null;
@@ -36,7 +36,7 @@ public abstract class BaseMatchStrategy<T extends MapResult> implements MatchStr
}
public List<T> detect(ChatQueryContext chatQueryContext, List<S2Term> terms,
Set<Long> detectDataSetIds) {
Set<Long> detectDataSetIds) {
throw new RuntimeException("Not implemented");
}
@@ -64,6 +64,9 @@ public abstract class BaseMatchStrategy<T extends MapResult> implements MatchStr
}
public double getThreshold(Double threshold, Double minThreshold, MapModeEnum mapModeEnum) {
if (MapModeEnum.STRICT.equals(mapModeEnum)) {
return 1.0d;
}
double decreaseAmount = (threshold - minThreshold) / 4;
double divideThreshold = threshold - mapModeEnum.threshold * decreaseAmount;
return divideThreshold >= minThreshold ? divideThreshold : minThreshold;