소스 검색

ft: 完善函数

master
SisMaker 4 년 전
부모
커밋
df3694b5e7
2개의 변경된 파일20개의 추가작업 그리고 2개의 파일을 삭제
  1. +1
    -0
      README.md
  2. +19
    -2
      src/eAcs.erl

+ 1
- 0
README.md 파일 보기

@ -19,6 +19,7 @@ Uses
eAcs:matchSw/1 %% 返回匹配的敏感词列表
eAcs:isHasSw/1 %% 检查是否包含敏感词
eAcs:replaceSw/1 %% 替换敏感词
isHasRpSw/1 %% 检测并替换敏感词
性能
-----

+ 19
- 2
src/eAcs.erl 파일 보기

@ -4,6 +4,7 @@
matchSw/1 %%
, isHasSw/1 %%
, replaceSw/1 %%
, isHasRpSw/1 %%
, strSize/2 %% utf8字符串的长度
]).
@ -128,10 +129,26 @@ getOutputIs(State) ->
end.
%% *************************************** matchSw end ***************************************************************
%% *************************************** replaceSw start *************************************************************
-spec replaceSw(BinStr :: binary()) -> ReBinStr :: binary().
replaceSw(BinStr) ->
TotalSize = byte_size(BinStr),
MatchBIMWs = doMatchRs(BinStr, TotalSize - 1, _Index = 1, _State = 0, _MatchList = []),
doReplaceSw(lists:reverse(MatchBIMWs), BinStr, TotalSize, _StartPos = 0, <<>>).
case doMatchRs(BinStr, TotalSize - 1, _Index = 1, _State = 0, _MatchList = []) of
[] ->
BinStr;
MatchBIMWs ->
doReplaceSw(lists:reverse(MatchBIMWs), BinStr, TotalSize, _StartPos = 0, <<>>)
end.
-spec isHasRpSw(BinStr :: binary()) -> {IsHasSw :: boolean(), ReBinStr :: binary()}.
isHasRpSw(BinStr) ->
TotalSize = byte_size(BinStr),
case doMatchRs(BinStr, TotalSize - 1, _Index = 1, _State = 0, _MatchList = []) of
[] ->
{false, BinStr};
MatchBIMWs ->
ReBinStr = doReplaceSw(lists:reverse(MatchBIMWs), BinStr, TotalSize, _StartPos = 0, <<>>),
{true, ReBinStr}
end.
doReplaceSw([], BinStr, TotalSize, StartPos, BinAcc) ->
case TotalSize > StartPos of

불러오는 중...
취소
저장