文案檢測工具,敏感詞檢測

 2023-12-25 阅读 31 评论 0

摘要:?傳送門https://github.com/ccppluagopy/SensitiveWord-Lua 轉這個位置已經寫的很棒了,然后稍微修改一下,改用小寫來檢測,原文替換保留大寫的原文 function MsgParser:getString(s)if type(s) ~= 'string' then return endlocal i = 1lo

?傳送門https://github.com/ccppluagopy/SensitiveWord-Lua

轉這個位置已經寫的很棒了,然后稍微修改一下,改用小寫來檢測,原文替換保留大寫的原文

function MsgParser:getString(s)if type(s) ~= 'string' then return endlocal i = 1local len = strLen(s)local word, idx, tmpslocal returnStr = s;s = string.lower(s);while true doword = strSub(s, i)idx = _detect(_tree, word, i)if idx thentmps = strSub(s, 1, i-1)for j=1, idx-i+1 dotmps = tmps .. _maskWordends = tmps .. strSub(s, idx+1)tmps1 = strSub(returnStr, 1, i-1)for j=1, idx-i+1 dotmps1 = tmps1 .. _maskWordendreturnStr = tmps1 .. strSub(returnStr, idx+1)i = idx+1elsei = i + 1endif i > len thenbreakendendreturn returnStr
end

  這樣我們使用就已經ok了

轉載于:https://www.cnblogs.com/wility/p/8567102.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/196430.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息