<commit_before>#!/usr/bin/env escript

value(null) -> null;
value(String) ->
    S = string:concat(String, "."),
    io:format("~s~n", [S]),
    {ok,Tokens,_} = erl_scan:string(S),
    io:format("~w~n", [Tokens]),
    % filter pids : {'<',1},{float,1,7765.625},{'.',1},{integer,1,0},{'>',1},{',',1}
    
    io:format("~w~n", [Tokens]),
    {ok,Term} = erl_parse:parse_term(Tokens),
    io:format("~w~n", [Term]),
    Term.

%% How to handle the "Attempting to restart script through sudo -u riak" line?
objects(["Attempting to restart script through sudo -u riak"|T]) ->
    objects(T);
objects(StringList) ->
    object_acc(StringList, {null, null}, []).
    
object_acc([H|T], {Name, Value}, Objects) ->
    %io:format("~s~n", [H]),
    case string:chr(H, $:) of
        0 -> object_acc(T, {Name, string:concat(Value, string:strip(H))}, Objects);
        Index -> {NewName, NewValue} = lists:split(Index, H),
            object_acc(T, {NewName, string:strip(NewValue)}, [{Name, value(Value)}|Objects])
    end;
object_acc([], Current, Objects) ->
    [Current|Objects].
    
main(_) ->
    Status = objects(string:tokens(os:cmd("riak-repl status"), "\n")),
    io:format("~w~n", [Status]).
    
    %% each line that has a (:), parse value following the colon, until the next line with a colon, or end.
    <commit_msg>riak repl parsing success<commit_after>#!/usr/bin/env escript

value(null) -> null;
value(String) ->
    io:format("~s~n", [String]),
    S = string:concat(re:replace(String, "<[^>]*>", "\"&\"", [global, {return, list}]), "."),
    io:format("~s~n", [S]),
    {ok,Tokens,_} = erl_scan:string(S),
    {ok,Term} = erl_parse:parse_term(Tokens),
    io:format("~p~n", [Term]),
    Term.

%% How to handle the "Attempting to restart script through sudo -u riak" line?
objects(["Attempting to restart script through sudo -u riak"|T]) ->
    objects(T);
objects(StringList) ->
    object_acc(StringList, {null, null}, []).
    
object_acc([H|T], {Name, Value}, Objects) ->
    %io:format("~s~n", [H]),
    case string:chr(H, $:) of
        0 -> object_acc(T, {Name, string:concat(Value, string:strip(H))}, Objects);
        Index -> {NewName, NewValue} = lists:split(Index, H),
            object_acc(T, {string:sub_string(NewName, 1, string:len(NewName)-1), string:strip(NewValue)}, [{Name, value(Value)}|Objects])
    end;
object_acc([], {Name, Value}, Objects) ->
    [{Name, value(Value)}|Objects].
    
main(_) ->
    Status = objects(string:tokens(os:cmd("riak-repl status"), "\n")),
    io:format("~p~n", [Status]).
    
    %% each line that has a (:), parse value following the colon, until the next line with a colon, or end.
    
{'fraction_non_alphanumeric': 0.21694915254237288, 'fraction_numerical': 0.006779661016949152, 'mean_word_length': 3.846715328467153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4358740', 'n_tokens_mistral': 979, 'n_tokens_neox': 951, 'n_words': 215}