Step 05 - Standardize spelling
Source:vignettes/step-05-standardize-spelling.Rmd
step-05-standardize-spelling.RmdThe dictionary layer. standardize_spelling() expands abbreviations, fixes common misspellings and truncations, and writes each kind of title one way, so that the crosswalk in step 07 needs one entry per title rather than one per spelling.
Before and after
| before (TitleTxt4) | after (TitleTxt5) |
|---|---|
| EXEC DIR | EXECUTIVE DIRECTOR |
| SEC | SECRETARY |
| TREAS | TREASURER |
| ASST SECRETARY | ASSISTANT SECRETARY |
| DIR OF DEVELOPMENT | DIRECTOR OF DEVELOPMENT |
| DIR OF OPS | DIRECTOR OF OPERATIONS |
| CHIEF EXEC OFFICER | CEO |
| CHIEF OPERATING OFFICER | COO |
| EXEC VP | EXECUTIVE VICE PRESIDENT |
| SVP OF MARKETING | SENIOR VICE PRESIDENT OF MARKETING |
| VP FINANCE AND ADMINISTRATION | VICE PRESIDENT OF FINANCE AND ADMINISTRATION |
| VP OF HR | VICE PRESIDENT OF HUMAN RESOURCES |
| GEN COUNSEL | GENERAL COUNSEL |
| CHAIRMAN OF BOARD | CHAIR OF BOARD |
| CHAIRPERSON | CHAIR |
| BOARD PRES | BOARD PRESIDENT |
| MGR IT | MANAGER IT |
| DIR OF NURSING | DIRECTOR OF NURSING |
What it does
standardize_spelling()
+- fix_spelling()
+- fix_vice(), fix_executive(), fix_director(), fix_president(), ... (about 50 fix_* routines)
+- condense_abbreviations(), simplify_clevels()
+- remove_trailing_conjunctions(), fix_of()
+- spellcheck() (hunspell)
- Each
fix_*routine handles one word family:fix_vice()turns VP, V.P., VICE-PRES and EVP into their full forms,fix_director()handles DIR, DIRS, DRCTR, and so on. -
fix_of()inserts the implicit “of” between a title and its subject: VICE PRESIDENT FINANCE becomes VICE PRESIDENT OF FINANCE. - Unambiguous C-suite titles are condensed (CHIEF EXECUTIVE OFFICER becomes CEO, CHIEF FINANCIAL OFFICER becomes CFO). Titles without a standard abbreviation stay spelled out.
-
spellcheck()suggests a dictionary spelling for a word no routine knows.
Assets
| Asset | Type | Used for | Load it with |
|---|---|---|---|
possible.titles |
word list (package data) | title words that can precede an implicit “of” | data(possible.titles) |
likely.subjects |
word list (package data) | subjects that follow “of” (FINANCE, DEVELOPMENT, …) | data(likely.subjects) |
the fix_* routines |
R functions | the abbreviation and spelling rules themselves |
?fix_spelling, ?fix_vice, … |
| hunspell | R package (Imports) | the spell-check dictionary | hunspell::dictionary("en_US") |
data(possible.titles)
head(possible.titles, 10)
#> [1] "VICE PRESIDENT" "DIRECTOR" "CHAIR" "DEAN"
#> [5] "TRUSTEE" "CEO" "SECRETARY" "MANAGER"
#> [9] "MEMBER"
data(likely.subjects)
head(likely.subjects, 15)
#> [1] "OPERATIONS" "FINANCE" "ADMINISTRATION" "MANAGEMENT"
#> [5] "EXHIBIT" "PUBLICITY" "ACTIVITIES" "BUILDING"
#> [9] "EDUCATION" "MARKETING" "STRATEGY" "SALES"
#> [13] "ENSHRINEMENT" "ADVANCEMENT" "FUNDRAISING"Try it
fix_spelling("VP") # VICE PRESIDENT
#> [1] "VICE PRESIDENT"
fix_spelling("SR D MARKETING") # SENIOR DIRECTOR OF MARKETING
#> [1] "SENIOR DIRECTOR OF MARKETING"
fix_spelling("SECY") # SECRETARY
#> [1] "SECRETARY"
fix_spelling("VICE PRESIDENT FINANCE") # VICE PRESIDENT OF FINANCE
#> [1] "VICE PRESIDENT OF FINANCE"
fix_spelling("CHIEF EXEC OFFICER") # CEO
#> [1] "CEO"
fix_spelling("CHIEF ADVANCEMENT OFFICER") # unchanged: no standard abbreviation
#> [1] "CHIEF ADVANCEMENT OFFICER"
fix_vice(c("EVP", "SVP", "V.P."))
#> [1] "EXECUTIVE VICE PRESIDENT" "SENIOR VICE PRESIDENT"
#> [3] "V.P."Input: TitleTxt4. Output: TitleTxt5, with standard spelling. Continue with step 06.