package stem

  1. Overview
  2. Docs
A stemmer of words for few languages

Install

dune-project
 Dependency

Authors

Maintainers

Sources

stem-0.0.2.tbz
sha256=830e8693a19996caa7745fc67c6d3655b29128d253ff78088e77faba9ad7b488
sha512=d89a8246864f204fbaa159d7c09517003838913944f4a6235b63efb8e4e96fb1872baaa8563392b8e3a4e2354baf363b5e15ed2899f60d8cbf66bbcfdb6d2d85

doc/src/stem.tokenizer/dash.ml.html

Source file dash.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(* TODO(dinosaure): handle [encoding]. *)
let find_matches ?encoding:_ str =
  match String.split_on_char '-' str with
  | [] -> assert false
  | [ str ] -> List.to_seq [ { S.str; is_match = false } ]
  | hd :: tl ->
      let dash = { S.str = "-"; is_match = true } in
      let rec go acc = function
        | [] -> List.to_seq (List.rev acc)
        | "" :: r -> go (dash :: acc) r
        | str :: r ->
            let x = { S.str; is_match = false } in
            go (x :: dash :: acc) r in
      go [ { S.str = hd; is_match = false } ] tl

let find_matches_on_bstr ?encoding:_ bstr =
  match Bstr.split_on_char '-' bstr with
  | [] -> assert false
  | [ bstr ] ->
      let str = Bstr.to_string bstr in
      List.to_seq [ { S.str; is_match = false } ]
  | hd :: tl ->
      let dash = { S.str = "-"; is_match = true } in
      let rec go acc = function
        | [] -> List.to_seq (List.rev acc)
        | bstr :: r when Bstr.is_empty bstr -> go (dash :: acc) r
        | bstr :: r ->
            let str = Bstr.to_string bstr in
            let x = { S.str; is_match = false } in
            go (x :: dash :: acc) r in
      let hd = Bstr.to_string hd in
      go [ { S.str = hd; is_match = false } ] tl