[b]1.获取匹配信息的方法[/b]
例: 获取字符串中 20XX 和 19XX 形式的数值
[b]2.IKanalyzer 中文分词的方法[/b]
[url=http://dl.iteye.com/topics/download/fab66cb4-4afb-3924-ad69-4b5ed909db00]下载IKAnalyzer3.2[/url]
[url=http://dl.iteye.com/topics/download/cee89094-894d-3cea-a064-60bfb1bb51c3]下载lucene-3.0.3.jar[/url]
[b]3.中英文停用词库[/b]
[url=http://dl.iteye.com/topics/download/a6959777-acad-378b-8ad4-bf05b4b76303]下载附件[/url](另附 导入数据库类)
[b]4.struts1重定向的方法[/b]
注:url中若含有中文,需经过编码:URLEncoder.encode(url, "UTF-8")
[b]5.获得时间[/b]
例: 获取字符串中 20XX 和 19XX 形式的数值
public static String findDate(String str){
// str1.matches("[\\w\\W]*[19\\d{2}|20\\d{2}][\\w\\W]*");
Pattern pt = Pattern.compile("19\\d{2}|20\\d{2}");
Matcher m = pt.matcher(str);
boolean found = m.find();
if(found) return m.group();
return "";
}
[b]2.IKanalyzer 中文分词的方法[/b]
[url=http://dl.iteye.com/topics/download/fab66cb4-4afb-3924-ad69-4b5ed909db00]下载IKAnalyzer3.2[/url]
[url=http://dl.iteye.com/topics/download/cee89094-894d-3cea-a064-60bfb1bb51c3]下载lucene-3.0.3.jar[/url]
public static String splitChinese(String text) {
String output = "";
Analyzer analyzer = new IKAnalyzer();
TokenStream tokenStream = analyzer.tokenStream("", new StringReader(text));
TermAttribute termAtt = (TermAttribute) tokenStream.getAttribute(TermAttribute.class);
try {
while (tokenStream.incrementToken()) {
output += termAtt.term() + " ";
}
} catch (IOException e) {
e.printStackTrace();
}
return output;
}
[b]3.中英文停用词库[/b]
[url=http://dl.iteye.com/topics/download/a6959777-acad-378b-8ad4-bf05b4b76303]下载附件[/url](另附 导入数据库类)
[b]4.struts1重定向的方法[/b]
ActionForward forward = new ActionForward(url);
forward.setRedirect(true);
return forward ;
注:url中若含有中文,需经过编码:URLEncoder.encode(url, "UTF-8")
[b]5.获得时间[/b]
Calendar calendar = Calendar.getInstance();
Timestamp ts = new Timestamp(System.currentTimeMillis());
calendar.setTime(ts);