titlecase icon indicating copy to clipboard operation
titlecase copied to clipboard

name initials in all caps string gets incorrectly lower cased

Open foobargeez opened this issue 7 years ago • 6 comments

Does NOT work:

$> perl
use Lingua::EN::Titlecase::Simple qw(titlecase);

my $str = 'HAHA AND HEHE A.B TEAM UP';
print titlecase($str), "\n";

Haha and Hehe a.b Team Up
$>

Thanks!

foobargeez avatar Oct 09 '18 11:10 foobargeez

@ap would you be interested/willing to look into this? Thanks!

foobargeez avatar Oct 16 '18 16:10 foobargeez

Yes, I’ve meant to reply for a while. Sorry you’re having to wait.

Uhm, what is your expected output here? “A.b” or “A.B”? Can you provide a non-gibberish example sentence that illustrates the case?

ap avatar Oct 19 '18 13:10 ap

Uhm, what is your expected output here? “A.b” or “A.B”?

A.B

Can you provide a non-gibberish example sentence that illustrates the case?

Oh, no, my example is not gibberish :-) Anyway, how about this?

Input: MICHAEL AND JOHN A.P TEAM UP TO DO SOMETHING AWESOME! Output (current): Michael and John a.p Team Up to Do Something Awesome! Output (desired): Michael and John A.P Team up to Do Something Awesome!

foobargeez avatar Oct 19 '18 14:10 foobargeez

I guess that helps, insofar as it tells me that a simple example doesn’t make it obvious what’s going on linguistically. This “A.P” with a missing trailing period is not something I have ever seen or would normally write. How does it chunk? Is one person called “Michael” and the other “John A. P”? Are they “Michael A. P.” and “John A. P.”? Is “A.P” some kind of oddball nonstandard personal style (kinda like the people who insist their names be written in lowercase)?

ap avatar Oct 20 '18 05:10 ap

Thanks! I don't so much have control on the input text (often received from external sources). That being said, the way I saw the input above as - one person is called "Michael" and the other "John A.P" but I agree with you that there are other ways to look at it.

Just to make sure this isn't really a corner case, I tried the following online titlecase conversions and they all seem to match the desired output:

  • http://titlecase.com/
  • http://individed.com/code/to-title-case/
  • https://capitalizemytitle.com/

Is “A.P” some kind of oddball nonstandard personal style (kinda like the people who insist their names be written in lowercase)

Hmm ... I guess I didn't run into such a case with my input names at the least (about 10K names and counting) - who knows what could be next? :-)

foobargeez avatar Oct 20 '18 23:10 foobargeez