分词es路径修改
This commit is contained in:
parent
2f02ecfe67
commit
2b15682b0a
@ -10,13 +10,10 @@ package com.suisung.mall.common.utils;
|
||||
|
||||
import com.huaban.analysis.jieba.JiebaSegmenter;
|
||||
import com.huaban.analysis.jieba.WordDictionary;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@ -33,6 +30,7 @@ import static com.suisung.mall.common.utils.ProductTitleUtil.*;
|
||||
@Component
|
||||
public class JiebaUtils {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JiebaUtils.class);
|
||||
private final JiebaSegmenter segmenter = new JiebaSegmenter();
|
||||
// 中文保护标记(不会被分割)
|
||||
private static final String PROTECT_START = "开始";
|
||||
@ -71,13 +69,12 @@ public class JiebaUtils {
|
||||
private static void loadUserDict() {
|
||||
// 方法1:通过文件加载
|
||||
WordDictionary dictionary = WordDictionary.getInstance();
|
||||
try {
|
||||
Resource resource=new ClassPathResource("dic/user_dict.txt");
|
||||
Path path = Paths.get(resource.getURI());
|
||||
dictionary.loadUserDict(path);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
dictionary.loadDict();
|
||||
// Resource resource=new ClassPathResource("dic/dict.txt");
|
||||
// if(resource.exists()){
|
||||
// //Path path = Paths.get(resource.getURI());
|
||||
// dictionary.loadDict();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -401,14 +398,14 @@ public class JiebaUtils {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// JiebaUtils jiebaUtils = new JiebaUtils();
|
||||
//String text = "云计算和区块链是热门技术";
|
||||
String text = "云计算和区块链是热门技术";
|
||||
// String text = "新鲜牛肉饺子500g";
|
||||
//String text = "志高1.8L电热水壶";
|
||||
// String text = "(单充)数据线2m";
|
||||
// String text = "雅安利2.0*2.3四件套";
|
||||
// String text = "RSCW-1949剃须刀";
|
||||
System.out.println(cleanNumberAndDigit("日本豆腐3条"));
|
||||
String text="六指鼠童袜001";
|
||||
//String text="六指鼠童袜001";
|
||||
List<String> words = JiebaUtils.extractKeywords(text);
|
||||
System.out.println(words);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user