mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
[improvement][chat] The two characters need to be a perfect match (#1805)
This commit is contained in:
@@ -21,6 +21,7 @@ public class MapFilter {
|
||||
public static void filter(ChatQueryContext chatQueryContext) {
|
||||
filterByDataSetId(chatQueryContext);
|
||||
filterByDetectWordLenLessThanOne(chatQueryContext);
|
||||
twoCharactersMustEqual(chatQueryContext);
|
||||
switch (chatQueryContext.getQueryDataType()) {
|
||||
case TAG:
|
||||
filterByQueryDataType(chatQueryContext, element -> !(element.getIsTag() > 0));
|
||||
@@ -70,6 +71,19 @@ public class MapFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private static void twoCharactersMustEqual(ChatQueryContext chatQueryContext) {
|
||||
Map<Long, List<SchemaElementMatch>> dataSetElementMatches =
|
||||
chatQueryContext.getMapInfo().getDataSetElementMatches();
|
||||
for (Map.Entry<Long, List<SchemaElementMatch>> entry : dataSetElementMatches.entrySet()) {
|
||||
List<SchemaElementMatch> value = entry.getValue();
|
||||
if (!CollectionUtils.isEmpty(value)) {
|
||||
value.removeIf(schemaElementMatch -> StringUtils
|
||||
.length(schemaElementMatch.getDetectWord()) <= 2
|
||||
&& schemaElementMatch.getSimilarity() < 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void filterByQueryDataType(ChatQueryContext chatQueryContext,
|
||||
Predicate<SchemaElement> needRemovePredicate) {
|
||||
Map<Long, List<SchemaElementMatch>> dataSetElementMatches =
|
||||
|
||||
Reference in New Issue
Block a user