shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.walker.semantics.util;
 
import com.walker.infrastructure.utils.StringUtils;
 
public class SemanticsUtils {
 
    public static final String EMPTY_TEXT = "";
 
    /**
     * 返回给定关键词的Hash码集合
     * @param words 一组关键词,用英文逗号分隔
     * @return
     * @date 2023-08-17
     */
    public static final Integer[] acquireWordHashCode(String words){
        if(StringUtils.isEmpty(words)){
            throw new IllegalArgumentException("words不存在");
        }
        String[] wordArray = StringUtils.commaDelimitedListToStringArray(words);
        Integer[] data = new Integer[wordArray.length];
        for(int i=0; i<wordArray.length; i++){
            data[i] = wordArray[i].hashCode();
        }
        return data;
    }
 
    public static boolean isEmpty(String text){
        if(text == null || text.equals(EMPTY_TEXT)){
            return true;
        }
        return false;
    }
}