Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement](chat) Use the word-based approach for comparing Schema Mapping rules and fix the issue where the results were not being modified. #1650

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ public static void filterByQueryDataType(
public static void filterByRules(ChatQueryContext chatQueryContext) {
Map<Long, List<SchemaElementMatch>> dataSetElementMatches =
chatQueryContext.getMapInfo().getDataSetElementMatches();

for (Map.Entry<Long, List<SchemaElementMatch>> entry : dataSetElementMatches.entrySet()) {
List<SchemaElementMatch> elementMatches = entry.getValue();
filterByExactMatch(elementMatches);
filterInExactMatch(elementMatches);
filterByExactMatch(entry.getValue());
filterInExactMatch(entry.getValue());
}
}

public static List<SchemaElementMatch> filterByExactMatch(List<SchemaElementMatch> matches) {
public static void filterByExactMatch(List<SchemaElementMatch> matches) {
// Group by detectWord
Map<String, List<SchemaElementMatch>> groupedByDetectWord =
matches.stream().collect(Collectors.groupingBy(SchemaElementMatch::getDetectWord));
Expand Down Expand Up @@ -139,14 +139,15 @@ public static List<SchemaElementMatch> filterByExactMatch(List<SchemaElementMatc
result.addAll(group);
}
}
return result;
matches.clear();
matches.addAll(result);
}

public static List<SchemaElementMatch> filterInExactMatch(List<SchemaElementMatch> matches) {
public static void filterInExactMatch(List<SchemaElementMatch> matches) {
Map<String, List<SchemaElementMatch>> fullMatches =
matches.stream()
.filter(schemaElementMatch -> schemaElementMatch.isFullMatched())
.collect(Collectors.groupingBy(SchemaElementMatch::getDetectWord));
.collect(Collectors.groupingBy(SchemaElementMatch::getWord));
Set<String> keys = new HashSet<>(fullMatches.keySet());
for (String key1 : keys) {
for (String key2 : keys) {
Expand All @@ -163,6 +164,7 @@ public static List<SchemaElementMatch> filterInExactMatch(List<SchemaElementMatc
List<SchemaElementMatch> mergedMatches = new ArrayList<>();
fullMatches.values().forEach(mergedMatches::addAll);
mergedMatches.addAll(notFullMatches);
return mergedMatches;
matches.clear();
matches.addAll(mergedMatches);
}
}
Loading