BantScore (bant_score v1.0.0)

Copy Markdown View Source

BANT lead scoring from a CSV with the columns lead,budget,authority,need,timeline.

Each letter is yes (2 points), unknown (1 point) or no (0 points); true and false are accepted as yes and no. The total runs from 0 to 8 and gives a verdict:

  • 7 to 8: qualified
  • 4 to 6: nurture
  • 0 to 3: disqualify

Any other value in a letter column is an error.

Summary

Functions

Count of leads per verdict, in the order qualified, nurture, disqualify.

Parse the CSV text into scored leads, sorted by score descending then lead name.

Parse a single answer: yes, no, unknown, true, false (any case).

Points for one answer: yes = 2, unknown = 1, no = 0.

Printable table followed by the count per verdict.

Score one lead from its four answers (budget, authority, need, timeline).

Verdict for a total score: 7-8 qualified, 4-6 nurture, 0-3 disqualify.

Types

answer()

@type answer() :: :yes | :no | :unknown

lead()

@type lead() :: %{
  lead: String.t(),
  answers: [answer()],
  score: 0..8,
  verdict: String.t()
}

Functions

counts(leads)

@spec counts([lead()]) :: [{String.t(), non_neg_integer()}]

Count of leads per verdict, in the order qualified, nurture, disqualify.

parse(text)

@spec parse(String.t()) :: {:ok, [lead()]} | {:error, String.t()}

Parse the CSV text into scored leads, sorted by score descending then lead name.

parse_answer(value)

@spec parse_answer(String.t()) :: {:ok, answer()} | :error

Parse a single answer: yes, no, unknown, true, false (any case).

points(atom)

@spec points(answer()) :: 0..2

Points for one answer: yes = 2, unknown = 1, no = 0.

render(leads)

@spec render([lead()]) :: String.t()

Printable table followed by the count per verdict.

score_answers(answers)

@spec score_answers([answer()]) :: 0..8

Score one lead from its four answers (budget, authority, need, timeline).

verdict(score)

@spec verdict(0..8) :: String.t()

Verdict for a total score: 7-8 qualified, 4-6 nurture, 0-3 disqualify.