-4

I'm very confused about this. In most programming languages, there are string.ToUpperCase(), string.ToLowerCase(), sometimes Capitalize() (which capitalize the first letter of the string), even ToTitleCase() which capitalize every first letter of everyword.

But why isn't there any ToCommonSenseCase()? The one that capitalize the first letter of each sentence? Why doesn't any language have it? I thought it should be the first utility function to implement case-wise.

AVAVT
  • 111
  • 3
  • see [On discussions and why they don't make good questions](https://softwareengineering.meta.stackexchange.com/q/6742/31260) – gnat Feb 23 '19 at 04:21
  • 1
    It is not a discussion. There should be a reason why it isn't implemented in any languages I know. It shouldn't be a coincidence that all those languages creators have the same *opinion* of omitting it. – AVAVT Feb 23 '19 at 04:26
  • Since there is likely not to be a single answer which applies to all languages and their creators, and we must conjecture the reasons for this, I think it does count as s discussion. – James McLeod Feb 23 '19 at 18:53
  • Theres no such thing as common sense. – whatsisname Feb 24 '19 at 03:47
  • Because determining where sentence boundaries fall is deceptively difficult. Try writing a sentence boundary detector, and you'll have a hard time getting anywhere near 100%. Therefore it would take far too much code for a peripheral utility routine in the standard library, – Kilian Foth Feb 25 '19 at 07:20

1 Answers1

6

That's called sentence case, and there are some challenges with it:

  • The word "I" needs to be capitalized, wherever it appears in the sentence. Granted, the programming language could detect that.
  • Proper nouns ('names') always need to be capitalized. These are a lot harder to detect programmatically; a dictionary alone won't even help since "Mark" is both a name and a common word.
  • A dot does not always signify the end of a sentence, e.g. when using abbreviations like this sentence does.
  • Other languages than English have different capitalization rules: for example, German capitalizes all nouns.

You see that a proper sentence casing tool is much more complicated that just transforming each letter to capital or lowercase form; that's why standard libraries don't have this functionality.

Glorfindel
  • 3,137
  • 6
  • 25
  • 33
  • Many languages have locale specific utilities for formatting numbers and dates. Seems like the same could be done for basic sentence capitalization. – user949300 Feb 23 '19 at 21:51
  • 1
    Then you get into [Why is quixotic not Quixotic (a proper adjective)?](https://english.stackexchange.com/q/486432) and decide a shot of Tequila sounds good about now. – Peter M Feb 23 '19 at 23:24