<commit_before>#!/usr/bin/env escript
%% -*- erlang -*-
%% %%! -smp enable -sname factorial -mnesia debug verbose
main(Args)->
    GenerateBeamFilename = fun(Filename) ->
      lists:concat([Filename, ".beam"])
    end,

    WriteBeamFile = fun(BeamFilename, BeamCode) ->
      escript:create(BeamFilename, [{beam, BeamCode}])
    end,

    WriteDissFile = fun(BeamFilename) ->
      {ok,F}=file:open(BeamFilename++".dmp",[write]),
      io:format(F,"~p.~n",[beam_disasm:file(BeamFilename)]),
      file:close(F)
    end,

    Diss = fun({ok, Filename, BeamCode}) ->
        BeamFilename = GenerateBeamFilename(Filename),
        WriteBeamFile(BeamFilename, BeamCode),
        WriteDissFile(BeamFilename);
        (error) -> io:format("~p~n", ["Error"])
    end,

    Run = fun(Filename, Source) ->
      % create source file
      file:write_file(Filename, [Source]),

      % compile erl
      case compile:file(Filename, [binary, debug_info]) of
        % second arg is module name
        {ok, _, BeamCode} -> Diss({ok, Filename, BeamCode});
        error -> Diss(error)
      end
    end,
    Filename = lists:nth(1, Args),
    Source = lists:nth(2, Args),
    Run(Filename, Source).<commit_msg>added ability to output success<commit_after>#!/usr/bin/env escript
%% -*- erlang -*-
%% %%! -smp enable -sname factorial -mnesia debug verbose
main(Args)->
    DecodeData = fun(Data) ->
      case unicode:characters_to_list(Data) of
        {incomplete, _, _} -> error;
        {error, _, _} -> error;
        List -> List
      end
    end,

    Readlines = fun(Filename) ->
      case file:read_file(Filename) of
        {ok, Data} -> DecodeData(Data);
        {error, _} -> error
      end
    end,

    GenerateBeamFilename = fun(Filename) ->
      lists:concat([Filename, ".beam"])
    end,

    WriteBeamFile = fun(BeamFilename, BeamCode) ->
      escript:create(BeamFilename, [{beam, BeamCode}])
    end,

    WriteDissFile = fun(BeamFilename) ->
      DissFilename = lists:concat([BeamFilename, ".dmp"]),
      {ok,F}=file:open(DissFilename, [write]),
      io:format(F,"~p.~n",[beam_disasm:file(BeamFilename)]),
      file:close(F),
      DissFilename
    end,

    Diss = fun({ok, Filename, BeamCode}) ->
        BeamFilename = GenerateBeamFilename(Filename),
        WriteBeamFile(BeamFilename, BeamCode),
        DissFilename = WriteDissFile(BeamFilename),
        case Readlines(DissFilename) of
          {ok, Data} -> Data;
          error -> error
        end;
        (error) -> error
    end,

    Run = fun(Filename, Source) ->
      % create source file
      file:write_file(Filename, [Source]),

      % compile erl
      Output = case compile:file(Filename, [binary, debug_info]) of
        % second arg is module name
        {ok, _, BeamCode} -> Diss({ok, Filename, BeamCode});
        error -> Diss(error)
      end,
      io:format("~p~n", [Output])
    end,
    Filename = lists:nth(1, Args),
    Source = lists:nth(2, Args),
    Run(Filename, Source).
{'fraction_non_alphanumeric': 0.15229788661522978, 'fraction_numerical': 0.0013418316001341832, 'mean_word_length': 2.6860321384425214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '4391864', 'n_tokens_mistral': 1007, 'n_tokens_neox': 980, 'n_words': 203}