Despamilator.Subject (Despamilator v2.1.5)

Copy Markdown View Source

The mutable-feeling accumulator for a scan. Holds the original text, the running score, and per-filter score totals in match_scores.

Summary

Functions

Returns matches as a list of %{filter: module, score: float} maps, sorted highest score first (ties keep insertion order).

Builds a new subject from raw text.

Records a match. Filter is the implementing module; score is added to both the per-filter total and the subject's running score.

Convenience: hand the subject text to a Despamilator.Subject.Text helper.

Types

t()

@type t() :: %Despamilator.Subject{
  match_order: [module()],
  match_scores: %{required(module()) => float()},
  score: float(),
  text: String.t()
}

Functions

count(text, pattern)

See Despamilator.Subject.Text.count/2.

matches(subject)

Returns matches as a list of %{filter: module, score: float} maps, sorted highest score first (ties keep insertion order).

new(text)

Builds a new subject from raw text.

register_match(subject, filter, score)

Records a match. Filter is the implementing module; score is added to both the per-filter total and the subject's running score.

remove_and_count(text, pattern)

See Despamilator.Subject.Text.remove_and_count/2.

text(subject)

Convenience: hand the subject text to a Despamilator.Subject.Text helper.

without_uris(text)

See Despamilator.Subject.Text.without_uris/1.

words(text)

See Despamilator.Subject.Text.words/1.