Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

name initials in all caps string gets incorrectly lower cased #5

Open
foobargeez opened this issue Oct 9, 2018 · 6 comments
Open

Comments

@foobargeez
Copy link

foobargeez commented Oct 9, 2018

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
Copy link
Author

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

@ap
Copy link
Owner

ap commented Oct 19, 2018

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?

@foobargeez
Copy link
Author

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!

@ap
Copy link
Owner

ap commented Oct 20, 2018

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)?

@foobargeez
Copy link
Author

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:

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? :-)

@ap
Copy link
Owner

ap commented Oct 16, 2024

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:

This one doesn’t implement Gruber’s rules at all.

This one, when given all-caps input, preserves most words in all-uppercase, and when given all-lowercase input, matches the “a.p” output of this code.

This one, when switched to NY Times rules, matches the “a.p” output of this code.

The same is true for John Gruber’s latest published version (from 2015 as of this writing).

I’m inclined to reject this one…

However: if John himself agrees with the suggestion, then I will accept it with no questions asked. So you can try pinging him about it, or wait until I get around to it. (I want to ask him whether he has made any further changes to his code in the 9 years since, anyway.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants