(improvement)(chat) support remove dictionary and rename match strategy (#332)

This commit is contained in:
lexluo09
2023-11-06 21:03:38 +08:00
committed by GitHub
parent 6c9983164e
commit 6e3f871015
7 changed files with 32 additions and 13 deletions

View File

@@ -27,11 +27,11 @@ public class FuzzyNameMapper extends BaseMapper {
List<Term> terms = HanlpHelper.getTerms(queryContext.getRequest().getQueryText());
FuzzyMatchStrategy fuzzyMatchStrategy = ContextUtils.getBean(FuzzyMatchStrategy.class);
FuzzyNameMatchStrategy fuzzyNameMatchStrategy = ContextUtils.getBean(FuzzyNameMatchStrategy.class);
MapperHelper mapperHelper = ContextUtils.getBean(MapperHelper.class);
List<FuzzyResult> matches = fuzzyMatchStrategy.getMatches(queryContext, terms);
List<FuzzyResult> matches = fuzzyNameMatchStrategy.getMatches(queryContext, terms);
for (FuzzyResult match : matches) {
SchemaElement schemaElement = match.getSchemaElement();

View File

@@ -22,11 +22,11 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
/**
* Fuzzy Match Strategy
* Fuzzy Name Match Strategy
*/
@Service
@Slf4j
public class FuzzyMatchStrategy extends BaseMatchStrategy<FuzzyResult> {
public class FuzzyNameMatchStrategy extends BaseMatchStrategy<FuzzyResult> {
@Autowired
private OptimizationConfig optimizationConfig;
@@ -59,7 +59,6 @@ public class FuzzyMatchStrategy extends BaseMatchStrategy<FuzzyResult> {
public void detectByStep(QueryContext queryContext, Set<FuzzyResult> existResults, Set<Long> detectModelIds,
Integer startIndex, Integer index, int offset) {
String detectSegment = queryContext.getRequest().getQueryText().substring(startIndex, index);
// step1. build query params
if (StringUtils.isBlank(detectSegment)) {
return;
}

View File

@@ -30,7 +30,7 @@ public class HanlpDictMapper extends BaseMapper {
String queryText = queryContext.getRequest().getQueryText();
List<Term> terms = HanlpHelper.getTerms(queryText);
HanlpMatchStrategy matchStrategy = ContextUtils.getBean(HanlpMatchStrategy.class);
HanlpDictMatchStrategy matchStrategy = ContextUtils.getBean(HanlpDictMatchStrategy.class);
List<HanlpMapResult> matches = matchStrategy.getMatches(queryContext, terms);

View File

@@ -25,7 +25,7 @@ import org.springframework.stereotype.Service;
*/
@Service
@Slf4j
public class HanlpMatchStrategy extends BaseMatchStrategy<HanlpMapResult> {
public class HanlpDictMatchStrategy extends BaseMatchStrategy<HanlpMapResult> {
@Autowired
private MapperHelper mapperHelper;
@@ -71,8 +71,8 @@ public class HanlpMatchStrategy extends BaseMatchStrategy<HanlpMapResult> {
detectModelIds).stream().collect(Collectors.toCollection(LinkedHashSet::new));
// step2. suffix search
LinkedHashSet<HanlpMapResult> suffixHanlpMapResults = SearchService.suffixSearch(detectSegment,
oneDetectionMaxSize,
agentId, detectModelIds).stream().collect(Collectors.toCollection(LinkedHashSet::new));
oneDetectionMaxSize, agentId, detectModelIds).stream()
.collect(Collectors.toCollection(LinkedHashSet::new));
hanlpMapResults.addAll(suffixHanlpMapResults);

View File

@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
/**
* MatchStrategyImplTest
*/
class HanlpMatchStrategyTest extends ContextTest {
class HanlpDictMatchStrategyTest extends ContextTest {
@Test
void match() {