Re: str.title() fails with words containing apostrophes

2017-03-07 Thread D'Arcy Cain
On 2017-03-06 06:33 PM, Steve D'Aprano wrote: If you read "title case" as *literally* as being only for titles (of books, I believe there is only one conclusion to be drawn from this thread - There is still a place for human proofreaders. I'm taking that as good news. -- D'Arcy J.M. Cain V

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Jussi Piitulainen
Marko Rauhamaa writes: > Steve D'Aprano wrote: >> I came across this book title: >> >> Täällä Pohjantähden alla (‘Here beneath the North Star’) >> >> http://www.booksfromfinland.fi/1980/12/the-strike/ >> >> which is partly title case, but I'm not sure what rule is being >> applied there. My guess

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Jussi Piitulainen
Steve D'Aprano writes: > On Tue, 7 Mar 2017 03:28 am, Grant Edwards wrote: >> >> Besides locale-aware, it'll need to be style-guide-aware so that it >> knows whether you want MLA, Chicago, Strunk & White, NYT, Gregg, >> Mrs. Johnson from 9th grade English class, or any of a dozen or two >> others

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Marko Rauhamaa
Chris Angelico : > On Tue, Mar 7, 2017 at 12:03 PM, Marko Rauhamaa wrote: >> >> As for the UK: >> >>Yhdistynyt kuningaskunta > > About the only part of that that I understand is "kuning" == > king/queen/kingdom. I swear, you like the letter 'y' more than the > Welsh do... The Proto-Finnic bo

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Chris Angelico
On Tue, Mar 7, 2017 at 4:18 PM, Steven D'Aprano wrote: > On Tue, 07 Mar 2017 12:18:13 +1100, Chris Angelico wrote: > >> On Tue, Mar 7, 2017 at 12:03 PM, Marko Rauhamaa >> wrote: >>> >>> As for the UK: >>> >>>Yhdistynyt kuningaskunta >> >> About the only part of that that I understand is "kuni

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Steven D'Aprano
On Tue, 07 Mar 2017 12:18:13 +1100, Chris Angelico wrote: > On Tue, Mar 7, 2017 at 12:03 PM, Marko Rauhamaa > wrote: >> >> As for the UK: >> >>Yhdistynyt kuningaskunta > > About the only part of that that I understand is "kuning" == > king/queen/kingdom. I swear, you like the letter 'y' more

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Chris Angelico
On Tue, Mar 7, 2017 at 12:03 PM, Marko Rauhamaa wrote: > > As for the UK: > >Yhdistynyt kuningaskunta About the only part of that that I understand is "kuning" == king/queen/kingdom. I swear, you like the letter 'y' more than the Welsh do... ChrisA -- https://mail.python.org/mailman/listinf

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Marko Rauhamaa
Steve D'Aprano : > On Tue, 7 Mar 2017 01:03 am, Marko Rauhamaa wrote: > If you read "title case" as *literally* as being only for titles (of > books, for instance) then of course you are right. Finnish book titles > are normally written in sentence case (initial capital, followed by > all lowercas

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Steve D'Aprano
On Tue, 7 Mar 2017 01:03 am, Marko Rauhamaa wrote: > Chris Angelico : > >> Right. If you want true title casing, it has to be *extremely* >> linguistically-aware. > > For instance, title case has no meaning in the context of Finnish. In > other words, your internationalized program shouldn't eve

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Grant Edwards
On 2017-03-06, Steve D'Aprano wrote: > On Tue, 7 Mar 2017 03:28 am, Grant Edwards wrote: > >> On 2017-03-06, Chris Angelico wrote: >> >>> Still, it's fun to discuss, if only to show why that kind of >>> locale-aware transformation is important. >> >> Besides locale-aware, it'll need to be style

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Steve D'Aprano
On Tue, 7 Mar 2017 03:28 am, Grant Edwards wrote: > On 2017-03-06, Chris Angelico wrote: > >> Still, it's fun to discuss, if only to show why that kind of >> locale-aware transformation is important. > > Besides locale-aware, it'll need to be style-guide-aware so that it > knows whether you wan

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Grant Edwards
On 2017-03-06, Chris Angelico wrote: > Still, it's fun to discuss, if only to show why that kind of > locale-aware transformation is important. Besides locale-aware, it'll need to be style-guide-aware so that it knows whether you want MLA, Chicago, Strunk & White, NYT, Gregg, Mrs. Johnson from 9

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread D'Arcy Cain
On 2017-03-06 05:04 AM, Peter Otten wrote: Won't Steve D'aprano And D'arcy Cain Be Happy Now :) Perhaps one could limit the conversion to go from lower to upper only, as names tend be in the desired case in the original text. That would help with acronyms as well. -- D'Arcy J.M. Cain Vybe Ne

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Marko Rauhamaa
Chris Angelico : > Right. If you want true title casing, it has to be *extremely* > linguistically-aware. For instance, title case has no meaning in the context of Finnish. In other words, your internationalized program shouldn't even think of title case when localized in Finnish. This localizat

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Chris Angelico
On Mon, Mar 6, 2017 at 9:04 PM, Peter Otten <__pete...@web.de> wrote: > Perhaps one could limit the conversion to go from lower to upper only, as > names tend be in the desired case in the original text. No, that just tends to make things confusing to use. > Unfortunately this won't help with > >

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Peter Otten
Jussi Piitulainen wrote: > gvm...@gmail.com writes: > >> On Sunday, March 5, 2017 at 11:25:04 PM UTC+5:30, Steve D'Aprano wrote: >>> I'm trying to convert strings to Title Case, but getting ugly results >>> if the words contain an apostrophe: >>> >>> >>> py> 'hello world'.title() # okay >>> 'H

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Jussi Piitulainen
gvm...@gmail.com writes: > On Monday, March 6, 2017 at 2:37:11 PM UTC+5:30, Jussi Piitulainen wrote: >> gvm...@gmail.com writes: >> >> > On Sunday, March 5, 2017 at 11:25:04 PM UTC+5:30, Steve D'Aprano wrote: >> >> I'm trying to convert strings to Title Case, but getting ugly results >> >> if the

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread gvmcmt
On Monday, March 6, 2017 at 2:37:11 PM UTC+5:30, Jussi Piitulainen wrote: > gvm...@gmail.com writes: > > > On Sunday, March 5, 2017 at 11:25:04 PM UTC+5:30, Steve D'Aprano wrote: > >> I'm trying to convert strings to Title Case, but getting ugly results > >> if the words contain an apostrophe: > >

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread gvmcmt
On Sunday, March 5, 2017 at 11:25:04 PM UTC+5:30, Steve D'Aprano wrote: > I'm trying to convert strings to Title Case, but getting ugly results if the > words contain an apostrophe: > > > py> 'hello world'.title() # okay > 'Hello World' > py> "i can't be having with this".title() # not okay > "

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread Jussi Piitulainen
gvm...@gmail.com writes: > On Sunday, March 5, 2017 at 11:25:04 PM UTC+5:30, Steve D'Aprano wrote: >> I'm trying to convert strings to Title Case, but getting ugly results >> if the words contain an apostrophe: >> >> >> py> 'hello world'.title() # okay >> 'Hello World' >> py> "i can't be having

Re: str.title() fails with words containing apostrophes

2017-03-06 Thread gvmcmt
On Sunday, March 5, 2017 at 11:25:04 PM UTC+5:30, Steve D'Aprano wrote: > I'm trying to convert strings to Title Case, but getting ugly results if the > words contain an apostrophe: > > > py> 'hello world'.title() # okay > 'Hello World' > py> "i can't be having with this".title() # not okay > "

Re: str.title() fails with words containing apostrophes

2017-03-05 Thread D'Arcy Cain
On 2017-03-05 03:40 PM, Terry Reedy wrote: import re def title(string): return re.sub(r"\b'\w", lambda m: m.group().lower(), string.title()) Nice. It lowercases a word char that follows an "'" that follows a word without an intervening non-word char. It passes this test: print(title("'tim

Re: str.title() fails with words containing apostrophes

2017-03-05 Thread Terry Reedy
On 3/5/2017 2:38 PM, MRAB wrote: On 2017-03-05 17:54, Steve D'Aprano wrote: I'm trying to convert strings to Title Case, but getting ugly results if the words contain an apostrophe: py> 'hello world'.title() # okay 'Hello World' py> "i can't be having with this".title() # not okay "I Can'T B

Re: str.title() fails with words containing apostrophes

2017-03-05 Thread MRAB
On 2017-03-05 17:54, Steve D'Aprano wrote: I'm trying to convert strings to Title Case, but getting ugly results if the words contain an apostrophe: py> 'hello world'.title() # okay 'Hello World' py> "i can't be having with this".title() # not okay "I Can'T Be Having With This" Anyone have

str.title() fails with words containing apostrophes

2017-03-05 Thread Steve D'Aprano
I'm trying to convert strings to Title Case, but getting ugly results if the words contain an apostrophe: py> 'hello world'.title() # okay 'Hello World' py> "i can't be having with this".title() # not okay "I Can'T Be Having With This" Anyone have any suggestions for working around this? -