mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-01-18 17:01:02 +08:00
1 修复生成的用户token 一生成就失效的问题 2 如果用户设置的token ,需校验是否数据库存在,因为用户可设置一年的token 有泄露风险 3 结果解析优化, 去除不可以解析的情况,解析问题需要改写后的问, 4 召回样例,用相似度,保住至少有一个样例是高相似度的 5 数据集召回,填加完全匹配格式筛选逻辑
51 lines
1.5 KiB
Java
51 lines
1.5 KiB
Java
package com.hankcs.hanlp;
|
|
|
|
import com.tencent.supersonic.common.pojo.enums.DictWordType;
|
|
import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
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 {
|
|
|
|
public List removeNatures(List value, Set<Long> modelIdOrDataSetIds) {
|
|
if (CollectionUtils.isEmpty(value)) {
|
|
return value;
|
|
}
|
|
List<String> resultList = new ArrayList<>(value);
|
|
if (!CollectionUtils.isEmpty(modelIdOrDataSetIds)) {
|
|
resultList.removeIf(nature -> {
|
|
if (Objects.isNull(nature) || !nature.startsWith("_")) { // 系统的字典是以 _ 开头的,
|
|
// 过滤因引用外部字典导致的异常
|
|
return false;
|
|
}
|
|
Long id = getId(nature);
|
|
if (Objects.nonNull(id)) {
|
|
return !modelIdOrDataSetIds.contains(id);
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
return resultList;
|
|
}
|
|
|
|
public Long getId(String nature) {
|
|
try {
|
|
String[] split = nature.split(DictWordType.NATURE_SPILT);
|
|
if (split.length <= 1) {
|
|
return null;
|
|
}
|
|
return Long.valueOf(split[1]);
|
|
} catch (NumberFormatException e) {
|
|
log.error("", e);
|
|
}
|
|
return null;
|
|
}
|
|
}
|