Loading ...
Sorry, an error occurred while loading the content.

RE: [Clip] Re: Headline Case help

Expand Messages
  • John Shotsky
    Not sure about the email, I ve been getting emails all day, though none from you. I double checked my Comcast spam filter and nothing is in it, so I can only
    Message 1 of 19 , Oct 13, 2009
    • 0 Attachment
      Not sure about the email, I've been getting emails all day, though none from you. I double checked my Comcast spam
      filter and nothing is in it, so I can only presume there was something wrong with the address, since I've received
      emails from you in the past.

      What your clip, and the text file below represents, is what is called 'intelligent capitalization'. It is used for
      titles of books, articles, recipes, etc. Certain words should always be lower-case in titles, unless they are the first
      or last word in the title. There are a few other rules too, such as when an alternate title follows in parens, it must
      follow the same rules, even though it is inside the parens. It has proven quite tricky to implement, but it should be a
      good sample for NoteTab's sample clips, as such a function might be handy for others as well as providing some
      outstanding programming techniques.

      Thanks again!
      John Shotsky
      jshotsky@...

      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of flo.gehrke
      Sent: Tuesday, October 13, 2009 18:12
      To: ntb-clips@yahoogroups.com
      Subject: [Clip] Re: Headline Case help


      --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
      >
      > Wow, thanks, Flo!
      > ....

      Hi John,

      What's the matter with your email address? I tried to sent you severeal emails but they all came back with "Mail
      delivery failed".

      If anyone wants to test this, here's the WORDLIST.TXT (courtesy John)...

      a
      á
      à
      ajo
      al
      ala
      alla
      and
      as
      at
      au
      aux
      avec
      but
      by
      coi
      con
      d
      de
      des
      di
      du
      due
      e
      el
      en
      estilo
      et
      eze
      for
      from
      für
      i
      in
      into
      l
      la
      like
      med
      mit
      nor
      o
      of
      on
      onto
      or
      ou
      para
      past
      per
      plus
      s
      so
      su
      sur
      the
      to
      un
      up
      upon
      v
      vagy
      w
      with
      y
      yet
      z
      ze

      Regards,
      Flo



      [Non-text portions of this message have been removed]
    • John Shotsky
      Flo, I m having a problem with this new clip. (The one with the array.) With debug on, I can see that it is cycling through the words in the list, but it
      Message 2 of 19 , Oct 24, 2009
      • 0 Attachment
        Flo,

        I'm having a problem with this new clip. (The one with the array.) With
        debug on, I can see that it is cycling through the words in the list, but it
        capitalizes every word in each title. It doesn't seem to ever hit the lower
        case function. It runs to the end with no errors, so I don't think it's an
        email issue. I copied your clip and example exactly out of this email.



        Any idea what could be happening?

        Thanks,

        John



        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf
        Of flo.gehrke
        Sent: Tuesday, October 13, 2009 5:07 PM
        To: ntb-clips@yahoogroups.com
        Subject: [Clip] Re: Headline Case help





        --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> ,
        "flo.gehrke" <flo.gehrke@...> wrote:
        >
        > --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> ,
        "John Shotsky" <jshotsky@> wrote:
        >
        > > Here's the sample title I used:
        > > Title a danger of the traffic you have to be aware of (a danger of
        > > the traffic you have to be aware of)
        >
        > Thanks, John. Now I can see the problem!
        >
        > Please replace the long ^!Find-line with...
        >
        > ^!Find "(?-i)(?<!Title\x20|\()\b(Of|The|To|With|A)\b(?!$|\x20\(|\))" RS
        >
        > In my test, this is doing the job.
        >
        > Regards,
        > Flo

        To all who followed this thread,

        Regarding the solution with wordlist file: Please note that the wordlist
        must not end with an empty line. That's the notorious problem with an empty
        value in alternations and arrays caused by empty lines from a list. You may
        also change the first two lines to...

        ^!Set
        %Search%=(^$StrReplace("^P";"|";"^$GetFileText(^$GetDocumentPath$WORDLIST.TX
        T)$";0;0)$)
        ^!Set %Search%=^$StrReplace("|)";")";"^%Search%";0;0)$

        If you prefer a solution without a big alternation and with simpler RegEx,
        try this...

        ; Assign wordlist to array
        ^!StatusShow Running!
        ^!SetScreenUpdate Off
        ^!SetListDelimiter ^%NL%
        ^!SetArray %Lower%=^$GetFileText(^$GetDocumentPath$TITLEWORDS.TXT)$
        ; Strip empty value from end of array (with courtesy of Eb)
        ^!If ^%Lower^%Lower0%% = ^%Empty% ^!Dec %Lower0%
        ; Capitalize titles
        ^!Jump Doc_Start
        ^!Find "^Title::.+$" RS
        ^!IfError Edit
        ^!Toolbar Capitalize
        ^!Goto Skip_-3

        :Edit
        ; Set selected words in titles to lower case
        ^!Set %ID%=1
        ^!Jump Doc_Start

        :Loop1
        ^!Find "^Title::.*\b^%Lower^%ID%%\b.*$" RIS
        ^!IfError Loop3

        :Loop2
        ^!Replace "^%Lower^%ID%%" >> "^%Lower^%ID%%" HIAS
        ^!Goto Loop1

        :Loop3
        ^!Inc %ID%
        ^!If ^%ID% > ^%Lower0% FirstInLine
        ^!Jump Doc_Start
        ^!Goto Loop1

        :FirstInLine
        ^!Jump Doc_Start
        ^!Find "^Title::\x20\K([[:lower:]]|"[[:lower:]])" RS
        ^!IfError AfterBracket
        ^!Toolbar Upper Case
        ^!Goto Skip_-3

        :AfterBracket
        ^!Jump Doc_Start
        ^!Find "^Title::.+\(\K([[:lower:]]|"[[:lower:]])" RS
        ^!IfError BeforeClosBracket
        ^!Toolbar Upper Case
        ^!Goto Skip_-3

        :BeforeClosBracket
        ^!Jump Doc_Start
        ^!Find "^Title::.+\x20\K[[:lower:]]+\)" RS
        ^!IfError BeforeOpenBracket
        ^!Toolbar Capitalize
        ^!Goto Skip_-3

        :BeforeOpenBracket
        ^!Jump Doc_Start
        ^!Find "^Title::.+\x20\K[[:lower:]]+\x20\(" RS
        ^!IfError End
        ^!Toolbar Capitalize
        ^!Goto Skip_-3

        :End
        ^!StatusClose
        ^!Jump Doc_Start
        ^!Info Finished!

        I've tested it with the following sample text and NT Pro 6.12 (all in long
        lines - no hard line breaks!)

        any text
        any text
        Title:: a danger of the traffic you have to be aware of (a danger of the
        traffic you have to be aware of)
        any text
        Title:: "a cup of joe's" beer with crackers
        Title:: conejo en salmorejo (kaninchen in beize)
        any text
        Title:: a danger of the traffic you have to be aware of (a danger of the
        traffic you have to be aware of)
        any text
        any text
        Title:: potaje de trigo (eintopf mit weizen)
        any text
        any text
        any text
        Title:: a danger of the traffic you have to be aware of (a danger of the
        traffic you have to be aware of)
        any text
        any text
        any text
        Title:: a danger of the traffic you have to be aware of (a danger of the
        traffic you have to be aware of)

        Regards,
        Flo





        [Non-text portions of this message have been removed]
      • flo.gehrke
        ... John, My first suspicion is this: Due to email problems with Comcast.net (missing Reverse DNS) an important information possibly got lost: The version with
        Message 3 of 19 , Oct 24, 2009
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:

          > Flo,
          >
          > I'm having a problem with this new clip. (The one with the array.)
          > With debug on, I can see that it is cycling through the words in
          > the list, but it capitalizes every word in each title. It doesn't
          > seem to ever hit the lower case function.

          John,

          My first suspicion is this:

          Due to email problems with Comcast.net (missing Reverse DNS) an important information possibly got lost: The version with array is using a TitleWords.txt containing entries in lower case (whereas the first word list was in upper case).

          Please try the list below.

          I also experienced that mistakes sneak into code sometimes when copying it from an email. For example: Lines with a single space where originally was an empty line. So please watch out for possible glitches like that.

          Regards,
          Flo


          en
          de
          a
          à
          á
          ajo
          al
          ala
          alla
          and
          as
          at
          au
          aux
          avec
          but
          by
          coi
          con
          d
          des
          di
          du
          due
          e
          el
          estilo
          et
          eze
          for
          from
          für
          i
          in
          into
          l
          la
          like
          med
          mit
          nor
          o
          of
          on
          onto
          or
          ou
          para
          past
          per
          plus
          s
          so
          su
          sur
          the
          to
          un
          up
          upon
          v
          vagy
          w
          with
          y
          yet
          z
          ze
        • John Shotsky
          Yes, that was the problem. Thanks again, I’ll do further testing, but it looks like it’s doing the right thing now. John From: ntb-clips@yahoogroups.com
          Message 4 of 19 , Oct 24, 2009
          • 0 Attachment
            Yes, that was the problem.



            Thanks again, I’ll do further testing, but it looks like it’s doing the
            right thing now.

            John



            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf
            Of flo.gehrke
            Sent: Saturday, October 24, 2009 8:14 AM
            To: ntb-clips@yahoogroups.com
            Subject: [Clip] Re: Headline Case help







            --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> ,
            "John Shotsky" <jshotsky@...> wrote:

            > Flo,
            >
            > I'm having a problem with this new clip. (The one with the array.)
            > With debug on, I can see that it is cycling through the words in
            > the list, but it capitalizes every word in each title. It doesn't
            > seem to ever hit the lower case function.

            John,

            My first suspicion is this:

            Due to email problems with Comcast.net (missing Reverse DNS) an important
            information possibly got lost: The version with array is using a
            TitleWords.txt containing entries in lower case (whereas the first word list
            was in upper case).

            Please try the list below.

            I also experienced that mistakes sneak into code sometimes when copying it
            from an email. For example: Lines with a single space where originally was
            an empty line. So please watch out for possible glitches like that.

            Regards,
            Flo

            en
            de
            a
            à
            á
            ajo
            al
            ala
            alla
            and
            as
            at
            au
            aux
            avec
            but
            by
            coi
            con
            d
            des
            di
            du
            due
            e
            el
            estilo
            et
            eze
            for
            from
            für
            i
            in
            into
            l
            la
            like
            med
            mit
            nor
            o
            of
            on
            onto
            or
            ou
            para
            past
            per
            plus
            s
            so
            su
            sur
            the
            to
            un
            up
            upon
            v
            vagy
            w
            with
            y
            yet
            z
            ze





            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.