<commit_before>(*
    Repwatcher
    Copyright (C) 2009  <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*)


open Lexing
open Format

let conf = ref None

(* localise l'erreur en indiquant la ligne
 et la colonne *)
let localisation (pos,e) config_file =
  let l = pos.pos_lnum in
  let c = pos.pos_cnum - pos.pos_bol + 1 in
  let lc = e.pos_cnum - pos.pos_bol + 1 in
  eprintf "Fichier \"%s\", ligne %d, caractère %d-%d:\n" config_file l c lc

let get () =
  match !conf with
    | None -> failwith "Failed to retrieve the configuration file"
    | Some c -> c

let parse config_file =
  let c = open_in config_file in
  let lb = Lexing.from_channel c in
    try
      conf := Some (Parser.deb Lexer.nexttoken lb) ;
      close_in c;
      get()
    with
      | Lexer.Lexing_error s -> 
	  localisation (lexeme_start_p lb, lexeme_end_p lb) config_file;
	  eprintf "lexical error in the configuration file repwatcher.conf: %s\n@." s;
	  exit 1
      | Parsing.Parse_error ->
	  localisation (lexeme_start_p lb, lexeme_end_p lb) config_file;
	  eprintf "syntax error in the configuration file repwatcher.conf\n@.";
	  exit 1
 
		  <commit_msg>Translate some french in english<commit_after>(*
    Repwatcher
    Copyright (C) 2009  <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*)


open Lexing
open Format

let conf = ref None;;

(* localize the error and give the line and column *)
let localization (pos,e) config_file =
  let l = pos.pos_lnum in
  let c = pos.pos_cnum - pos.pos_bol + 1 in
  let lc = e.pos_cnum - pos.pos_bol + 1 in
  eprintf "File \"%s\", line %d, character %d-%d:\n" config_file l c lc
;;

let get () =
  match !conf with
    | None -> failwith "Failed to retrieve the configuration file"
    | Some c -> c
;;

let parse config_file =
  let c = open_in config_file in
  let lb = Lexing.from_channel c in
    try
      conf := Some (Parser.deb Lexer.nexttoken lb) ;
      close_in c;
      get()
    with
      | Lexer.Lexing_error s -> 
	  localization (lexeme_start_p lb, lexeme_end_p lb) config_file;
	  eprintf "lexical error in the configuration file repwatcher.conf: %s\n@." s;
	  exit 1
      | Parsing.Parse_error ->
	  localization (lexeme_start_p lb, lexeme_end_p lb) config_file;
	  eprintf "syntax error in the configuration file repwatcher.conf\n@.";
	  exit 1
;; 
		  
{'fraction_non_alphanumeric': 0.07507082152974505, 'fraction_numerical': 0.0050991501416430595, 'mean_word_length': 2.985327313769752, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5966746', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1085, 'n_words': 462}