2 Module : Gargantext.Core.Text.Ngrams.Stem
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 In linguistic morphology and information retrieval, stemming is the
11 process of reducing inflected (or sometimes derived) words to their word
12 stem, base or root form—generally a written word form. The @stem@ needs
13 not be identical to the morphological root of the word; it is usually
14 sufficient that related words map to the same stem, even if this stem is
15 not in itself a valid root.
16 Source : https://en.wikipedia.org/wiki/Stemming
21 module Gargantext.Core.Text.Terms.Mono.Stem (stem, Lang(..))
24 import Data.Text (Text)
25 import qualified Data.Text as DT
26 import qualified NLP.Stemmer as N
28 import Gargantext.Prelude
29 import Gargantext.Core (Lang(..))
31 -- (stem, Stemmer(..))
33 --import Language.Aspell (check, suggest, spellChecker, spellCheckerWithOptions)
34 --import Language.Aspell.Options (ACOption(..))
39 -- A stemmer for English, for example, should identify the string "cats"
40 -- (and possibly "catlike", "catty" etc.) as based on the root "cat".
43 -- "stems", "stemmer", "stemming", "stemmed" as based on "stem". A stemming
44 -- algorithm reduces the words "fishing", "fished", and "fisher" to the
45 -- root word, "fish". On the other hand, "argue", "argued", "argues",
46 -- "arguing", and "argus" reduce to the stem "argu" (illustrating the
47 -- case where the stem is not itself a word or root) but "argument" and
48 -- "arguments" reduce to the stem "argument".
51 stem :: Lang -> Text -> Text
52 stem lang = DT.pack . N.stem lang' . DT.unpack
57 _ -> panic $ DT.pack "not implemented yet"