韦忠喜提交
parent
dc44d17446
commit
3272b0bc3c
@ -0,0 +1,5 @@
|
|||||||
|
package me.zhengjie.modules.buildrecord.rest.consts;
|
||||||
|
|
||||||
|
public class Sysconts {
|
||||||
|
public static final Integer NO_SEND = 0;
|
||||||
|
}
|
@ -0,0 +1,616 @@
|
|||||||
|
package me.zhengjie.modules.buildrecord.util;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
|
||||||
|
public class KeyWordFilter {
|
||||||
|
public static final String PATH_DIC_WFC = "/lib/wfc.dic";
|
||||||
|
public static final String PATH_DIC_FQC = "/lib/fqc.dic";
|
||||||
|
private HashMap<String, String> wfc_map = null;
|
||||||
|
private HashMap<String, String> fqc_map = null;
|
||||||
|
private HashMap<String, Integer> firstword_map = new HashMap<String, Integer>();
|
||||||
|
private HashMap<String, Integer> firstword_fqc_map = new HashMap<String, Integer>();
|
||||||
|
private static KeyWordFilter singleton;
|
||||||
|
|
||||||
|
private KeyWordFilter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized static KeyWordFilter getInstance() {
|
||||||
|
if (singleton == null) {
|
||||||
|
singleton = new KeyWordFilter();
|
||||||
|
}
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized HashMap<String, String> getWfcMap() {
|
||||||
|
if (wfc_map == null) {
|
||||||
|
wfc_map = getWordMap(PATH_DIC_WFC, "");
|
||||||
|
}
|
||||||
|
return wfc_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized HashMap<String, String> getFqcMap() {
|
||||||
|
if (fqc_map == null) {
|
||||||
|
fqc_map = getWordMap(PATH_DIC_FQC, "");
|
||||||
|
}
|
||||||
|
return fqc_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized HashMap<String, Integer> getFirstwordMap() {
|
||||||
|
if (firstword_map == null) {
|
||||||
|
firstword_map = new HashMap<String, Integer>();
|
||||||
|
}
|
||||||
|
return firstword_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized HashMap<String, Integer> getFirstwordFqcMap() {
|
||||||
|
if (firstword_fqc_map == null) {
|
||||||
|
firstword_fqc_map = new HashMap<String, Integer>();
|
||||||
|
}
|
||||||
|
return firstword_fqc_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean reload() {
|
||||||
|
try {
|
||||||
|
wfc_map = null;
|
||||||
|
fqc_map = null;
|
||||||
|
KeyWordFilter.getInstance().getWfcMap();
|
||||||
|
KeyWordFilter.getInstance().getFqcMap();
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean restart() {
|
||||||
|
try {
|
||||||
|
singleton = null;
|
||||||
|
getInstance();
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashMap<String, String> getWordMap(String dicPath, String replace) {
|
||||||
|
InputStream is = null;
|
||||||
|
HashMap<String, String> wordMap = new HashMap<String, String>();
|
||||||
|
try {
|
||||||
|
// is = new FileInputStream(dicPath);
|
||||||
|
is = KeyWordFilter.class.getResourceAsStream(dicPath);
|
||||||
|
if (is == null) {
|
||||||
|
System.out.println(dicPath + " not found!!!");
|
||||||
|
}
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(is,
|
||||||
|
"UTF-8"), 512);
|
||||||
|
String theWord = null;
|
||||||
|
HashMap<String, Integer> firstword = getFirstwordMap();
|
||||||
|
HashMap<String, Integer> firstword_fqc = getFirstwordFqcMap();
|
||||||
|
|
||||||
|
String ss = null;
|
||||||
|
if (dicPath.equals(PATH_DIC_FQC)) {
|
||||||
|
do {
|
||||||
|
theWord = br.readLine();
|
||||||
|
if (theWord != null && !"".equals(theWord.trim())) {
|
||||||
|
String[] sss = theWord.trim().toLowerCase().split("@@");
|
||||||
|
if (sss[0] != null && !sss[0].equals("")) {
|
||||||
|
if (firstword_fqc
|
||||||
|
.containsKey(sss[0].toCharArray()[0] + "")
|
||||||
|
&& firstword_fqc
|
||||||
|
.get(sss[0].toCharArray()[0] + "") > sss[0]
|
||||||
|
.length()) {
|
||||||
|
// do nothing
|
||||||
|
} else {
|
||||||
|
firstword_fqc.put(sss[0].toCharArray()[0] + "",
|
||||||
|
sss[0].length());
|
||||||
|
}
|
||||||
|
wordMap.put(sss[0], sss.length == 1 ? "" : sss[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (theWord != null);
|
||||||
|
} else {
|
||||||
|
do {
|
||||||
|
theWord = br.readLine();
|
||||||
|
if (theWord != null && !"".equals(theWord.trim())) {
|
||||||
|
ss = theWord.trim().toLowerCase();
|
||||||
|
if (firstword.containsKey(ss.toCharArray()[0] + "")
|
||||||
|
&& firstword.get(ss.toCharArray()[0] + "") > ss
|
||||||
|
.length()) {
|
||||||
|
// do nothing
|
||||||
|
} else {
|
||||||
|
firstword.put(theWord.trim().toLowerCase()
|
||||||
|
.toCharArray()[0]
|
||||||
|
+ "", ss.length());
|
||||||
|
}
|
||||||
|
wordMap.put(theWord.trim().toLowerCase(), replace);
|
||||||
|
}
|
||||||
|
} while (theWord != null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
if (is == null) {
|
||||||
|
System.err.println(dicPath + " not found!!!");
|
||||||
|
} else {
|
||||||
|
System.err.println(dicPath + " loading exception.");
|
||||||
|
}
|
||||||
|
ioe.printStackTrace();
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (is != null) {
|
||||||
|
is.close();
|
||||||
|
is = null;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wordMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String filter_in(String content, String sta, String usid) {
|
||||||
|
if (content == null || content.length() <= 0) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
if (usid == null) {
|
||||||
|
usid = "0";
|
||||||
|
}
|
||||||
|
HashMap<String, String> wfc_map = KeyWordFilter.getInstance()
|
||||||
|
.getWfcMap();
|
||||||
|
HashMap<String, String> fqc_map = KeyWordFilter.getInstance()
|
||||||
|
.getFqcMap();
|
||||||
|
HashMap<String, Integer> firstword_map = KeyWordFilter.getInstance()
|
||||||
|
.getFirstwordMap();
|
||||||
|
HashMap<String, Integer> firstword_fqc_map = KeyWordFilter
|
||||||
|
.getInstance().getFirstwordFqcMap();
|
||||||
|
|
||||||
|
int result_type = 0;
|
||||||
|
char[] ch = content.toCharArray();
|
||||||
|
StringBuffer ret = new StringBuffer();
|
||||||
|
StringBuffer word = new StringBuffer();
|
||||||
|
int start = 0;
|
||||||
|
int step = 0;
|
||||||
|
int max_length = 1;
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_fqc_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append(fqc_map.get(tmp.toLowerCase()));
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ch = ret.toString().toCharArray();
|
||||||
|
word = new StringBuffer();
|
||||||
|
start = 0;
|
||||||
|
step = 0;
|
||||||
|
if (sta.equals("1")) {
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
|
||||||
|
if (!firstword_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wfc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
result_type = 2;
|
||||||
|
break;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (sta.equals("0")) {
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wfc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
result_type = 2;
|
||||||
|
break;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Integer.toString(result_type);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String filter_out(String content, String sta, String usid) {
|
||||||
|
if (content == null || content.length() <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (usid == null) {
|
||||||
|
usid = "0";
|
||||||
|
}
|
||||||
|
HashMap<String, String> wfc_map = KeyWordFilter.getInstance()
|
||||||
|
.getWfcMap();
|
||||||
|
HashMap<String, String> fqc_map = KeyWordFilter.getInstance()
|
||||||
|
.getFqcMap();
|
||||||
|
HashMap<String, Integer> firstword_map = KeyWordFilter.getInstance()
|
||||||
|
.getFirstwordMap();
|
||||||
|
HashMap<String, Integer> firstword_fqc_map = KeyWordFilter
|
||||||
|
.getInstance().getFirstwordFqcMap();
|
||||||
|
|
||||||
|
char[] ch = content.toCharArray();
|
||||||
|
StringBuffer ret = new StringBuffer();
|
||||||
|
StringBuffer word = new StringBuffer();
|
||||||
|
int start = 0;
|
||||||
|
int step = 0;
|
||||||
|
int max_length = 1;
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_fqc_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append(fqc_map.get(tmp.toLowerCase()));
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ch = ret.toString().toCharArray();
|
||||||
|
ret = new StringBuffer();
|
||||||
|
word = new StringBuffer();
|
||||||
|
start = 0;
|
||||||
|
step = 0;
|
||||||
|
|
||||||
|
if (sta.equals("1")) {
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
// System.out.println("i="+i+"\tstart="+start+"\tstep="+step+"\tret="+ret.toString());
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
|
||||||
|
if (!firstword_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wfc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append("");
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (sta.equals("0")) {
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wfc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append("");
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String rs = ret.toString().replace("⊙", "");
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String filter_search(String content) {
|
||||||
|
if (content == null || content.length() <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
HashMap<String, String> fqc_map = KeyWordFilter.getInstance()
|
||||||
|
.getFqcMap();
|
||||||
|
HashMap<String, String> wfc_map = KeyWordFilter.getInstance()
|
||||||
|
.getWfcMap();
|
||||||
|
HashMap<String, Integer> firstword_map = KeyWordFilter.getInstance()
|
||||||
|
.getFirstwordMap();
|
||||||
|
HashMap<String, Integer> firstword_fqc_map = KeyWordFilter
|
||||||
|
.getInstance().getFirstwordFqcMap();
|
||||||
|
|
||||||
|
char[] ch = content.toCharArray();
|
||||||
|
StringBuffer ret = new StringBuffer();
|
||||||
|
StringBuffer word = new StringBuffer();
|
||||||
|
int start = 0;
|
||||||
|
int step = 0;
|
||||||
|
int max_length = 1;
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_fqc_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append(fqc_map.get(tmp.toLowerCase()));
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ch = ret.toString().toCharArray();
|
||||||
|
ret = new StringBuffer();
|
||||||
|
word = new StringBuffer();
|
||||||
|
start = 0;
|
||||||
|
step = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wfc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append("");
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String rs = ret.toString().replace("⊙", "");
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String filter_jk(String content, String sta, String usid,
|
||||||
|
String mgcstyle1, String mgcstyle2, String wfcstyle1,
|
||||||
|
String wfcstyle2) {
|
||||||
|
if (content == null || content.length() <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (usid == null) {
|
||||||
|
usid = "0";
|
||||||
|
}
|
||||||
|
HashMap<String, String> wfc_map = KeyWordFilter.getInstance()
|
||||||
|
.getWfcMap();
|
||||||
|
HashMap<String, String> fqc_map = KeyWordFilter.getInstance()
|
||||||
|
.getFqcMap();
|
||||||
|
HashMap<String, Integer> firstword_map = KeyWordFilter.getInstance()
|
||||||
|
.getFirstwordMap();
|
||||||
|
HashMap<String, Integer> firstword_fqc_map = KeyWordFilter
|
||||||
|
.getInstance().getFirstwordFqcMap();
|
||||||
|
|
||||||
|
char[] ch = content.toCharArray();
|
||||||
|
StringBuffer ret = new StringBuffer();
|
||||||
|
StringBuffer word = new StringBuffer();
|
||||||
|
int start = 0;
|
||||||
|
int step = 0;
|
||||||
|
int max_length = 1;
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_fqc_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fqc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append(fqc_map.get(tmp.toLowerCase()));
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ch = ret.toString().toCharArray();
|
||||||
|
ret = new StringBuffer();
|
||||||
|
word = new StringBuffer();
|
||||||
|
start = 0;
|
||||||
|
step = 0;
|
||||||
|
|
||||||
|
if (sta.equals("1")) {
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wfc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append(wfcstyle1);
|
||||||
|
ret.append(tmp.toLowerCase());
|
||||||
|
ret.append(wfcstyle2);
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (sta.equals("0")) {
|
||||||
|
for (int i = 0; i < ch.length; i++) {
|
||||||
|
if (step == 0) {
|
||||||
|
start = i;
|
||||||
|
step = 1;
|
||||||
|
}
|
||||||
|
char c = ch[i];
|
||||||
|
word.append(c);
|
||||||
|
String tmp = word.toString();
|
||||||
|
if (i == start) {
|
||||||
|
if (!firstword_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
max_length = firstword_map.get(tmp.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wfc_map.containsKey(tmp.toLowerCase())) {
|
||||||
|
ret.append(wfcstyle1);
|
||||||
|
ret.append(tmp.toLowerCase());
|
||||||
|
ret.append(wfcstyle2);
|
||||||
|
step = 0;
|
||||||
|
} else if (word.length() >= max_length || i >= ch.length - 1) {
|
||||||
|
step = 0;
|
||||||
|
ret.append(ch[start]);
|
||||||
|
word.delete(0, word.length());
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String rs = ret.toString().replace("⊙", "");
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
南宁市永安@@南宁市永⊙安
|
||||||
|
硫酸亚铁@@硫⊙酸亚铁
|
||||||
|
硫酸铁@@硫⊙酸铁
|
||||||
|
硫酸镁@@硫⊙酸镁
|
||||||
|
成人学校@@成⊙人学校
|
||||||
|
成人高考@@成⊙人高考
|
||||||
|
蛋白粉@@蛋白⊙粉
|
||||||
|
屏蔽电缆@@屏⊙蔽电缆
|
||||||
|
钛白粉@@钛白⊙粉
|
||||||
|
华莉达弹簧@@华莉达弹⊙簧
|
||||||
|
沙发转盘@@沙发转⊙盘
|
||||||
|
艺博彩鸿@@艺博⊙彩鸿
|
||||||
|
屏蔽线@@屏⊙蔽线
|
||||||
|
屏蔽网络线@@屏⊙蔽网络线
|
||||||
|
隐形纱窗@@隐⊙形纱窗
|
||||||
|
现代办公@@现代⊙办公
|
||||||
|
钻枪支架@@钻枪⊙支架
|
||||||
|
一次性用品@@一次性⊙用品
|
||||||
|
广东王牌@@广东⊙王牌
|
||||||
|
永康市@@永⊙康市
|
||||||
|
门口交易@@门口⊙交易
|
||||||
|
感情色彩@@感情⊙色彩
|
||||||
|
港口交通@@港口⊙交通
|
||||||
|
路口交通@@路口⊙交通
|
||||||
|
口交换机@@口⊙交换机
|
||||||
|
宝鸡巴士@@宝鸡⊙巴士
|
||||||
|
江阴道路@@江阴⊙道路
|
||||||
|
千百度@@千百⊙度
|
||||||
|
解放军7@@解⊙放军7
|
||||||
|
解放军七@@解⊙放军七
|
||||||
|
茅台镇@@茅⊙台镇
|
||||||
|
优阳科技@@优⊙阳科技
|
||||||
|
打折机票预订@@打折机⊙票预订
|
||||||
|
三螺@@三⊙螺
|
||||||
|
3螺@@3⊙螺
|
||||||
|
漂白粉@@漂白⊙粉
|
||||||
|
电动车@@电动⊙车
|
||||||
|
硫酸泵@@硫⊙酸泵
|
||||||
|
硫酸离心泵@@硫⊙酸离心泵
|
||||||
|
硫酸液下泵@@硫⊙酸液下泵
|
||||||
|
硫酸钡@@硫⊙酸钡
|
||||||
|
硫酸铵@@硫⊙酸铵
|
||||||
|
ngcd@@ng⊙cd
|
||||||
|
铅丝石笼@@铅⊙丝石笼
|
||||||
|
ISO认证@@ISO认⊙证
|
||||||
|
UC4@@UC⊙4
|
||||||
|
厨房刀具@@厨房刀⊙具
|
||||||
|
兽药@@兽⊙药
|
||||||
|
电动门遥控器@@电动门遥控⊙器
|
||||||
|
卷帘门遥控器@@卷帘门遥控⊙器
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue