I had a problem earlier today where I needed to normalize text into title case, or proper case, or whatever the English language calls it. Essentially:
Of mice AnD mEN → Of Mice and Men
MY NAME IS SCOTT → My Name is Scott
Here’s the current doc: Would love input if theres an easier way to accomplish it. . .Also, for some reasons, now matter what I do, the Omitted Words function will catch any word excpet forthe. I think it might be a Coda bug?
Check it out and let me know what you think! Its pretty fun!
It also does the split, and then for each word a clear centralized switchif to see if the word should be ignored, lowercased, or title-cased. Then separately I’m capitalizing the whole sentence.
In your formula, there’s a .Split(",").FormulaMap(Trim(...)) within a loop — not an optimal approach since the splitting and trimming is unnecessarily repeated for each check. It’s much better to extract the splitting outside the loop — either as a separate column on the Omitted words table that’ll be already calculated to a nice trimmed list of text values, or in a WithName declaration in the start of the formula — similarly how I did in mine but yours would be @[Omitted Words].Words.Split(",").FormulaMap(CurrentValue.Trim()).WithName(...)
Yep — the issue with “the” is not a bug in Coda but your formula, here:
You think you’re testing whether it’s the first word that you’re currently processing — but in fact you’re testing that this is not what the sentence starts with. So if it’s the second “the” in your sentence, list.Find(CurrentValue) will still return 1 because the first word is also “the”.
To properly implement it your way, you’d have to Sequence().FormulaMap() over indices and test whether CurrentValue is 1. I thought of that, but then I thought it was easier to just “title case” everything including the first word, and then capitalize the first character of the sentence separately afterwards.