<commit_before>%%%-------------------------------------------------------------------
%%% File    : gperfGtk.erl
%%% Author  : <NAME> <<EMAIL>>
%%% Description : 
%%%
%%% Created : 12 Sep 2005 by <NAME> <<EMAIL>>
%%%-------------------------------------------------------------------
-module(gperfGtk).

-export([start/0,stop/0,init/0]).
-export([loop/1]).				%internal export

-import(lists,[foreach/2,flatten/1,keysearch/3,nth/2,reverse/1,seq/2,sort/1]).
-import(orddict,[new/0,store/3,is_key/2,fold/3,update/3,fetch/2,from_list/1]).

-include("log.hrl").

-define(LP(X), ?MODULE:loop(X)).
-define(MARG,10).
-define(XSIZE,6000).
-define(YSIZE,100).
-define(WXSIZE,200).
-define(WYSIZE,?YSIZE).
-define(XHALF,(?XSIZE div 2)).
-define(DAREAS, [{drawingarea1,[blue,red,green,magenta]},
		 {drawingarea2,[black,blue,red,yellow]},
		 {drawingarea3,[red,green]}]).

-record(dArea, {win,px_fg,px_bg,gc_fg,gc_bg,gcs,layout}).
-record(conf, {widget, val, type}).
-record(ld, {conf=conf(),minute,x=?XHALF,dAreas=[],state=disc,stat_ctxt}).

-type orddict(X,Y) :: [{X,Y}].
-type tag_vals() :: orddict(atom(),any()).
-type confs() :: orddict(atom(),#conf{}).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start() -> spawn(fun init/0).
stop() -> catch (gperf ! quit),quit.

init() ->
  register(gperf,self()),
  gtknode:start(gperf_gtk),
  g('GN_glade_init',[glade_file()]),
  maybe_show(),
  try loop(do_init(#ld{}))
  catch
    _:dying -> ok;
    _:R -> ?log([{error,R},{stack,erlang:get_stacktrace()}])
  end.

glade_file() -> 
  filename:join([code:priv_dir(eper),"glade","gperf.glade"]).<commit_msg>better glade file detection<commit_after>%%%-------------------------------------------------------------------
%%% File    : gperfGtk.erl
%%% Author  : <NAME> <<EMAIL>>
%%% Description : 
%%%
%%% Created : 12 Sep 2005 by <NAME> <<EMAIL>>
%%%-------------------------------------------------------------------
-module(gperfGtk).

-export([start/0,stop/0,init/0]).
-export([loop/1]).				%internal export

-import(lists,[foreach/2,flatten/1,keysearch/3,nth/2,reverse/1,seq/2,sort/1]).
-import(orddict,[new/0,store/3,is_key/2,fold/3,update/3,fetch/2,from_list/1]).

-include("log.hrl").

-define(LP(X), ?MODULE:loop(X)).
-define(MARG,10).
-define(XSIZE,6000).
-define(YSIZE,100).
-define(WXSIZE,200).
-define(WYSIZE,?YSIZE).
-define(XHALF,(?XSIZE div 2)).
-define(DAREAS, [{drawingarea1,[blue,red,green,magenta]},
		 {drawingarea2,[black,blue,red,yellow]},
		 {drawingarea3,[red,green]}]).

-record(dArea, {win,px_fg,px_bg,gc_fg,gc_bg,gcs,layout}).
-record(conf, {widget, val, type}).
-record(ld, {conf=conf(),minute,x=?XHALF,dAreas=[],state=disc,stat_ctxt}).

-type orddict(X,Y) :: [{X,Y}].
-type tag_vals() :: orddict(atom(),any()).
-type confs() :: orddict(atom(),#conf{}).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start() -> spawn(fun init/0).
stop() -> catch (gperf ! quit),quit.

init() ->
  register(gperf,self()),
  gtknode:start(gperf_gtk),
  g('GN_glade_init',[glade_file("gperf.glade")]),
  maybe_show(),
  try loop(do_init(#ld{}))
  catch
    _:dying -> ok;
    _:R -> ?log([{error,R},{stack,erlang:get_stacktrace()}])
  end.

glade_file(Glade) -> 
  try take_first(
        fun(F) -> true = filelib:is_regular(F) end,
        [filename:join([code:lib_dir(eper),"src",Glade])
         , filename:join([code:priv_dir(eper),"glade",Glade])])
  catch _:_ -> exit({not_found,Glade})
  end.

take_first(F,[H|T]) -> 
  try F(H),H 
  catch _:_ -> take_first(F,T)
  end.
{'fraction_non_alphanumeric': 0.33975084937712347, 'fraction_numerical': 0.0232163080407701, 'mean_word_length': 3.60625814863103, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, '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': '3989122', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1357, 'n_words': 168}