diff options
-rw-r--r-- | sorsyl/lib/ipa_table.ml | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sorsyl/lib/ipa_table.ml b/sorsyl/lib/ipa_table.ml index 295100d..3ecbda4 100644 --- a/sorsyl/lib/ipa_table.ml +++ b/sorsyl/lib/ipa_table.ml @@ -121,9 +121,11 @@ let longest_one_seg_prefix trie word = let ipa_segs ?(_normalize = true) data word = let rec aux acc remaining = - match longest_one_seg_prefix data.trie remaining with - | None -> acc - | Some seg -> - aux (seg :: acc) (String.drop_prefix remaining (String.length seg)) + if String.is_empty remaining then acc + else + match longest_one_seg_prefix data.trie remaining with + | None -> aux acc (String.drop_prefix remaining 1) + | Some seg -> + aux (seg :: acc) (String.drop_prefix remaining (String.length seg)) in List.rev (aux [] word) |