瀏覽代碼

ft: replaceSw函数的实现 todo: replaceSw函数的优化 敏感词去除特殊字符

master
SisMaker 4 年之前
父節點
當前提交
b6316d46d5
共有 3 個檔案被更改,包括 7 行新增6 行删除
  1. +3
    -1
      rebar.config
  2. +2
    -3
      src/eAcs.erl
  3. +2
    -2
      src/test/acTest.erl

+ 3
- 1
rebar.config 查看文件

@ -1,5 +1,7 @@
{erl_opts, [no_debug_info]}.
{deps, []}.
{deps,[
{eSync, {git, "http://192.168.0.88:53000/SisMaker/eSync.git", {branch, "master"}}}
]}.
%% escript

+ 2
- 3
src/eAcs.erl 查看文件

@ -136,14 +136,13 @@ getOutputIs(State) ->
replaceSw(BinStr) ->
TotalSize = byte_size(BinStr),
MatchBIMWs = doMatchRs(BinStr, TotalSize - 1, _Index = 1, _State = 0, _MatchList = []),
io:format("IMY******************* ~p~n", [lists:reverse(MatchBIMWs)]),
doReplaceSw(lists:reverse(MatchBIMWs), BinStr, TotalSize, _StartPos = 0, <<>>).
%%
doReplaceSw([], BinStr, TotalSize, StartPos, BinAcc) ->
case TotalSize > StartPos of
true ->
<<BinAcc/binary, (binary:part(BinStr, StartPos, TotalSize - StartPos))/binary>>;
<<BinAcc/binary, (binary:part(BinStr, StartPos, TotalSize - StartPos))/binary>>;
_ ->
BinAcc
end;
@ -173,7 +172,7 @@ getMatchWords(MatchWordCnt, BinStr, ByteIndex, BslCnt, Utf8Code, FilterWs) ->
%%
getMatchWords(MatchWordCnt - 1, BinStr, ByteIndex - 1, 0, 0, [?RW | FilterWs])
end;
Byte band 128 == 128 ->
Byte bsr 6 == 2 ->
Code = Byte band 63,
getMatchWords(MatchWordCnt, BinStr, ByteIndex - 1, BslCnt + 6, Code bsl BslCnt + Utf8Code, FilterWs);
true ->

+ 2
- 2
src/test/acTest.erl 查看文件

@ -7,7 +7,7 @@
test1() ->
acTc:ts(1000000, acsTree, goto, [63870]).
test2() ->
test20() ->
acTc:ts(1000000, eAcs, matchSw, [<<"fdsfads拉法叶舰fds淫秽ffdsfdsffdddd"/utf8>>]).
test21() ->
@ -20,7 +20,7 @@ test3(Cnt, BinStr) ->
acTc:ts(Cnt, eAcs, matchSw, [BinStr]).
test31(Cnt, BinStr) ->
acTc:ts(Cnt, keyword, filter, [BinStr]).
acTc:ts(Cnt, eAcs, replaceSw, [BinStr]).
test4(Cnt, FileName) ->
{ok, Data} = file:read_file(FileName),

Loading…
取消
儲存