java去除符号和字母_java 字符串中去除 数字 字母 符号&&N*1*senten.Length=>M*M

2023-05-16

字符串中去除 数字 字母 符号

String str = "今天1@天%。气^64很?不?错.心情6666很好。。。。。";

String str1 = str.replaceAll("[,。、|~!@#¥;【》‘“”、】《·\\-?:,:{}%……&*()\\=—+ A-Za-z0-9]","").trim().equals("");

N14=》M*M

public static void preCNN(String modelPathName,String sentence) throws IOException {

//分词

String Participle = ANJS_Participle.ANJS_FC(sentence);

String[] ReParticiple = Participle.trim().split(" ");

//词转向量

Word2VEC vec = new Word2VEC();

vec.loadJavaModel("model/four_dimensional_My40d_");

double[] reVec = new double[1600];

int toPreNum = 0;

for (int i = 0; i < ReParticiple.length; i++) {

float[] vecrDes = vec.getWordVector(ReParticiple[i].trim());//转向量

if (vecrDes!=null) {

for (int j = 0; j < vecrDes.length; j++) {

reVec[toPreNum] = vecrDes[j];

toPreNum++;

}

}

}

if (toPreNum!=0) {

//N*1*=>M*M

OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(new File("temp/txt2Vec2Array1600.txt")),"GBK") ;

double[] toPre = new double[1600];

for (int i = 0; i < toPre.length; i++) {

toPre[i] = reVec[i%toPreNum];

out.write(reVec[i%toPreNum]+",");

}

out.close(); //关闭写操作

}else {

System.out.println(sentence+" 《= 该句话无词向量。。。。。");

}

}

打开App,阅读手记

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

java去除符号和字母_java 字符串中去除 数字 字母 符号&&N*1*senten.Length=>M*M 的相关文章

随机推荐