ExNlp.Snowball (ex_nlp v0.1.0)

View Source

Unified interface for Snowball stemming algorithms.

This module provides a consistent API for stemming words across multiple languages.

Supported Languages

  • :english - English stemming using Porter2 algorithm
  • :spanish - Spanish stemming
  • :portuguese - Portuguese stemming
  • :french - French stemming
  • :german - German stemming
  • :italian - Italian stemming
  • :polish - Polish stemming

Examples

iex> ExNlp.Snowball.stem("running", :english)
"run"

iex> ExNlp.Snowball.stem("caminando", :spanish)
"camin"

iex> ExNlp.Snowball.stem("the", :english, ignore_stopwords: true)
"the"

iex> ExNlp.Snowball.stem("running", :english, ignore_stopwords: false)
"run"

Summary

Functions

Stems a word in the specified language.

Checks if a language is supported.

Returns the list of supported languages.

Functions

stem(word, language, opts \\ [])

Stems a word in the specified language.

Arguments

  • word - The word to stem (string)
  • language - The language atom (:english, :spanish, etc.)
  • opts - Keyword list of options
    • ignore_stopwords - If true, returns stopwords unchanged (default: false)

Returns

The stemmed word as a string.

Examples

iex> ExNlp.Snowball.stem("running", :english)
"run"

iex> ExNlp.Snowball.stem("beautifully", :english)
"beauti"

stem_words(words, language, opts \\ [])

Stems multiple words.

Examples

iex> ExNlp.Snowball.stem_words(["running", "jumping"], :english)
["run", "jump"]

supported?(language)

Checks if a language is supported.

Examples

iex> ExNlp.Snowball.supported?(:english)
true

iex> ExNlp.Snowball.supported?(:japanese)
false

supported_languages()

Returns the list of supported languages.

Examples

iex> ExNlp.Snowball.supported_languages()
[:english, :spanish, :portuguese, :french, :german, :italian, :polish]