Split a keyword list into head, body and long-tail bands by word count.
Input is a CSV with a keyword column and an optional volume column (a non-negative
whole number). Words are the whitespace-separated tokens of the trimmed keyword.
- head: fewer than
body_fromwords (default: 1 word) - body:
body_fromor more words but fewer thanlong_from(default: 2 to 3 words) - long tail:
long_fromor more words (default: 4 or more)
body_from and long_from are parameters set by you, not rules. They must satisfy
2 <= body_from < long_from.
Keywords that repeat (ignoring case and extra spaces) are counted once; the first row wins, including its volume. Shares and averages are rounded half up to one decimal.
Summary
Functions
Band name for a word count.
Check the band limits: 2 <= body_from < long_from.
Parse the CSV text. Duplicate keywords are dropped (first row kept) and listed.
Divide num / den * mult exactly (integers only) and format with decimals places,
rounding half up. Returns "n/a" when den is zero.
Printable report: totals, duplicates, band table and top keywords.
Per-band summary for parsed keywords. Returns a list of three maps (head, body, long tail)
with the keys band, keywords, words_total, volume and top (up to 3 keywords by
volume, ties by keyword).
Types
@type keyword_row() :: %{ keyword: String.t(), words: pos_integer(), volume: non_neg_integer() | nil }
@type parsed() :: %{ keywords: [keyword_row()], duplicates: [String.t()], has_volume: boolean() }
Functions
@spec band(pos_integer(), pos_integer(), pos_integer()) :: :head | :body | :long_tail
Band name for a word count.
Check the band limits: 2 <= body_from < long_from.
Parse the CSV text. Duplicate keywords are dropped (first row kept) and listed.
@spec ratio(integer(), integer(), integer(), non_neg_integer()) :: String.t()
Divide num / den * mult exactly (integers only) and format with decimals places,
rounding half up. Returns "n/a" when den is zero.
@spec render(parsed(), pos_integer(), pos_integer()) :: String.t()
Printable report: totals, duplicates, band table and top keywords.
@spec summarize(parsed(), pos_integer(), pos_integer()) :: [map()]
Per-band summary for parsed keywords. Returns a list of three maps (head, body, long tail)
with the keys band, keywords, words_total, volume and top (up to 3 keywords by
volume, ties by keyword).