<commit_before>(**************************************************************************)
(*  Copyright (c) 2015 <NAME> <<EMAIL>>      *)
(*                                                                        *)
(*  Permission to use, copy, modify, and distribute this software for any  *)
(*  purpose with or without fee is hereby granted, provided that the above  *)
(*  copyright notice and this permission notice appear in all copies.     *)
(*                                                                        *)
(*  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES  *)
(*  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF      *)
(*  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  *)
(*  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES  *)
(*  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN  *)
(*  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  *)
(*  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.        *)
(*                                                                        *)
(**************************************************************************)

open Ast ;;
open Format ;;

module H = Hashtbl ;;

exception Found of symbol ;;

let pick_one h =
  try Hashtbl.iter (fun _ v -> raise (Found v)) h;
      assert false; (* Should not get here *)
  with Found v -> v
;;

let add_sorted_symbol, _find_sorted_symbol, find_symbol =
  let h = Hashtbl.create 97 in
  let n = ref (-1) in
  let base = "S" in
  (fun symbol sort ->
   incr n;
   let newsymb =
     { symbol with symbol_desc = SimpleSymbol (base ^ (string_of_int !n)) }
   in
   (try
       let hsort = Hashtbl.find h symbol in
       Hashtbl.add hsort sort newsymb
     with
     | Not_found ->
        begin
          let hsort = Hashtbl.create 7 in
          Hashtbl.add hsort sort newsymb;
          Hashtbl.add h symbol hsort;
        end;);
     newsymb
  ),
  (fun symbol sort -> H.find (H.find h symbol) sort),
  (fun symbol -> let hsort = H.find h symbol in pick_one hsort)
;;

let obfuscate_command cmd =
  let command_desc =
    match cmd.command_desc with
    | CmdReset
    | CmdCheckSat
    | CmdEcho _
    | CmdExit
    | CmdGetAssertions
    | CmdGetModel<commit_msg>* Renaming to use only Hashtbl in the code.<commit_after>(**************************************************************************)
(*  Copyright (c) 2015 <NAME> <<EMAIL>>      *)
(*                                                                        *)
(*  Permission to use, copy, modify, and distribute this software for any  *)
(*  purpose with or without fee is hereby granted, provided that the above  *)
(*  copyright notice and this permission notice appear in all copies.     *)
(*                                                                        *)
(*  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES  *)
(*  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF      *)
(*  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  *)
(*  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES  *)
(*  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN  *)
(*  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  *)
(*  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.        *)
(*                                                                        *)
(**************************************************************************)

open Ast ;;
open Format ;;

exception Found of symbol ;;

let pick_one h =
  try Hashtbl.iter (fun _ v -> raise (Found v)) h;
      assert false; (* Should not get here *)
  with Found v -> v
;;

let add_sorted_symbol, _find_sorted_symbol, find_symbol =
  let h = Hashtbl.create 97 in
  let n = ref (-1) in
  let base = "S" in
  (fun symbol sort ->
   incr n;
   let newsymb =
     { symbol with symbol_desc = SimpleSymbol (base ^ (string_of_int !n)) }
   in
   (try
       let hsort = Hashtbl.find h symbol in
       Hashtbl.add hsort sort newsymb
     with
     | Not_found ->
        begin
          let hsort = Hashtbl.create 7 in
          Hashtbl.add hsort sort newsymb;
          Hashtbl.add h symbol hsort;
        end;);
     newsymb
  ),
  (fun symbol sort -> Hashtbl.find (Hashtbl.find h symbol) sort),
  (fun symbol -> let hsort = Hashtbl.find h symbol in pick_one hsort)
;;

let obfuscate_command cmd =
  let command_desc =
    match cmd.command_desc with
    | CmdReset
    | CmdCheckSat
    | CmdEcho _
    | CmdExit
    | CmdGetAssertions
    | CmdGetModel
{'fraction_non_alphanumeric': 0.1418788786646694, 'fraction_numerical': 0.0034239246736571796, 'mean_word_length': 2.1666666666666665, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '761364', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1222, 'n_words': 490}