<commit_before>-module(autoinc).

-export([init/0, init/1, next/1, loop/1]).

loop(Id) ->
    receive
        {FromPid, next} ->
            FromPid ! Id,
            ?MODULE:loop(Id + 1)
    end.

init() ->
    %% spawn(fun() -> loop(1) end).
    spawn(?MODULE, loop, [1]).

init(Name) ->
    case whereis(Name) of
        undefined ->
            Pid = spawn(fun() -> loop(1) end),
            register(Name, Pid);
        _Pid -> ok
    end.

next(Pid) ->
    Pid ! {self(), next},
    receive Resp -> Resp
    after 5000 -> error
    end.<commit_msg>Minor cleanup in autoinc snippet<commit_after>-module(autoinc).

-compile([]).

-export([init/0, init/1, next/1, loop/1]).


loop(Id) ->
    receive
        {FromPid, next} ->
            FromPid ! {id, Id},
            loop(Id + 1);
        quit -> ok
    end.

init() ->
    spawn(?MODULE, loop, [1]).

init(Name) ->
    case whereis(Name) of
        undefined ->
            Pid = spawn(?MODULE, loop, [1]),
            register(Name, Pid);
        _Pid -> ok
    end.

next(Pid) ->
    Pid ! {self(), next},
    receive {id, Id} -> Id
    after 5000 -> error
    end.
{'fraction_non_alphanumeric': 0.18044444444444444, 'fraction_numerical': 0.020444444444444446, 'mean_word_length': 1.7132530120481928, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6686122', 'n_tokens_mistral': 419, 'n_tokens_neox': 400, 'n_words': 97}