Title-case a single word¶
Apply acronym/lowercase/mixed-case/ordinal rules to one word, triggered when called once per split word by OP-001 step 4.
| Field | Value |
|---|---|
| Operation ID | OP-002 |
| Trigger | Called once per split word by OP-001 step 4 |
| Inputs | string inWord |
| Outputs | Cased string |
| Primary components | `TitleCase.TitleCaseSingleWord(string) (private)` |
| Entry point | Common/SAIF.Common/Utility/TitleCase.cs |
Steps¶
- If the word already contains both an uppercase and a lowercase character, return it unchanged — it is assumed intentionally cased. (BR-015)
- Else if the uppercased word is in
UpperCaseWordList(SAIF, KPD, BW, AIC, LLC, LLP, DDS, MD, II, III, IV, NE, NW, SE, SW, PO, USA, CA, WA, OHSU), uppercase the whole word. (BR-016) - Else if the lowercased word is in
LowerCaseWordList(is, in, the, an, of, on, and, de), lowercase the whole word. (BR-017) - Else if the lowercased word matches an entry of
MixedCaseWordList(PhD,LaCombe), substitute that entry's exact casing. (BR-018) - Else if the word is digits plus an ordinal suffix (
HasNumberSuffix: digit-only stem plus one ofNumberSuffixes), keep the ordinal suffix lowercase. (BR-019) - Else apply
StringExtensions.ToProperCase(current-thread cultureTextInfo.ToTitleCaseover the lowercased word). - If the result starts with a
MixedCasePrefixListprefix (Mc,O'), split at the prefix and proper-case the remainder somcmahonbecomesMcMahon. (BR-018)
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["Called once per split word<br>by OP-001 step 4"]) --> D1{"Contains both upper and<br>lower case characters?"}
D1 -->|Yes| R1["Return word unchanged"]
D1 -->|No| D2{"Uppercased word is in<br>UpperCaseWordList?"}
D2 -->|Yes| R2["Uppercase the whole word"]
D2 -->|No| D3{"Lowercased word is in<br>LowerCaseWordList?"}
D3 -->|Yes| R3["Lowercase the whole word"]
D3 -->|No| D4{"Lowercased word matches a<br>MixedCaseWordList entry?"}
D4 -->|Yes| R4["Substitute the entry's<br>exact casing"]
D4 -->|No| D5{"Word is digits plus<br>an ordinal suffix?"}
D5 -->|Yes| R5["Keep the ordinal<br>suffix lowercase"]
D5 -->|No| R6["Apply ToProperCase<br>(current-thread culture<br>TextInfo.ToTitleCase)"]
R1 --> D6
R2 --> D6
R3 --> D6
R4 --> D6
R5 --> D6
R6 --> D6
D6{"Result starts with a<br>Mc or O' prefix?"}
D6 -->|Yes| S7["Split at the prefix and<br>proper-case the remainder"]
D6 -->|No| End(["Cased word returned"])
S7 --> End
Related documentation¶
Sources¶
Common/SAIF.Common/Utility/TitleCase.cs