Markus Mottl avatar Markus Mottl committed 0570ce4

Upgraded to OCaml 3.12

Comments (0)

Files changed (14)

+2010-07-21:  Upgraded to OCaml 3.12.
+
 2006-11-22:  Updated OCamlMakefile.
 
 2004-04-18:  Minor speed improvement.

src/algdt_utils.ml

 
 let make_histo var = Array.make (Array.length var.histo) 0
 
-let calc_cntg_tbls { histo = dhisto; samples = dsamples } cvars =
+let calc_cntg_tbls { histo; samples; _ } cvars =
   let make_cntg_tbl _ = Array.map make_histo cvars in
-  let cntg_tbls = Array.init (Array.length dhisto) make_cntg_tbl in
+  let cntg_tbls = Array.init (Array.length histo) make_cntg_tbl in
   let fill_cntg_tbls sample_ix dsample =
     let dcnstr = fdsum_cnstr dsample in
     let cntg_tbl = cntg_tbls.(dcnstr) in
       let ccnstr_cnts = cntg_tbl.(ix) in
       ccnstr_cnts.(ccnstr) <- ccnstr_cnts.(ccnstr) + 1 in
     Array.iteri cnt_var cvars in
-  Array.iteri fill_cntg_tbls dsamples;
+  Array.iteri fill_cntg_tbls samples;
   cntg_tbls
 
 let sample_histo fspec tp samples =
 
 
 (* Split variables on some given variable without adding subvariables. *)
-let split_vars { histo = histo; samples = samples } fspec vars =
+let split_vars { histo; samples; _ } fspec vars =
   let cnv_histo freq =
-    let cnv_vars { tp = tp } =
+    let cnv_vars { tp; _ } =
       {
         samples = Array.make freq dummy_fdsum;
         tp = tp;
         split_ixs.(split_cnstr) <- new_sample_ix + 1;
         let new_vars = split_vars.(split_cnstr) in
         for i = 0 to var_ix_1 do
-          let { histo = new_histo } as new_var = new_vars.(i) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
           new_histo.(cnstr) <- new_histo.(cnstr) + 1
         done;
         for i = var_ix1 to n_vars_1 do
-          let { histo = new_histo } as new_var = new_vars.(i - 1) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i - 1) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
         let new_vars = split_vars.(split_cnstr) in
         let n_subs = Array.length subs in
         for i = 0 to var_ix_1 do
-          let { histo = new_histo } as new_var = new_vars.(i) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
         done;
         let n_subs_1 = n_subs - 1 in
         for i = 0 to n_subs_1 do
-          let { histo = new_histo } as new_var = new_vars.(var_ix + i) in
+          let { histo = new_histo; _ } as new_var = new_vars.(var_ix + i) in
           let sample = subs.(i) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
           new_histo.(cnstr) <- new_histo.(cnstr) + 1
         done;
         for i = var_ix1 to n_vars_1 do
-          let { histo = new_histo } as new_var = new_vars.(i + n_subs_1) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i + n_subs_1) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
 
 let split_cnstr_with_sub_vars fspec vars var_ix cnstr =
   let n_vars_1 = Array.length vars - 1 in
-  let { samples = samples; tp = tp; histo = histo } = vars.(var_ix) in
+  let { samples; tp; histo } = vars.(var_ix) in
   let n_samples = Array.length samples in
   let var_ix1 = var_ix + 1 in
   let var_ix_1 = var_ix - 1 in
   let other_vars = Array.make n_new_vars dummy_var in
 
   for i = 0 to var_ix_1 do
-    let { tp = cur_tp; histo = cur_histo } = vars.(i) in
+    let { tp = cur_tp; histo = cur_histo; _ } = vars.(i) in
     let n_cur_histo = Array.length cur_histo in
     new_vars.(i) <-
       {
   done;
   let n_subs_1 = n_subs - 1 in
   for i = var_ix1 to n_vars_1 do
-    let { tp = cur_tp; histo = cur_histo } = vars.(i) in
+    let { tp = cur_tp; histo = cur_histo; _ } = vars.(i) in
     let n_cur_histo = Array.length cur_histo in
     new_vars.(i + n_subs_1) <-
       {
       new_vars.(var_ix + i) <-
         {
           samples = Array.make freq dummy_fdsum;
-          tp = tp;
+          tp;
           histo = Array.make (Array.length fspec.(tp)) 0;
         }
     done;
           let new_sample_ix = !new_sample_ix_ref in
           new_sample_ix_ref := new_sample_ix + 1;
           for i = 0 to var_ix_1 do
-            let { histo = new_histo } as new_var = new_vars.(i) in
+            let { histo = new_histo; _ } as new_var = new_vars.(i) in
             let sample = vars.(i).samples.(sample_ix) in
             new_var.samples.(new_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
             new_histo.(cnstr) <- new_histo.(cnstr) + 1
           done;
           for i = 0 to n_subs_1 do
-            let { histo = new_histo } as new_var = new_vars.(var_ix + i) in
+            let { histo = new_histo; _ } as new_var = new_vars.(var_ix + i) in
             let sample = subs.(i) in
             new_var.samples.(new_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
             new_histo.(cnstr) <- new_histo.(cnstr) + 1
           done;
           for i = var_ix1 to n_vars_1 do
-            let { histo = new_histo } as new_var = new_vars.(i + n_subs_1) in
+            let { histo = new_histo; _ } as new_var = new_vars.(i + n_subs_1) in
             let sample = vars.(i).samples.(sample_ix) in
             new_var.samples.(new_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
           let other_sample_ix = !other_sample_ix_ref in
           other_sample_ix_ref := other_sample_ix + 1;
           for i = 0 to var_ix_1 do
-            let { histo = other_histo } as other_var = other_vars.(i) in
+            let { histo = other_histo; _ } as other_var = other_vars.(i) in
             let sample = vars.(i).samples.(sample_ix) in
             other_var.samples.(other_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
             other_histo.(cnstr) <- other_histo.(cnstr) + 1
           done;
           for i = var_ix1 to n_vars_1 do
-            let { histo = other_histo } as other_var = other_vars.(i - 1) in
+            let { histo = other_histo; _ } as other_var = other_vars.(i - 1) in
             let sample = vars.(i).samples.(sample_ix) in
             other_var.samples.(other_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
           let new_sample_ix = !new_sample_ix_ref in
           new_sample_ix_ref := new_sample_ix + 1;
           for i = 0 to var_ix_1 do
-            let { histo = new_histo } as new_var = new_vars.(i) in
+            let { histo = new_histo; _ } as new_var = new_vars.(i) in
             let sample = vars.(i).samples.(sample_ix) in
             new_var.samples.(new_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
             new_histo.(cnstr) <- new_histo.(cnstr) + 1
           done;
           for i = var_ix1 to n_vars_1 do
-            let { histo = new_histo } as new_var = new_vars.(i - 1) in
+            let { histo = new_histo; _ } as new_var = new_vars.(i - 1) in
             let sample = vars.(i).samples.(sample_ix) in
             new_var.samples.(new_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
           let other_sample_ix = !other_sample_ix_ref in
           other_sample_ix_ref := other_sample_ix + 1;
           for i = 0 to var_ix_1 do
-            let { histo = other_histo } as other_var = other_vars.(i) in
+            let { histo = other_histo; _ } as other_var = other_vars.(i) in
             let sample = vars.(i).samples.(sample_ix) in
             other_var.samples.(other_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
             other_histo.(cnstr) <- other_histo.(cnstr) + 1
           done;
           for i = var_ix1 to n_vars_1 do
-            let { histo = other_histo } as other_var = other_vars.(i - 1) in
+            let { histo = other_histo; _ } as other_var = other_vars.(i - 1) in
             let sample = vars.(i).samples.(sample_ix) in
             other_var.samples.(other_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
       new_vars.(var_ix + i) <-
         {
           samples = Array.make freq dummy_fdsum;
-          tp = tp;
+          tp;
           histo = Array.make (Array.length fspec.(tp)) 0;
         }
     done;
       match samples.(sample_ix) with
       | FDStrct (split_cnstr, subs) when split_cnstr = cnstr ->
           for i = 0 to n_subs_1 do
-            let { histo = new_histo } as new_var = new_vars.(var_ix + i) in
+            let { histo = new_histo; _ } as new_var = new_vars.(var_ix + i) in
             let sample = subs.(i) in
             new_var.samples.(sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
         let none_sample_ix = !none_ix_ref in
         none_ix_ref := none_sample_ix + 1;
         for i = 0 to var_ix_1 do
-          let { histo = none_histo } as none_var = none_vars.(i) in
+          let { histo = none_histo; _ } as none_var = none_vars.(i) in
           let sample = vars.(i).samples.(sample_ix) in
           none_var.samples.(none_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
           none_histo.(cnstr) <- none_histo.(cnstr) + 1
         done;
         for i = var_ix1 to n_vars_1 do
-          let { histo = none_histo } as none_var = none_vars.(i - 1) in
+          let { histo = none_histo; _ } as none_var = none_vars.(i - 1) in
           let sample = vars.(i).samples.(sample_ix) in
           none_var.samples.(none_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
         split_ixs.(split_cnstr) <- new_sample_ix + 1;
         let new_vars = split_vars.(split_cnstr) in
         for i = 0 to var_ix_1 do
-          let { histo = new_histo } as new_var = new_vars.(i) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
           new_histo.(cnstr) <- new_histo.(cnstr) + 1
         done;
         for i = var_ix1 to n_vars_1 do
-          let { histo = new_histo } as new_var = new_vars.(i - 1) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i - 1) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
         let new_vars = split_vars.(split_cnstr) in
         let n_subs = Array.length subs in
         for i = 0 to var_ix_1 do
-          let { histo = new_histo } as new_var = new_vars.(i) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
         done;
         let n_subs_1 = n_subs - 1 in
         for i = 0 to n_subs_1 do
-          let { histo = new_histo } as new_var = new_vars.(var_ix + i) in
+          let { histo = new_histo; _ } as new_var = new_vars.(var_ix + i) in
           let sample = subs.(i) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
           new_histo.(cnstr) <- new_histo.(cnstr) + 1
         done;
         for i = var_ix1 to n_vars_1 do
-          let { histo = new_histo } as new_var = new_vars.(i + n_subs_1) in
+          let { histo = new_histo; _ } as new_var = new_vars.(i + n_subs_1) in
           let sample = vars.(i).samples.(sample_ix) in
           new_var.samples.(new_sample_ix) <- sample;
           let cnstr = fdsum_cnstr sample in
 (* Apply model to data *)
 
 let handle_model pred_oc = function
-  | `Model (dispec_info, { ispec = cispec; cnstr_tbl = ccnstr_tbl }, model) ->
+  | `Model (
+        dispec_info, { ispec = cispec; cnstr_tbl = ccnstr_tbl; _ }, model) ->
       let dispec = dispec_info.ispec in
       let dfspec, _ = flatten_ispec dispec_info.ispec in
       let cfspec, _ = flatten_ispec cispec in
       let sample_ix = n_samples_1 - ix in
       csamples.(sample_ix) <- FDAtom ccnstr;
       chisto.(ccnstr) <- chisto.(ccnstr) + 1;
-      let acti var_ix { samples = dsamples; histo = dhisto } =
+      let acti var_ix { samples = dsamples; histo = dhisto; _ } =
         let dcnstr = sample.(var_ix) in
         dhisto.(dcnstr) <- dhisto.(dcnstr) + 1;
         dsamples.(sample_ix) <- FDAtom dcnstr in
 
 let read_c45_data (tp_names, target_attrs, pat, _ as c45_spec) mv ic =
   let rex = regexp ~flags pat in
-  let { cnstr_tbl = dcnstr_tbl; cnstr_htbl = dcnstr_htbl; } as dispec_info =
+  let { cnstr_tbl = dcnstr_tbl; cnstr_htbl = dcnstr_htbl; _ } as dispec_info =
     calc_dispec_info mv c45_spec in
-  let { cnstr_htbl = ccnstr_htbl; } as cispec_info =
+  let { cnstr_htbl = ccnstr_htbl; _ } as cispec_info =
     calc_cispec_info c45_spec in
 
   let n_lines_ref = ref 1 in
 
       let n_samples = !n_samples_ref in
       let n_samples_1 = n_samples - 1 in
-      let { samples = dsamples; histo = dhisto; } as dvar =
+      let { samples = dsamples; histo = dhisto; _ } as dvar =
         {
           tp = n_vars + 1;
           samples = Array.make n_samples dummy_fdsum;  (* dummy_fdsum = MV! *)
           let sample_ix = n_samples_1 - ix in
           csamples.(sample_ix) <- FDAtom ccnstr;
           chisto.(ccnstr) <- chisto.(ccnstr) + 1;
-          let acti var_ix { samples = dsamples; histo = dhisto } =
+          let acti var_ix { samples = dsamples; histo = dhisto; _ } =
             let fdsum = sample.(var_ix) in
             let dcnstr = fdsum_cnstr fdsum in
             dhisto.(dcnstr) <- dhisto.(dcnstr) + 1;
       else (i', ar) :: rest
   | [] -> assert false
 
-let make_cnv_data
-    { cnstr_htbl = cnstr_htbl; ispec = ispec; tp_tbl = tp_tbl } fspec =
+let make_cnv_data { cnstr_htbl; ispec; tp_tbl; _ } fspec =
   let find_cnstr tp cnstr =
     try Hashtbl.find cnstr_htbl (tp, cnstr)
     with Not_found ->
 
 (* Evaluate C4.5-data *)
 
-let eval_c45 { cnstr_htbl = cnstr_htbl; ispec = cispec } eval_name =
+let eval_c45 { cnstr_htbl; ispec; _ } eval_name =
   do_open_in eval_name (fun eval_ic ->
   let read_eval () = C45_io.read_rhs eval_ic cnstr_htbl in
   let read () = C45_io.read_rhs stdin cnstr_htbl in
-  report (flatten_ispec cispec) read_eval read)
+  report (flatten_ispec ispec) read_eval read)
         dentropy +. calc_unique_entropy (Array.length dfspec.(tp)) n_samples in
       one_list_fold_left coll_dom_entropy dentropy sh_chain
 
-let split_entropy ({ histo = dhisto; samples = dsamples } as dvar) cvars =
+let split_entropy ({ histo = dhisto; samples = dsamples; _ } as dvar) cvars =
   let f_samples = float (Array.length dsamples) in
   let colli dcnstr e split_info =
     let split_e = calc_split_info_entropy cfspec split_info in

src/id_entropy.ml

           split_ixs.(split_cnstr) <- new_sample_ix + 1;
           let new_vars = split_vars.(split_cnstr) in
           for i = 0 to Array.length new_vars - 1 do
-            let { histo = new_histo } as new_var = new_vars.(i) in
+            let { histo = new_histo; _ } as new_var = new_vars.(i) in
             let sample = subs.(i) in
             new_var.samples.(new_sample_ix) <- sample;
             let cnstr = fdsum_cnstr sample in
 
 let learn spec =
   let
-    { ispec = dispec } as dispec_info,
-    ({ ispec = cispec } as cispec_info) =
+    { ispec = dispec; _ } as dispec_info,
+    ({ ispec = cispec; _ } as cispec_info) =
       do_open_in spec (fun sp_ic -> read_spec (Lexing.from_channel sp_ic)) in
 
   let dfspec, dinit_tps = flatten_ispec dispec in

src/learn_nothreads.ml

 
 let learn spec =
   let
-    { ispec = dispec } as dispec_info,
-    ({ ispec = cispec } as cispec_info) =
+    { ispec = dispec; _ } as dispec_info,
+    ({ ispec = cispec; _ } as cispec_info) =
       do_open_in spec (fun sp_ic -> read_spec (Lexing.from_channel sp_ic)) in
 
   let dfspec, dinit_tps = flatten_ispec dispec in

src/model_pp_impl.ml

 
 (* Conversion tables from immediate to string encodings *)
 
-let { tp_tbl = dtp_tbl; cnstr_tbl = dcnstr_tbl; } = dispec_info
-let { tp_tbl = ctp_tbl; cnstr_tbl = ccnstr_tbl; } = cispec_info
+let { tp_tbl = dtp_tbl; cnstr_tbl = dcnstr_tbl; _ } = dispec_info
+let { tp_tbl = ctp_tbl; cnstr_tbl = ccnstr_tbl; _ } = cispec_info
 
 (* Specialized pretty-printer *)
 
         sub_ixs.(cnstr) <- sub_ix + 1;
         let sub_vars = many_sub_vars.(cnstr) in
         for sub_var_ix = 0 to Array.length subs - 1 do
-          let { samples = sub_samples; histo = sub_histo } =
+          let { samples = sub_samples; histo = sub_histo; _ } =
             sub_vars.(sub_var_ix) in
           let sub_sample = subs.(sub_var_ix) in
           sub_samples.(sub_ix) <- sub_sample;
         many_sub_irefs.(cnstr).(sub_ix) <- iref;
         let sub_vars = many_sub_vars.(cnstr) in
         for sub_var_ix = 0 to Array.length subs - 1 do
-          let { samples = sub_samples; histo = sub_histo } =
+          let { samples = sub_samples; histo = sub_histo; _ } =
             sub_vars.(sub_var_ix) in
           let sub_sample = subs.(sub_var_ix) in
           sub_samples.(sub_ix) <- sub_sample;
   loop init_tp
 
 let write_rand_samples ppf dispec_info cispec_info n with_target =
-  let { ispec = dispec; cnstr_tbl = dcnstr_tbl } = dispec_info in
-  let { ispec = cispec; cnstr_tbl = ccnstr_tbl } = cispec_info in
+  let { ispec = dispec; cnstr_tbl = dcnstr_tbl; _ } = dispec_info in
+  let { ispec = cispec; cnstr_tbl = ccnstr_tbl; _ } = cispec_info in
   let module IData2PP =
     Algdt_pp.Make_IData2
       (struct let cnstr_tbl = dcnstr_tbl end)

src/split_impl.ml

         split_ixs.(split_cnstr) <- new_sample_ix + 1;
         let new_dvars = split_dvars.(split_cnstr) in
         for i = 0 to dvar_ix - 1 do
-          let { histo = new_dhisto } as new_dvar = new_dvars.(i) in
+          let { histo = new_dhisto; _ } as new_dvar = new_dvars.(i) in
           let dsample = dvars.(i).samples.(sample_ix) in
           new_dvar.samples.(new_sample_ix) <- dsample;
           let dcnstr = fdsum_cnstr dsample in
           new_dhisto.(dcnstr) <- new_dhisto.(dcnstr) + 1
         done;
         for i = dvar_ix + 1 to n_dvars_1 do
-          let { histo = new_dhisto } as new_dvar = new_dvars.(i - 1) in
+          let { histo = new_dhisto; _ } as new_dvar = new_dvars.(i - 1) in
           let dsample = dvars.(i).samples.(sample_ix) in
           new_dvar.samples.(new_sample_ix) <- dsample;
           let dcnstr = fdsum_cnstr dsample in
         done;
         let new_cvars = split_cvars.(split_cnstr) in
         for i = 0 to n_cvars_1 do
-          let { histo = new_chisto } as new_cvar = new_cvars.(i) in
+          let { histo = new_chisto; _ } as new_cvar = new_cvars.(i) in
           let csample = cvars.(i).samples.(sample_ix) in
           new_cvar.samples.(new_sample_ix) <- csample;
           let ccnstr = fdsum_cnstr csample in
         let new_dvars = split_dvars.(split_cnstr) in
         let n_dsubs = Array.length subs in
         for i = 0 to dvar_ix - 1 do
-          let { histo = new_dhisto } as new_dvar = new_dvars.(i) in
+          let { histo = new_dhisto; _ } as new_dvar = new_dvars.(i) in
           let dsample = dvars.(i).samples.(sample_ix) in
           new_dvar.samples.(new_sample_ix) <- dsample;
           let dcnstr = fdsum_cnstr dsample in
         done;
         let n_dsubs_1 = n_dsubs - 1 in
         for i = 0 to n_dsubs_1 do
-          let { histo = new_dhisto } as new_dvar = new_dvars.(dvar_ix + i) in
+          let { histo = new_dhisto; _ } as new_dvar = new_dvars.(dvar_ix + i) in
           let dsample = subs.(i) in
           new_dvar.samples.(new_sample_ix) <- dsample;
           let dcnstr = fdsum_cnstr dsample in
           new_dhisto.(dcnstr) <- new_dhisto.(dcnstr) + 1
         done;
         for i = dvar_ix + 1 to n_dvars_1 do
-          let { histo = new_dhisto } as new_dvar = new_dvars.(i + n_dsubs_1) in
+          let { histo = new_dhisto; _ } as new_dvar = new_dvars.(i + n_dsubs_1) in
           let dsample = dvars.(i).samples.(sample_ix) in
           new_dvar.samples.(new_sample_ix) <- dsample;
           let dcnstr = fdsum_cnstr dsample in
         done;
         let new_cvars = split_cvars.(split_cnstr) in
         for i = 0 to n_cvars_1 do
-          let { histo = new_chisto } as new_cvar = new_cvars.(i) in
+          let { histo = new_chisto; _ } as new_cvar = new_cvars.(i) in
           let csample = cvars.(i).samples.(sample_ix) in
           new_cvar.samples.(new_sample_ix) <- csample;
           let ccnstr = fdsum_cnstr csample in
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.