using System; using System.Web; using System.Web.UI; using System.Text.RegularExpressions; namespace STH.function { /// /// UbbCode 的摘要说明。 /// public class UbbCode { Root theroot=new Root(); HttpContext cOntext= HttpContext.Current; public UbbCode() { // // TODO: 在此处添加构造函数逻辑 // }
public String unhtml(string str) { str = context.Server.HtmlEncode(str); str = str.Replace("&","&"); return str; } public String turnit(string str) { Regex r; Match m; str = str.Replace("[","[|"); str = str.Replace("]","|]"); r = new Regex(@"(http|mms|rtsp|ftp|https)(:\/\/)"); for (m = r.Match(str); m.Success; m = m.NextMatch()) { str = str.Replace(m.Groups[0].ToString(), m.Groups[1].ToString() + "$"+m.Groups[2].ToString()); } return str; } public String turnof(string str) { Regex r; Match m; str = str.Replace("[|","["); str = str.Replace("|]","]"); r = new Regex(@"(http|mms|rtsp|ftp|https)(\$:\/\/)"); for (m = r.Match(str); m.Success; m = m.NextMatch()) { str = str.Replace(m.Groups[0].ToString(), m.Groups[1].ToString() + m.Groups[2].ToString().Replace("$","")); }
return str; }
public String UBB(string sDetail) { Regex r; Match m; sDetail = sDetail.Replace("[swf]","[swf=300,250]"); sDetail = sDetail.Replace("[rm]","[rm=300,250]"); sDetail = sDetail.Replace("[mp]","[mp=300,250]"); sDetail = unhtml(sDetail); sDetail = sDetail.Replace("\n"," "); //sDetail = sDetail.Replace(" "," "); //[code]标签 r = new Regex(@"(\[code\])([\s\S]+?)(\[\/code\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),""); } int i=1; r = new Regex(@"(\[html\])([\s\S]+?)(\[\/html\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { i=i+1; sDetail = sDetail.Replace(m.Groups[0].ToString()," [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行] "); //sDetail = sDetail.Replace(" ",""); } sDetail=turnhtm(sDetail); return turnof(sDetail); } public String turnhtm(string sDetail) { Regex r; Match m; //////////[b][/b] r = new Regex(@"(\[b\])([ \S\t]*?)(\[\/b\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + ""); } //////////////////////转换笑脸/////////////////////////// r = new Regex(@"(\[face=)([0-9]*)\]",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),""); }
r = new Regex(@"(\[i\])([ \S\t]*?)(\[\/i\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + ""); }
r = new Regex(@"(\[U\])([ \S\t]*?)(\[\/U\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),"" + m.Groups[2].ToString() + ""); }
//处[p][/p]标记 r = new Regex(@"((\r\n)*\[p\])(.+?)((\r\n)*\[\/p\])",RegexOptions.IgnoreCase|RegexOptions.Singleline); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),"
" + m.Groups[3].ToString() + "
"); }
//处[quote][/quote]标记 r = new Regex(@"(\[quote\])([\s\S]+?)(\[\/quote\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),"Quote:
" + m.Groups[2].ToString() + "
"); }
//处标记 r = new Regex(@"(\[url\])([ \S\t]*?)(\[\/url\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "" + m.Groups[2].ToString() + ""); }
//处[url=xxx][/url]标记 r = new Regex(@"(\[url=([ \S\t]+)\])([ \S\t]*?)(\[\/url\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "" + m.Groups[3].ToString() + ""); }
//处[email][/email]标记 r = new Regex(@"(\[email\])([ \S\t]*?)(\[\/email\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "" + m.Groups[2].ToString() + ""); } //处[down][/down]标记 r = new Regex(@"(\[down\])([ \S\t]*?)(\[\/down\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), ""); } //处[w][/w]标记 r = new Regex(@"(\[w\])([ \S\t]*?)(\[\/w\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), ""+m.Groups[2]+""); }
//处[email=xxx][/email]标记 r = new Regex(@"(\[email=([ \S\t]+)\])([ \S\t]*?)(\[\/email\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "" + m.Groups[3].ToString() + ""); }
//处[size=x][/size]标记 r = new Regex(@"(\[size=([1-7])\])([ \S\t]*?)(\[\/size\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "" + m.Groups[3].ToString() + ""); }
//处[color=x][/color]标记 r = new Regex(@"(\[color=([\S]+)\])([ \S\t]*?)(\[\/color\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "" + m.Groups[3].ToString() + ""); }
//处[fOnt=x][/font]标记 r = new Regex(@"(\[fOnt=(\w+)\])([ \S\t]*?)(\[\/font\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "" + m.Groups[3].ToString() + ""); }
//处理图片链接 r = new Regex(@"(\[img\])(.+?)(\[\/img\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { if(m.Groups[0].ToString().IndexOf("http://")>=0) { sDetail = sDetail.Replace(m.Groups[0].ToString(),"600) {this. Ondblclick=\"window.open('"+m.Groups[2].ToString()+"')\" title=\"双击在新窗口中打开\" />"); } else { sDetail = sDetail.Replace(m.Groups[0].ToString(),"600) {this. Ondblclick=\"window.open('"+m.Groups[2].ToString()+"')\" title=\"双击在新窗口中打开\" />"); } }
//处理
r = new Regex(@"(\[align=(\w+)\])([ \S\t]*?)(\[\/align\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(), "
" + m.Groups[3].ToString() + "
"); }
//处理[list=x][*][/list] r = new Regex(@"(\[list(=(A|a|I|i| ))?\]([ \S\t]*)\r\n)((\[\*\]([ \S\t]*\r\n))*?)(\[\/list\])",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { string strLI = m.Groups[5].ToString(); Regex rLI = new Regex(@"\[\*\]([ \S\t]*\r\n?)",RegexOptions.IgnoreCase); Match mLI; for (mLI = rLI.Match(strLI); mLI.Success; mLI = mLI.NextMatch()) { strLI = strLI.Replace(mLI.Groups[0].ToString(),"
r = new Regex(@"\[swf=([0-9]*),([0-9]*)\](.+?)\[\/swf\]",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),""); } r = new Regex(@"\[rm=([0-9]*),([0-9]*)\](.+?)\[\/rm\]",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString()," "); } r = new Regex(@"\[mp=([0-9]*),([0-9]*)\](.+?)\[\/mp\]",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),""); } /////////////处理链接
r = new Regex(@"([^>=""\?\'])((http|mms|rtsp|ftp|https):\/\/([A-Za-z0-9\.\/=\?%\-&_~`@':+!]+))",RegexOptions.IgnoreCase); for (m = r.Match(sDetail); m.Success; m = m.NextMatch()) { sDetail = sDetail.Replace(m.Groups[0].ToString(),m.Groups[1]+"" + m.Groups[2].ToString() + ""); }
本文介绍了阿里Treebased Deep Match(TDM)的学习笔记,同时回顾了工业界技术发展的几代演进。从基于统计的启发式规则方法到基于内积模型的向量检索方法,再到引入复杂深度学习模型的下一代匹配技术。文章详细解释了基于统计的启发式规则方法和基于内积模型的向量检索方法的原理和应用,并介绍了TDM的背景和优势。最后,文章提到了向量距离和基于向量聚类的索引结构对于加速匹配效率的作用。本文对于理解TDM的学习过程和了解匹配技术的发展具有重要意义。 ...
[详细]