相关疑难解决方法(0)

HTML Agility Pack strip标签不在白名单中

我正在尝试创建一个删除不在白名单中的html标签和属性的函数.我有以下HTML:

<b>first text </b>
<b>second text here
       <a>some text here</a>
 <a>some text here</a>

 </b>
<a>some twxt here</a>
Run Code Online (Sandbox Code Playgroud)

我正在使用HTML敏捷包,到目前为止我的代码是:

static List<string> WhiteNodeList = new List<string> { "b" };
static List<string> WhiteAttrList = new List<string> { };
static HtmlNode htmlNode;
public static void RemoveNotInWhiteList(out string _output, HtmlNode pNode, List<string> pWhiteList, List<string> attrWhiteList)
{

 // remove all attributes not on white list
 foreach (var item in pNode.ChildNodes)
 {
  item.Attributes.Where(u => attrWhiteList.Contains(u.Name) == false).ToList().ForEach(u => RemoveAttribute(u));

 }

 // remove all html and their innerText …
Run Code Online (Sandbox Code Playgroud)

c# tags sanitize html-parsing html-agility-pack

30
推荐指数
2
解决办法
2万
查看次数

模糊逻辑匹配

所以,我正在考虑在我的公司实现模糊逻辑匹配,并且无法获得良好的结果.对于初学者,我试图将公司名称与其他公司提供的名单上的名称相匹配.
我的第一次尝试是使用soundex,但看起来soundex只比较公司名称中的前几个声音,因此较长的公司名称太容易相互混淆.
我现在正在使用levenstein距离比较进行第二次尝试.它看起来很有希望,特别是如果我先删除标点符号.但是,我仍然无法在没有太多误报的情况下找到重复项.
我遇到的一个问题是像widgetsco vs widgets inc这样的公司.所以,如果我比较短名称长度的子串,我也会收到像BBC大学和CBC大学校园这样的东西.我怀疑使用距离和最长公共子串的组合得分可能是解决方案.
有没有人设法建立一个与有限误报匹配的算法?

sql t-sql sql-server string-matching sql-server-2012

5
推荐指数
1
解决办法
609
查看次数