module AccountNameKeyBuilder
Overview
Build a plain match key from account names, so that "Alpha Widgets Inc", "Alpha Widgets, LLC" and "The Alpha Widgets Company" show up as one group. The key only helps you SEE possible duplicates. It merges nothing, and two different companies can share a key.
Defined in:
account_name_key_builder.crConstant Summary
-
DEFAULT_SUFFIXES =
["inc", "incorporated", "llc", "ltd", "limited", "gmbh", "corp", "corporation", "co", "company", "plc", "pte", "bv", "ag", "sa"] of ::String -
Default suffix list, replaced as a whole by --suffixes. Set by you.
-
REQUIRED =
["account_id", "name"] of ::String -
USAGE =
"usage: account-name-key-builder accounts.csv [--suffixes inc,llc,ltd]\nCSV columns: account_id, name. The key only helps you see possible duplicates; it merges nothing and two different companies can share a key. --suffixes replaces the default suffix list and is set by you.\nMore: https://www.onegtmlab.dev/tool-directory/data-platforms/clay" -
VERSION =
"1.0.0"
Class Method Summary
-
.cli(args : Array(String), stdout : IO, stderr : IO) : Int32
Command line entry.
-
.groups(accounts : Array(Account)) : Array(Group)
Every key with its accounts in input order.
-
.key(name : String, suffixes : Array(String) = DEFAULT_SUFFIXES) : String
The key rule, in this exact order: 1.
-
.parse_csv(text : String) : Array(Array(String))
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark.
-
.parse_suffixes(text : String) : Array(String)
Parse the --suffixes value: comma separated, trimmed, lowercased.
- .read_accounts(text : String, suffixes : Array(String) = DEFAULT_SUFFIXES) : Array(Account)
- .render(accounts : Array(Account), suffixes : Array(String)) : String
Class Method Detail
Command line entry. Returns the exit code: 0 ok, 1 bad input or file, 2 usage.
Every key with its accounts in input order.
The key rule, in this exact order:
- lowercase
- "&" becomes " and "
- every character that is not a to z or 0 to 9 becomes a space (accented letters are therefore dropped, not transliterated)
- collapse spaces
- remove a leading word "the"
- repeatedly remove a trailing word that is in the suffix list
Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark. Returns rows of raw cell strings.
Parse the --suffixes value: comma separated, trimmed, lowercased. Replaces the default list.