Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert UpperCase to Sentence?
Message
De
20/11/2012 07:27:42
 
 
À
20/11/2012 04:14:12
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01557608
Message ID:
01557633
Vues:
68
J'aime (1)
>>
lcText = "THIS IS A SAMPLE.  SENTENCE STRUCTURE."
>>? lcText
>>llCapital = .t.
>>FOR lnI = 1 to LEN(lcText)
>>    lcChar = SUBSTR(lcText, lnI, 1)
>>    DO CASE
>>        CASE lcChar = SPACE(1)
>>            * Do nothing
>>        OTHERWISE
>>            lcText = STUFF(lcText, lnI, 1, IIF(llCapital, UPPER(lcChar), LOWER(lcChar)))
>>            llCapital = (lcChar $ ".?!")
>>    ENDCASE
>>NEXT
>> lcText = STRTRAN(lcText, " i ", " I ")
>> lcText = STRTRAN(lcText, "monday", "Monday")
>> lcText = STRTRAN(lcText, "tuesday", "Tuesday")
>>* et cetera
>>? lcText
>
>In the end, you'll have about 50 cases in there, to satisfy the one rule of capitalization in english capitalism language ("there are no rules, we have lists"). First, you need to capitalize the solo i, then the days of the week, then sometimes months (but you May run into trouble on that March) and an occasional moon, plus the need to distinguish between Mercury in orbit and mercury in a thermometer. Then the oddities like dutch last names with the article or prefix remaining lowercase, like deVries, or things like O'Keefe but not O'Clock. Then there are mentions of vi editor (always lower case) and the roman VI numeral (always upper). And there'll be more.
>
>Congratulations, you're well on your way of writing the first AI in VFP :).

I added a few post-processing STRTRAN() to handle the known odd cases.

My thoughts were the OP was not desiring a perfect, complete, wholly-encompassing-for-the-English-Language solution, but rather one which simply put things closer to being in proper mixed case, rather than all upper case.

Perhaps I was wrong in that assumption.

Best regards,
Rick C. Hodgin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform