ossean/match_program/util/Normalizer.java

21 lines
573 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.star.util;
import java.util.List;
public class Normalizer {
public static String removeVersion(String str){
//现在对于2.45还不能处理,也就是点后边两个连续的后缀
return str.replaceAll("\\-*\\d+(\\.[\\d|x|X])*$","");
}
//对字符串进行规整,去除版本号后缀和连接符等
public static String normalize(String str) {
//目前可能会删除掉一些确实以数字结尾的项目;在停用词里添加‘-
return removeVersion(str).replaceAll("[\\-]+"," ").replaceAll("'s"," ").toLowerCase();
}
}