diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2022-02-24 09:26:23 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-24 13:39:39 +0100 |
commit | 95432043550bd4a41b4466395502bc3b748e6746 (patch) | |
tree | 2d1783c6a03eadc9d4be485130b58abd222dad20 /motus/js | |
parent | c2bd6982e5ed845293a38ae600c239cd50924d76 (diff) |
Moved the wordlist into a set
Diffstat (limited to 'motus/js')
-rw-r--r-- | motus/js/initialize.ml | 12 | ||||
-rw-r--r-- | motus/js/next.ml | 7 |
2 files changed, 6 insertions, 13 deletions
diff --git a/motus/js/initialize.ml b/motus/js/initialize.ml index 82f1288..a088a0e 100644 --- a/motus/js/initialize.ml +++ b/motus/js/initialize.ml @@ -21,7 +21,7 @@ let get_proposition : Wordlist.t -> Criteria.t list -> State.proposition option = fun analysis rules -> let word = - Wordlist.extract_freq analysis |> Wordlist.pick_next_word analysis |> fst + Freq_analysis.analyse analysis |> Freq_analysis.pick_next_word analysis in match String.equal String.empty word with | true -> None @@ -58,13 +58,11 @@ let process { sender; length; content; proposition } state = in let words = Jstr.cuts ~sep:(Jstr.v "\n") value in let analysis = - List.fold_left - ~f:(fun a w -> - let upper = Jstr.uppercased w in - Wordlist.add_word rules a (Jstr.to_string upper) ) - ~init:(Wordlist.empty_data ()) - words + List.to_seq words + |> Seq.map (fun w -> Jstr.(to_string (uppercased w))) + |> Wordlist.add_words rules in + let current_prop = get_proposition analysis rules and fields = FieldList.make length sender in ( match current_prop with diff --git a/motus/js/next.ml b/motus/js/next.ml index 72db9e4..104b3e6 100644 --- a/motus/js/next.ml +++ b/motus/js/next.ml @@ -15,12 +15,7 @@ let process : t -> State.state -> State.state = in (* Update the word list with the new rules *) - let analysis = - List.fold_left - ~f:(Motus_lib.Wordlist.add_word rules) - ~init:(Motus_lib.Wordlist.empty_data ()) - (Motus_lib.Wordlist.words state.analysis) - in + let analysis = Motus_lib.Wordlist.filter rules state.analysis in let propositions = state.current_prop :: state.propositions and current_prop = [] in |