字符串中去除 数字 字母 符号
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+" 《= 该句话无词向量。。。。。");
}
}