Ver a proveniência

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

master
SisMaker há 4 anos
ascendente
cometimento
b6316d46d5
3 ficheiros alterados com 7 adições e 6 eliminações
  1. +3
    -1
      rebar.config
  2. +2
    -3
      src/eAcs.erl
  3. +2
    -2
      src/test/acTest.erl

+ 3
- 1
rebar.config Ver ficheiro

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

+ 2
- 3
src/eAcs.erl Ver ficheiro

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

+ 2
- 2
src/test/acTest.erl Ver ficheiro

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

Carregando…
Cancelar
Guardar