[improvement][chat] Filter at the lowest level in the Map based on the dataSetId (#1834)

This commit is contained in:
lexluo09
2024-10-20 21:51:57 +08:00
committed by GitHub
parent 1d84e00887
commit 473329d398
108 changed files with 232 additions and 165 deletions

View File

@@ -3,38 +3,38 @@ package com.hankcs.hanlp;
import com.tencent.supersonic.common.pojo.enums.DictWordType;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@Data
@Slf4j
public class LoadRemoveService {
@Value("${s2.mapper.remove.nature.prefix:}")
private String mapperRemoveNaturePrefix;
public List removeNatures(List value) {
public List removeNatures(List value, Set<Long> modelIdOrDataSetIds) {
if (CollectionUtils.isEmpty(value)) {
return value;
}
List<String> resultList = new ArrayList<>(value);
if (StringUtils.isNotBlank(mapperRemoveNaturePrefix)) {
if (!CollectionUtils.isEmpty(modelIdOrDataSetIds)) {
resultList.removeIf(nature -> {
if (Objects.isNull(nature)) {
return false;
}
return nature.startsWith(mapperRemoveNaturePrefix);
Long id = getId(nature);
if (Objects.nonNull(id)) {
return !modelIdOrDataSetIds.contains(id);
}
return false;
});
}
return resultList;
}
public Long getDataSetId(String nature) {
public Long getId(String nature) {
try {
String[] split = nature.split(DictWordType.NATURE_SPILT);
if (split.length <= 1) {