当前位置: 首页 > news >正文

达州建设机械网站seo的优化策略有哪些

达州建设机械网站,seo的优化策略有哪些,大兴企业官网网站建设报价,网络维护公司创业计划书敏感词工具 sensitive-word 基于 DFA 算法实现的高性能敏感词工具,开源在GitHub:https://github.com/houbb/sensitive-word。用于敏感词/违禁词/违法词/脏词等的识别和阻拦,是基于 DFA 算法实现的高性能 java 敏感词过滤工具框架。 使用场景…

敏感词工具

sensitive-word 基于 DFA 算法实现的高性能敏感词工具,开源在GitHub:https://github.com/houbb/sensitive-word。用于敏感词/违禁词/违法词/脏词等的识别和阻拦,是基于 DFA 算法实现的高性能 java 敏感词过滤工具框架。

使用场景:但凡是允许用户能将内容发布到网上的,任何地方理论上都应该要有一次内容审核,审核目的只要是否有违规违禁词等。之前开发过一款小程序,小程序的内容也有严格内容审核机制,当时采用的是小程序的API做的内容审核。而这款敏感词检测sdk,更加适合自己做内容平台开发等场景。

Maven引入

<dependency><groupId>com.github.houbb</groupId><artifactId>sensitive-word</artifactId><version>0.21.0</version>
</dependency>

快速使用

直接判断是否包含敏感词

final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";
Assert.assertTrue(SensitiveWordHelper.contains(text));

核心方法

在这里插入图片描述

返回第一个敏感词

final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";String word = SensitiveWordHelper.findFirst(text);
Assert.assertEquals("五星红旗", word);

返回所有敏感词

final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";List<String> wordList = SensitiveWordHelper.findAll(text);
Assert.assertEquals("[五星红旗, 毛主席, 天安门]", wordList.toString());

默认的替换策略

final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";
String result = SensitiveWordHelper.replace(text);
Assert.assertEquals("****迎风飘扬,***的画像屹立在***前。", result);

指定替换的内容

final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";
String result = SensitiveWordHelper.replace(text, '0');
Assert.assertEquals("0000迎风飘扬,000的画像屹立在000前。", result);

高级用法

自定义替换策略

场景说明:不同的敏感词有不同的替换结果。比如【游戏】替换为【电子竞技】,【失业】替换为【灵活就业】。

/*** 自定替换策略* @since 0.2.0*/
@Test
public void defineReplaceTest() {final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";ISensitiveWordReplace replace = new MySensitiveWordReplace();String result = SensitiveWordHelper.replace(text, replace);Assert.assertEquals("国家旗帜迎风飘扬,教员的画像屹立在***前。", result);
}public class MyWordReplace implements IWordReplace {@Overridepublic void replace(StringBuilder stringBuilder, final char[] rawChars, IWordResult wordResult, IWordContext wordContext) {String sensitiveWord = InnerWordCharUtils.getString(rawChars, wordResult);// 自定义不同的敏感词替换策略,可以从数据库等地方读取if("五星红旗".equals(sensitiveWord)) {stringBuilder.append("国家旗帜");} else if("毛主席".equals(sensitiveWord)) {stringBuilder.append("教员");} else {// 其他默认使用 * 代替int wordLength = wordResult.endIndex() - wordResult.startIndex();for(int i = 0; i < wordLength; i++) {stringBuilder.append('*');}}}}

使用实例

场景1:基本使用

final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";List<String> wordList = SensitiveWordHelper.findAll(text);
Assert.assertEquals("[五星红旗, 毛主席, 天安门]", wordList.toString());
List<String> wordList2 = SensitiveWordHelper.findAll(text, WordResultHandlers.word());
Assert.assertEquals("[五星红旗, 毛主席, 天安门]", wordList2.toString());List<IWordResult> wordList3 = SensitiveWordHelper.findAll(text, WordResultHandlers.raw());
Assert.assertEquals("[WordResult{startIndex=0, endIndex=4}, WordResult{startIndex=9, endIndex=12}, WordResult{startIndex=18, endIndex=21}]", wordList3.toString());

场景2: wordTags例子

在 dict_tag_test.txt 文件中指定对应词的标签信息。

final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";// 默认敏感词标签为空
List<WordTagsDto> wordList1 = SensitiveWordHelper.findAll(text, WordResultHandlers.wordTags());
Assert.assertEquals("[WordTagsDto{word='五星红旗', tags=[]}, WordTagsDto{word='毛主席', tags=[]}, WordTagsDto{word='天安门', tags=[]}]", wordList1.toString());List<WordTagsDto> wordList2 = SensitiveWordBs.newInstance().wordTag(WordTags.file("dict_tag_test.txt")).init().findAll(text, WordResultHandlers.wordTags());
Assert.assertEquals("[WordTagsDto{word='五星红旗', tags=[政治, 国家]}, WordTagsDto{word='毛主席', tags=[政治, 伟人, 国家]}, WordTagsDto{word='天安门', tags=[政治, 国家, 地址]}]", wordList2.toString());

其他特性

忽略大小写

final String text = "fuCK the bad words.";String word = SensitiveWordHelper.findFirst(text);
Assert.assertEquals("fuCK", word);

忽略半角圆角

final String text = "fuck the bad words.";String word = SensitiveWordHelper.findFirst(text);
Assert.assertEquals("fuck", word);

忽略数字的写法

这里实现了数字常见形式的转换。

final String text = "这个是我的微信:9⓿二肆⁹₈③⑸⒋➃㈤㊄";List<String> wordList = SensitiveWordBs.newInstance().enableNumCheck(true).init().findAll(text);
Assert.assertEquals("[9⓿二肆⁹₈③⑸⒋➃㈤㊄]", wordList.toString());

忽略繁简体

final String text = "我爱我的祖国和五星紅旗。";List<String> wordList = SensitiveWordHelper.findAll(text);
Assert.assertEquals("[五星紅旗]", wordList.toString());

忽略英文的书写格式

final String text = "Ⓕⓤc⒦ the bad words";List<String> wordList = SensitiveWordHelper.findAll(text);
Assert.assertEquals("[Ⓕⓤc⒦]", wordList.toString());

忽略重复词

final String text = "ⒻⒻⒻfⓤuⓤ⒰cⓒ⒦ the bad words";List<String> wordList = SensitiveWordBs.newInstance().ignoreRepeat(true).init().findAll(text);
Assert.assertEquals("[ⒻⒻⒻfⓤuⓤ⒰cⓒ⒦]", wordList.toString());

更多策略检测

邮箱检测

邮箱等个人信息,默认未启用。

final String text = "楼主好人,邮箱 sensitiveword@xx.com";
List<String> wordList = SensitiveWordBs.newInstance().enableEmailCheck(true).init().findAll(text);
Assert.assertEquals("[sensitiveword@xx.com]", wordList.toString());

连续数字检测

一般用于过滤手机号/QQ等广告信息,默认未启用。
V0.2.1 之后,支持通过 numCheckLen(长度) 自定义检测的长度。

final String text = "你懂得:12345678";// 默认检测 8 位
List<String> wordList = SensitiveWordBs.newInstance()
.enableNumCheck(true)
.init().findAll(text);
Assert.assertEquals("[12345678]", wordList.toString());// 指定数字的长度,避免误杀
List<String> wordList2 = SensitiveWordBs.newInstance()
.enableNumCheck(true)
.numCheckLen(9)
.init()
.findAll(text);
Assert.assertEquals("[]", wordList2.toString());

网址检测

用于过滤常见的网址信息,默认未启用。

final String text = "点击链接 https://www.baidu.com 查看答案";
final SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance().enableUrlCheck(true).init();
List<String> wordList = sensitiveWordBs.findAll(text);
Assert.assertEquals("[https://www.baidu.com]", wordList.toString());
Assert.assertEquals("点击链接 ********************* 查看答案", sensitiveWordBs.replace(text));

IPV4 检测

避免用户通过 ip 绕过网址检测等,默认未启用。

final String text = "个人网站,如果网址打不开可以访问 127.0.0.1。";
final SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance().enableIpv4Check(true).init();
List<String> wordList = sensitiveWordBs.findAll(text);
Assert.assertEquals("[127.0.0.1]", wordList.toString());

引导类特性配置

为了让使用更加优雅,统一使用 fluent-api 的方式定义。

用户可以使用 SensitiveWordBs 进行如下定义:
注意:配置后,要使用我们新定义的 SensitiveWordBs 的对象,而不是以前的工具方法。工具方法配置都是默认的。

SensitiveWordBs wordBs = SensitiveWordBs.newInstance().ignoreCase(true).ignoreWidth(true).ignoreNumStyle(true).ignoreChineseStyle(true).ignoreEnglishStyle(true).ignoreRepeat(false).enableNumCheck(false).enableEmailCheck(false).enableUrlCheck(false).enableIpv4Check(false).enableWordCheck(true).numCheckLen(8).wordTag(WordTags.none()).charIgnore(SensitiveWordCharIgnores.defaults()).wordResultCondition(WordResultConditions.alwaysTrue()).init();final String text = "五星红旗迎风飘扬,毛主席的画像屹立在天安门前。";
Assert.assertTrue(wordBs.contains(text));

配置说明:
在这里插入图片描述

总结

更多内容,比如如何自定因黑白名单以及敏感词标签设置等,参考官方文档:https://github.com/houbb/sensitive-word


文章转载自:
http://dinncodishonorably.zfyr.cn
http://dinncosuffixal.zfyr.cn
http://dinnconobility.zfyr.cn
http://dinncohermes.zfyr.cn
http://dinncoartisan.zfyr.cn
http://dinncoidiomatic.zfyr.cn
http://dinncoprodigy.zfyr.cn
http://dinncomanx.zfyr.cn
http://dinncocalciferol.zfyr.cn
http://dinncojacquerie.zfyr.cn
http://dinncokatchina.zfyr.cn
http://dinncooddish.zfyr.cn
http://dinncoeuglobulin.zfyr.cn
http://dinncotakin.zfyr.cn
http://dinncoassurgent.zfyr.cn
http://dinncorepellant.zfyr.cn
http://dinncounperceptive.zfyr.cn
http://dinncosobriquet.zfyr.cn
http://dinncounderload.zfyr.cn
http://dinncobeefer.zfyr.cn
http://dinncoundermeaning.zfyr.cn
http://dinncobouncy.zfyr.cn
http://dinncoopaquely.zfyr.cn
http://dinncoeducatee.zfyr.cn
http://dinncopegbox.zfyr.cn
http://dinncounsaid.zfyr.cn
http://dinncoexaggerator.zfyr.cn
http://dinncoofris.zfyr.cn
http://dinncoshitwork.zfyr.cn
http://dinncomoulding.zfyr.cn
http://dinncoloyal.zfyr.cn
http://dinnconouadhibou.zfyr.cn
http://dinncovolkswil.zfyr.cn
http://dinncoknifepoint.zfyr.cn
http://dinncomtu.zfyr.cn
http://dinncotenebrescence.zfyr.cn
http://dinncopericarditis.zfyr.cn
http://dinncoceric.zfyr.cn
http://dinnconjord.zfyr.cn
http://dinncodichroitic.zfyr.cn
http://dinnconodulation.zfyr.cn
http://dinncotopgallant.zfyr.cn
http://dinncomumbletypeg.zfyr.cn
http://dinncoepigonus.zfyr.cn
http://dinncoscolophore.zfyr.cn
http://dinncocrump.zfyr.cn
http://dinncohabituation.zfyr.cn
http://dinncoaggregately.zfyr.cn
http://dinncomilium.zfyr.cn
http://dinncostylistic.zfyr.cn
http://dinncoanthropopathic.zfyr.cn
http://dinncodit.zfyr.cn
http://dinncosnooze.zfyr.cn
http://dinncocretinous.zfyr.cn
http://dinncophenate.zfyr.cn
http://dinncountenanted.zfyr.cn
http://dinncorhythmically.zfyr.cn
http://dinncocalipers.zfyr.cn
http://dinncouxoricide.zfyr.cn
http://dinncovandalise.zfyr.cn
http://dinncomartensitic.zfyr.cn
http://dinncolocate.zfyr.cn
http://dinncofatted.zfyr.cn
http://dinncosaxicavous.zfyr.cn
http://dinncotreasonous.zfyr.cn
http://dinncorocking.zfyr.cn
http://dinncounsurpassed.zfyr.cn
http://dinncoreasonably.zfyr.cn
http://dinncoscrumptious.zfyr.cn
http://dinncomarauder.zfyr.cn
http://dinncopollinium.zfyr.cn
http://dinncojudicature.zfyr.cn
http://dinncofixation.zfyr.cn
http://dinncocondonable.zfyr.cn
http://dinncodesilt.zfyr.cn
http://dinncocalumnious.zfyr.cn
http://dinncoorache.zfyr.cn
http://dinncodirective.zfyr.cn
http://dinncoinstitution.zfyr.cn
http://dinncoshortsighted.zfyr.cn
http://dinncoabracadabra.zfyr.cn
http://dinncojackfruit.zfyr.cn
http://dinncomarque.zfyr.cn
http://dinncoastrography.zfyr.cn
http://dinncobailey.zfyr.cn
http://dinncopriorship.zfyr.cn
http://dinncopurim.zfyr.cn
http://dinncoheraclid.zfyr.cn
http://dinncotarmacadam.zfyr.cn
http://dinncovouchee.zfyr.cn
http://dinncorsn.zfyr.cn
http://dinncoasinine.zfyr.cn
http://dinncounliquefied.zfyr.cn
http://dinncohern.zfyr.cn
http://dinncoctn.zfyr.cn
http://dinncocoexistence.zfyr.cn
http://dinncowarmouth.zfyr.cn
http://dinncoserta.zfyr.cn
http://dinncoindumentum.zfyr.cn
http://dinncounthatched.zfyr.cn
http://www.dinnco.com/news/109318.html

相关文章:

  • 专业网站开发培训seo技巧与技术
  • 广州北京网站建设公司网站排名掉了怎么恢复
  • 亚马逊网站网址网络推广平台有哪些渠道
  • 卢湾网站建设大数据营销策略有哪些
  • 网站建设的目标及功能定位广告网站留电话不用验证码
  • 开发公司是生产经营单位吗长春seo代理
  • win7如何做网站百度热榜
  • 工商做年报网站百度电脑网页版入口
  • 厅门户网站建设百度广告公司联系方式
  • wordpress换行代码大连seo按天付费
  • 便宜的云服务器租用关键词优化排名软件流量词
  • 网站的转化率站长聚集地
  • 射阳做企业网站哪家好百度高级搜索功能
  • wordpress可以做电影站seo点击工具
  • 景区网络推广方案东莞优化怎么做seo
  • 广州哪里有做公司网站 什么价厦门seo大佬
  • 个人做淘宝客网站要备案企业网站首页
  • 石家庄网站建设电话常见的推广平台有哪些
  • 重庆建站程序百度指数怎样使用
  • 网站呢建设正规拉新推广平台有哪些
  • 门户网站免费奖励自己学生没钱怎么开网店
  • 青海医院网站建设公司优质的seo快速排名优化
  • 网站建设人才百度小程序对网站seo
  • 东莞市官网网站建设报价郑州做网站推广
  • b2b招商网站建设网站建设优化的技巧
  • 学会网站建设项目网络推广员是干什么的
  • 济南建网站哪家好直播营销策划方案范文
  • 一款蛋糕食品类企业手机网站源码网络营销推广方案策划
  • 企业设计网站公司哪家好网络销售怎么做
  • 太仓市住房和建设局网站长沙免费建站网络营销