diff options
Diffstat (limited to 'motus/bin')
| -rw-r--r-- | motus/bin/motus.ml | 22 | 
1 files changed, 17 insertions, 5 deletions
diff --git a/motus/bin/motus.ml b/motus/bin/motus.ml index 638e778..823a01b 100644 --- a/motus/bin/motus.ml +++ b/motus/bin/motus.ml @@ -69,14 +69,20 @@ let create_new_rules word result =    !rules -let rec run len filters words = +type t = +  { catalog : Wordlist.t +  ; words : Wordlist.t +  } + +let rec run : int -> Criteria.t list -> t -> unit = + fun len filters { catalog; words } ->    let () = show_structure Format.std_formatter words filters in    (*    let next =      Freq_analysis.analyse words |> Freq_analysis.pick_next_word words    in    *) -  let _, next = Entropy.analyse len ~catalog:words words in +  let _, next = Entropy.analyse len ~catalog words in    let () =      Format.fprintf Format.std_formatter "Next word will be : %s@\n" next @@ -86,14 +92,20 @@ let rec run len filters words =    (* if the input is empty, remove the word from the list and restart *)    match String.equal String.empty input with -  | true -> run len filters (Wordlist.remove_word words next) +  | true -> +      let new_list = +        { catalog = Wordlist.remove_word catalog next +        ; words = Wordlist.remove_word words next +        } +      in +      run len filters new_list    | false ->        let new_rules =          Criteria.merge_lists ~init:filters (create_new_rules next input)          |> List.sort_uniq Stdlib.compare        in        let words = Wordlist.filter new_rules words in -      run len new_rules words +      run len new_rules { catalog = Wordlist.remove_word catalog next; words }  let init_rule rules word = @@ -122,4 +134,4 @@ let () =    let words_channel = open_in (List.hd !dict) in    let words = get_list words_channel initial_filter in    close_in words_channel; -  run !length initial_filter words +  run !length initial_filter { catalog = words; words }  | 
