package aaa.bbb.demo;
import java.util.ArrayList;
import java.util.List;
public class RecognitionDemo {
public static void main(String[] args) {
String str1="SB哈NM哈哈哈WBDhdsada";
String str_deal=str1.replaceAll("['.,,。_+=~!@#$%^&*(){}\\-\\[\\]']", "");
long beginTime = System.currentTimeMillis();
MapDemo aaa=new MapDemo();
int length=0;
for(int i=0;i<str_deal.length();i++){
length=aaa.getStr(str_deal,i);
if(length>0){
System.out.println(str_deal.substring(i, i+length));
}
if(length==str_deal.length()){
break;
}else{
i=i+length;
}
}
long endTime = System.currentTimeMillis();
System.out.println(endTime-beginTime);
}
public int getStr(String str,int j){
List<String> lis_obj=new ArrayList<String>();
lis_obj.add("CNM");
lis_obj.add("WBD");
lis_obj.add("SB");
int countNum=0;
for(int i=j;i<str.length();i++){
char str_char=str.charAt(i);
String ss=String.valueOf(str_char);
long bb=lis_obj.stream().filter(p->p.contains(ss)).count();
if(bb>0){
countNum=countNum+1;
}else{
break;
}
}
if(countNum<2){
countNum=0;
}
return countNum;
}
}
敏感字识别算法基于JDK8 lambada表达式
最新推荐文章于 2022-11-03 16:56:26 发布