mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 13:47:09 +00:00
[improvement][project]Adjust files based on code style.
This commit is contained in:
@@ -27,7 +27,7 @@ public abstract class BaseMatchStrategy<T extends MapResult> implements MatchStr
|
||||
|
||||
@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;
|
||||
@@ -43,7 +43,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");
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class EmbeddingMatchStrategy extends BatchMatchStrategy<EmbeddingResult>
|
||||
|
||||
@Override
|
||||
public List<EmbeddingResult> detectByBatch(ChatQueryContext chatQueryContext,
|
||||
Set<Long> detectDataSetIds, Set<String> detectSegments) {
|
||||
Set<Long> detectDataSetIds, Set<String> detectSegments) {
|
||||
Set<EmbeddingResult> results = ConcurrentHashMap.newKeySet();
|
||||
int embeddingMapperBatch = Integer
|
||||
.valueOf(mapperConfig.getParameterValue(MapperConfig.EMBEDDING_MAPPER_BATCH));
|
||||
@@ -65,7 +65,7 @@ public class EmbeddingMatchStrategy extends BatchMatchStrategy<EmbeddingResult>
|
||||
}
|
||||
|
||||
private Callable<Void> createTask(ChatQueryContext chatQueryContext, Set<Long> detectDataSetIds,
|
||||
List<String> queryTextsSub, Set<EmbeddingResult> results) {
|
||||
List<String> queryTextsSub, Set<EmbeddingResult> results) {
|
||||
return () -> {
|
||||
List<EmbeddingResult> oneRoundResults =
|
||||
detectByQueryTextsSub(detectDataSetIds, queryTextsSub, chatQueryContext);
|
||||
@@ -77,7 +77,7 @@ public class EmbeddingMatchStrategy extends BatchMatchStrategy<EmbeddingResult>
|
||||
}
|
||||
|
||||
private List<EmbeddingResult> detectByQueryTextsSub(Set<Long> detectDataSetIds,
|
||||
List<String> queryTextsSub, ChatQueryContext chatQueryContext) {
|
||||
List<String> queryTextsSub, ChatQueryContext chatQueryContext) {
|
||||
Map<Long, List<Long>> modelIdToDataSetIds = chatQueryContext.getModelIdToDataSetIds();
|
||||
double threshold =
|
||||
Double.valueOf(mapperConfig.getParameterValue(EMBEDDING_MAPPER_THRESHOLD));
|
||||
|
||||
@@ -23,19 +23,20 @@ public abstract class SingleMatchStrategy<T extends MapResult> extends BaseMatch
|
||||
protected MapperHelper mapperHelper;
|
||||
|
||||
public List<T> detect(ChatQueryContext chatQueryContext, List<S2Term> terms,
|
||||
Set<Long> detectDataSetIds) {
|
||||
Set<Long> detectDataSetIds) {
|
||||
Map<Integer, Integer> regOffsetToLength = mapperHelper.getRegOffsetToLength(terms);
|
||||
String text = chatQueryContext.getRequest().getQueryText();
|
||||
Set<T> results = ConcurrentHashMap.newKeySet();
|
||||
List<Callable<Void>> tasks = new ArrayList<>();
|
||||
|
||||
for (int startIndex = 0; startIndex <= text.length() - 1; ) {
|
||||
for (int index = startIndex; index <= text.length(); ) {
|
||||
for (int startIndex = 0; startIndex <= text.length() - 1;) {
|
||||
for (int index = startIndex; index <= text.length();) {
|
||||
int offset = mapperHelper.getStepOffset(terms, startIndex);
|
||||
index = mapperHelper.getStepIndex(regOffsetToLength, index);
|
||||
if (index <= text.length()) {
|
||||
String detectSegment = text.substring(startIndex, index).trim();
|
||||
Callable<Void> task = createTask(chatQueryContext, detectDataSetIds, detectSegment, offset, results);
|
||||
Callable<Void> task = createTask(chatQueryContext, detectDataSetIds,
|
||||
detectSegment, offset, results);
|
||||
tasks.add(task);
|
||||
}
|
||||
}
|
||||
@@ -46,7 +47,7 @@ public abstract class SingleMatchStrategy<T extends MapResult> extends BaseMatch
|
||||
}
|
||||
|
||||
private Callable<Void> createTask(ChatQueryContext chatQueryContext, Set<Long> detectDataSetIds,
|
||||
String detectSegment, int offset, Set<T> results) {
|
||||
String detectSegment, int offset, Set<T> results) {
|
||||
return () -> {
|
||||
List<T> oneRoundResults =
|
||||
detectByStep(chatQueryContext, detectDataSetIds, detectSegment, offset);
|
||||
@@ -58,5 +59,5 @@ public abstract class SingleMatchStrategy<T extends MapResult> extends BaseMatch
|
||||
}
|
||||
|
||||
public abstract List<T> detectByStep(ChatQueryContext chatQueryContext,
|
||||
Set<Long> detectDataSetIds, String detectSegment, int offset);
|
||||
Set<Long> detectDataSetIds, String detectSegment, int offset);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user