#11 2010-08-31 21:40

auwebio
Member
From: Brazil
Registered: 2010-07-07
Posts: 45

Re: Title Case with delimeter option

hurshut wrote:

After trying your script, I understand why you were asking for clarification.

OK, it is perfectly clear now. smile   (I think...)

hurshut wrote:

rest of the words (other than first and last) first letter should be capitalized unless they are articles, prepositions, conjunctions, and forms of to be, if they are one of these, the first letter of the word should be lowercase

What you're describing to me sounds a lot like a looooooooooong way to say that:
every single word should be Capitalized, with 1 exception:
If the word is an article, preposition, conjunction or form of the verb to be AND the word is NOT the first or last in the sentence.

If this is true, I can see only 1 good way to do that:

( 1 )  * Capitalize Every Word
( 2 )  * lowercase all articles, prepositions, conjunctions and forms of the verb to be
( 3 )  * Capitalize all first and last words of the sentences (1st and 2nd).

( 1 ) and ( 2 ) could be done together if you use the option "Force case for fragments" or separately if you don't (you might use a Translit for number 2, for instance).
you might want to input your "Force case for fragments" like this

a,am,an,and,are,as,at,but,by,for,from,II,III,in,is,IV,nor,of,off,on,or,the,to,was,were,with,without,yet

or like this (if you wanna go a little bit further)

1st,2nd,3rd,a,al,an,and,as,at,ATB,ATFC,au,by,CD,da,das,de,del,des,DJ,DMX,dos,e,el,em,en,EP,et,for,from,II,III,in,INXS,is,iTunes,IV,la,las,le,les,los,MC,na,of,off,on,or,PM,pour,pra,SWV,the,TLC,to,TV,un,una,with,without,y

( 3 ) will probably have to be done by a PascalScript like this (assuming that your only delimiter is " - "):

// THIS SCRIPT Capitalizes EVERY 1ST AND LAST WORDS OF THE 2 SENTENCES USING " - " AS THE DELIMITER
var SPLT,WRDS: TStringsArray; i,t: integer; S1,S2: String;
begin
    // Split the 1st and 2nd Sentences
    If length(MatchesRegEx(FileName, '(.+?)(\s-\s)(.+)', False))>0 then begin
        SPLT := SubmatchesRegEx(FileName, '(.+?)(\s-\s)(.+)', False);
        // Process Sentence 1
            // Split the Words
            WRDS := WideSplitString(SPLT[0], ' ');
            //total word count
            t := Length(WRDS);
            // Capitalize the first word
            S1 := WideCaseCapitalize(WRDS[0]);
            // Add the rest of the words (if there is more than one)
            if (t >= 2) then for i := 1 to (t-1) do begin
                // Just add the next word to the sentence
                if (i <> (t-1)) then S1 := S1 + ' ' + WRDS[i]
                    // or else Capitalize the last word and add it to the sentence
                    else S1 := S1 + ' ' + WideCaseCapitalize(WRDS[i]);
            end;
        // Process Sentence 2
            // Split the Words
            WRDS := WideSplitString(SPLT[2], ' ');
            //total word count
            t := Length(WRDS);
            // Capitalize the first word
            S2 := WideCaseCapitalize(WRDS[0]);
            // Add the rest of the words (if there is more than one)
            if (t >= 2) then for i := 1 to (t-1) do begin
                // Just add the next word to the sentence
                if (i <> (t-1)) then S2 := S2 + ' ' + WRDS[i]
                    // or else Capitalize the last word and add it to the sentence
                    else S2 := S2 + ' ' + WideCaseCapitalize(WRDS[i]);
            end;
    // Re-Assemble the Filename with the new Capitalized Sentences
    FileName := S1 + SPLT[1] + S2;
    end;
end.

I know this looks like it's going up and down with the words more than once, but it is so much simpler that I think it might be worth the extra transformations (and less computing power required).

This is very important: I am assuming that you DO NOT have any "input string" that must stay in the exact form as it has arrived, e.g.: "Norah Jones - iTunes Originals" will become "Norah Jones - Itunes Originals" which is not OK here with me, but it might be OK accordingly to your rules. If it is not, we're now talking about thinking ahead even more and further customizing the preset to suit ALL of your preferences (mainly in the "Force case for fragments" section).

What I'm trying to say is that if you have reached a point where you have your very own personalized way to treat the Word Cases, you'll probably have to build a somewhat lengthy preset with multiple rules and probably some personalized scripts until you can get it  to act exactly the way you want. Luckily for us, ReNamer allow us to do exactly that. smile

Offline

#12 2010-08-31 23:21

hurshut
Member
Registered: 2010-06-25
Posts: 7

Re: Title Case with delimeter option

Stefan wrote:

Understood.
But what word are "articles, prepositions, conjunctions, ..." you have to add to the script at your own.

I am OK with that.

Stefan wrote:

The tools i know all use Title Case the same as i did. Because non of this tools are aware of "articles, prepositions, conjunctions, ..." .
All just makes the first letter of all words upper case.

http://titlecase.com

"Boards Of Canada" becomes "Boards of Canada"

"Boards Of A Canada" becomes "Boards of a Canada"

and

as you can see this site calls your way "Start Case"

RenameMaster also differentiate your way which is called "Capitalize Words"  with "Title Case"

also

https://secure.wikimedia.org/wikipedia/ … ion_titles

"The     Vitamins     are     in     My     Fresh     California     Raisins  >    Capitalization of all words, except for articles, prepositions, conjunctions, and forms of to be
...
This family of typographic conventions is usually called title case."

I believe the "family of conventions" is critical part so there no specific rules for title case.

Stefan wrote:

That could be if ' is an word separator. But i didn't see this behavior anyway while using any of my script above?!??

I tried your old script again it modifies
Bonnie 'Prince' Billie - Ain't You Wealthy, Ain't You Wise" to "Bonnie 'Prince' Billie - Ain'T You Wealthy, Ain'T You Wise"

I'll try the new scripts tomorrow, thanx guys.

Offline

#13 2010-09-01 07:17

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Title Case with delimeter option

hurshut wrote:
Stefan wrote:

That could be if ' is an word separator. But i didn't see this behavior anyway while using any of my script above?!??

I tried your old script again it modifies
"Bonnie 'Prince' Billie - Ain't You Wealthy, Ain't You Wise" to
"Bonnie 'Prince' Billie - Ain'T You Wealthy, Ain'T You Wise"

Interesting. Not in my part of the world big_smile (English WindowsTM MUI set to German)
But i would think this "word separator" thinggy is part of the app, not of WindowsTM?
But i don't remember an setting in ReNamer do set this.

I tried it again too:

First Script:
"Bonnie 'Prince' Billie - Ain't you wealthy, ain't you wise"

Second Script:
"Bonnie 'Prince' Billie - Ain't You Wealthy, Ain't You Wise"

Third Script //LowerCase(FileName):
"Bonnie 'Prince' Billie - Ain't You Wealthy, Ain't You Wise"

Third Script with LowerCase(FileName):
"Bonnie 'prince' Billie - Ain't you wealthy, ain't you Wise"


*I* didn't get "Ain'T", sorry.

.


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#14 2010-09-01 12:28

hurshut
Member
Registered: 2010-06-25
Posts: 7

Re: Title Case with delimeter option

You are right Stefan I tried a dummy file with ain't in the name and it did not modify it. It still seems to modify "Bonnie 'Prince' Billie - Ain't you wealthy, ain't you wise". Strange... I'll figure something out.

I tried auwebio's script and it works fine. Only problem is it does not preserve extension and roman numerals but i fixed that problem with an extra line of case rule.


For anyone who wants a to do something similar. Here are the words that should be lowercase (the words that should be inserted into "force fragments" in auwebio's solution):


a,an,the,and,but,yet,but,for,so,nor,or,either,neither,both,whether,also,from,in,of,off,on,to,with,onto,upon,up,down,than,via,per,over,under,until,till,past,next,as,at,by,ago,away,aside,apart,out of,because of,about,across,after,along,among,around,before,behind,below,beside,besides,between,beyond,despite,during,except,following,including,inside,into,near,next,outside,since,times,toward,towards,unlike,within,without,thanks to,as well as,as far as,me,myself,mine,my,us,ourselves,ours,our,yourself,yours,your,him,himself,his,her,herself,hers,itself,its,oneself,one's,them,themselves,theirs,their,you,we,they,it,he,she,this,that,these,those,many,much,few,several,most,each,every,any,such,some,any,which,what,whichever,whatever,a lot of,several,more,no,a few,a little,some,all,another,other,others,who,whoever,whom,whomever,whose,no one,nobody,none,nothing,somebody,someone,something,another,anybody,anyone,anything,everybody,everyone,everything,will be,have been,has been,had been,is,are,was,were,am,be,being,been

For people who prefer a different style of title case, here is the version with descriptions so that you can modify:

Articles:
a,an,the

Conjunctions:
and,but,yet,but,for,so,nor,or,either,neither,both,whether,also

Prepositions:
from,in,of,off,on,to,with,onto,upon,up,down,than,via,per,over,under,until,till,past,next,as,at,by,ago,away,aside,apart,out of,because of,about,across,after,along,among,around,before,behind,below,beside,besides,between,beyond,despite,during,except,following,including,inside,into,near,next,outside,since,times,toward,towards,unlike,within,without,thanks to,as well as,as far as


Personal pronouns:
me,myself,mine,my,us,ourselves,ourself,ours,our,yourself,yours,your,him,himself,his,her,herself,hers,itself,its,oneself,one's,them,themself,themselves,theirs,their,you,we,they,it,he,she

Determiners and other prenouns:
this,that,these,those,many,much,few,several,most,each,every,any,such,some,any,which,what,whichever,whatever,a lot of,several,more,no,a few,a little,some,all,another,other,others,who,whoever,whom,whomever,whose,no one,nobody,none,nothing,somebody,someone,something,another,anybody,anyone,anything,everybody,everyone,everything


Forms of To Be:
will be,have been,has been,had been,is,are,was,were,am,be,being,been

Offline

Board footer

Powered by FluxBB