aboutsummaryrefslogtreecommitdiff
path: root/motus/js/initialize.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-02-25 19:15:29 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-25 19:15:29 +0100
commit4eff667b92ff7ef4c3542650509c03fb0de5cbce (patch)
tree6a6180d355d0ab78626ad5988c5203ee20344187 /motus/js/initialize.ml
parent95432043550bd4a41b4466395502bc3b748e6746 (diff)
Added an another engine for motus, using entropy instead of frequencies only
Diffstat (limited to 'motus/js/initialize.ml')
-rw-r--r--motus/js/initialize.ml16
1 files changed, 11 insertions, 5 deletions
diff --git a/motus/js/initialize.ml b/motus/js/initialize.ml
index a088a0e..9d07a85 100644
--- a/motus/js/initialize.ml
+++ b/motus/js/initialize.ml
@@ -17,11 +17,17 @@ type t =
The rule list is used to identify the letter already fixed by the previous
results. *)
-let get_proposition : Wordlist.t -> Criteria.t list -> State.proposition option
- =
- fun analysis rules ->
+let get_proposition :
+ int -> Wordlist.t -> Criteria.t list -> State.proposition option =
+ fun length wordlist rules ->
+ Printf.printf "Number of elements : %d\n" (Wordlist.list_size wordlist);
+
let word =
- Freq_analysis.analyse analysis |> Freq_analysis.pick_next_word analysis
+ if Wordlist.list_size wordlist > 2000
+ then Freq_analysis.analyse wordlist |> Freq_analysis.pick_next_word wordlist
+ else
+ let _, word = Entropy.analyse length wordlist in
+ word
in
match String.equal String.empty word with
| true -> None
@@ -63,7 +69,7 @@ let process { sender; length; content; proposition } state =
|> Wordlist.add_words rules
in
- let current_prop = get_proposition analysis rules
+ let current_prop = get_proposition length analysis rules
and fields = FieldList.make length sender in
( match current_prop with
| None -> state