Case a single word¶
Applies a first-match-wins sequence of casing rules (preformatted mixed-case, acronym list, minor-word list, irregular spelling, ordinal suffix, default proper-case) to a single word token.
| Field | Value |
|---|---|
| Operation ID | op-02-case-single-word |
| Trigger | Called once per token from Convert text to title case, step 4 |
| Inputs | Word token (String) |
| Outputs | Cased word |
| Primary components | TitleCaseSingleWord (private), HasNumberSuffix, ToProperCase |
| Entry point | SAIF.Business.Utilities/TitleCase.vb |
Steps¶
First matching branch wins:
- If the word already contains both an upper-case and a lower-case character, return it untouched — pre-formatted mixed-case input is respected (BR-004).
- Else if
word.ToUpperis inUpperCaseWordList, upper-case the word (BR-005). - Else if
word.ToLoweris inLowerCaseWordList, lower-case the word (BR-006). - Else if
word.ToLowermatches an entry ofMixedCaseWordListcase-insensitively, replace with that list's canonical spelling (e.g.PhD,LaCombe) (BR-007). - Else if
HasNumberSuffix(word)— the token splits into a purely numeric part plus one ofst/nd/rd/th— rejoin the number with the lower-cased suffix (BR-008). - Else apply
ToProperCase(StrConv ... VbStrConv.ProperCase) (BR-009). - Post-step: if the resulting word starts with a
MixedCasePrefixListentry (Mc,O'), keep the prefix as-is and proper-case the remainder (BR-012).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["Caller invokes<br>TitleCaseSingleWord"]) --> MixedCheck{Contains both upper-<br>and lower-case chars?}
MixedCheck -->|Yes| ReturnAsIs(["Return word untouched"])
MixedCheck -->|No| UpperCheck{word.ToUpper in<br>UpperCaseWordList?}
UpperCheck -->|Yes| UpperCase["Upper-case the word"]
UpperCheck -->|No| LowerCheck{word.ToLower in<br>LowerCaseWordList?}
LowerCheck -->|Yes| LowerCase["Lower-case the word"]
LowerCheck -->|No| MixedListCheck{Matches MixedCaseWordList<br>case-insensitively?}
MixedListCheck -->|Yes| Canonical["Replace with canonical<br>spelling"]
MixedListCheck -->|No| SuffixCheck{HasNumberSuffix?}
SuffixCheck -->|Yes| Rejoin["Rejoin number with<br>lower-cased suffix"]
SuffixCheck -->|No| ProperCase["Apply ToProperCase"]
UpperCase --> PrefixCheck{Starts with<br>MixedCasePrefixList entry?}
LowerCase --> PrefixCheck
Canonical --> PrefixCheck
Rejoin --> PrefixCheck
ProperCase --> PrefixCheck
PrefixCheck -->|Yes| KeepPrefix["Keep prefix as-is,<br>proper-case remainder"]
PrefixCheck -->|No| Done(["Return cased word"])
KeepPrefix --> Done
Related documentation¶
Sources¶
SAIF.Business.Utilities/TitleCase.vb