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

Changing titles to links

Expand Messages
  • Phil
    Thanks to those who have helped me in the past, sorry I have not been able to pay back by helping anyone else. I do have a task which is exceedingly tedious,
    Message 1 of 8 , May 19 6:54 AM
      Thanks to those who have helped me in the past, sorry I have not been able to pay back by helping anyone else. I do have a task which is exceedingly tedious, so hope automation will help. My goal is to change titles to links. Some of this must be done outside NoteTab but I hope some steps can be automated.

      Here is sample data:



      * Ishizaka, M., 2004: Climatic response of snow depth to recent warmer winter seasons in heavy-snowfall areas in Japan. Ann. Glaciol., 38, 299–304.

      * Ivins, E. R., and T. S. James, 2005: Antarctic glacial isostatic adjustment: A new assessment. Antarct. Sci., 17, 541–553.

      * Ivins, E. R., M. M. Watkins, D. N. Yuan, R. Dietrich, G. Casassa, and A. Rulke, 2011: On-land ice loss and glacial isostatic adjustment at the Drake Passage: 2003–2009. J. Geophys. Res. Sol. Ea., 116, 24 (B02403).

      * Nesje, A., O. Lie, and S. O. Dahl, 2000: Is the North Atlantic Oscillation reflected in Scandinavian glacier mass balance records? J. Quat. Sci., 15, 587–601.


      I see the process as having four steps:
      1. Add the code for the link
      2. Select the title
      3. Google the title
      4. copy the link

      I assume that only the first two can be done in Notetab, but my experience is that it is best to explain the whole process, not just the narrow request.

      Here is the first entry after step 1:
      * Ishizaka, M., 2004: [ Climatic response of snow depth to recent warmer winter seasons in heavy-snowfall areas in Japan]. Ann. Glaciol., 38, 299–304.

      Note the left square bracket and right square bracket

      I can almost do this with a search and replace. However, searching for ": " and replacing with ": [ " doesn't quite work, because there are examples (see the second entry) where there is a colon that shouldn't be replaced. The good news is I can specify the rule - only do the replacement when it follows a year. The bad news, I don't know how to code such a rule.

      The right bracket needs to be placed before the first period following the colon. I don't quite know how to do that, but suspect it would be simple, except for a complication - if the title ends in a question marl, then the title is not terminated with a period (see the fourth item in the example). In that case, the right bracket needs to go after the question mark. (If this is difficult, I can accept placing it before, and I can manually search for the exceptions)

      Then I would like to select the title, the portion of the entry now between the left and right square brackets. This may be as far as I can go in Note Tab. I would copy the title to a Google search and then copy the resulting url, which may not be the first one coming up, and place it after the first square bracket.

      For example the first entry becomes:
      * Ishizaka, M., 2004: [http://www.researchgate.net/publication/233486111_Climatic_response_of_snow_depth_to_recent_warmer_winter_seasons_in_heavy-snowfall_areas_in_Japan Climatic response of snow depth to recent warmer winter seasons in heavy-snowfall areas in Japan]. Ann. Glaciol., 38, 299–304.

      The results are then copied to
      http://ipcc.wikia.com/wiki/154_References

      (You can see that I have done a few hundred, but I'm only up to Howat, and this is one of 14 chapters)

      The steps aren't all that hard to do manually, but there are over ten thousand entries, so I'd like to simplify whatever I can.

      Phil

    • flo.gehrke
      ... With regard to inserting the left and right bracket try... ^!Replace d{4}: x20 K [ WARS ^!Replace : x20 [[^.?]+ x3F? K ] WARS It s not quite
      Message 2 of 8 , May 19 9:20 AM
        ---In ntb-clips@yahoogroups.com, Phil <freetochoose@...> wrote :

        > My goal is to change titles to links...

        With regard to inserting the left and right bracket try...

        ^!Replace "\d{4}:\x20\K" >> "[" WARS
        ^!Replace ":\x20\[[^.?]+\x3F?\K" >> "]" WARS

        It's not quite clear whether there is a space following the '[' bracket or not. In my pattern, I left it out.

        Now you could select the titles with...

        ^!Find "\[[^]]+\]" RS

        Please note that this is tested with your four samples only -- I can't guarantee that this will work with ANY title.

        You possibly could also place the resulting URLS after each first square bracket by clip. Just put them into the same order as the titles, assign them to an array etc...

        Regards,
        Flo
         


      • Phil
        Thanks Flo, I will try that. Phil On Monday, May 19, 2014 12:20 PM, flo.gehrke@t-online.de [ntb-clips] wrote:   ... With regard
        Message 3 of 8 , May 19 9:55 AM
          Thanks Flo, I will try that.

          Phil
          On Monday, May 19, 2014 12:20 PM, "flo.gehrke@... [ntb-clips]" <ntb-clips@yahoogroups.com> wrote:


           
          ---In ntb-clips@yahoogroups.com, Phil <freetochoose@...> wrote :

          > My goal is to change titles to links...

          With regard to inserting the left and right bracket try...

          ^!Replace "\d{4}:\x20\K" >> "[" WARS
          ^!Replace ":\x20\[[^.?]+\x3F?\K" >> "]" WARS

          It's not quite clear whether there is a space following the '[' bracket or not. In my pattern, I left it out.

          Now you could select the titles with...

          ^!Find "\[[^]]+\]" RS

          Please note that this is tested with your four samples only -- I can't guarantee that this will work with ANY title.

          You possibly could also place the resulting URLS after each first square bracket by clip. Just put them into the same order as the titles, assign them to an array etc...

          Regards,
          Flo
           




        • John Shotsky
          Can you reliably use a close bracket within a negative class without escaping it? I do this a lot, but always escape it, and the opening one as well, if
          Message 4 of 8 , May 19 10:01 AM

            Can you reliably use a close bracket within a negative class without escaping it? I do this a lot, but always escape it, and the opening one as well, if needed.

             

            Regards,
            John
            RecipeTools Web Site: http://recipetools.gotdns.com/recipetools/
            John's Mags Yahoo Group:  http://groups.yahoo.com/group/johnsmags/

             

            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com]
            Sent: Monday, May 19, 2014 09:20
            To: ntb-clips@yahoogroups.com
            Subject: [Clip] Re: Changing titles to links

             

             

            ---In ntb-clips@yahoogroups.com, Phil <freetochoose@...> wrote :

             

            > My goal is to change titles to links...


            With regard to inserting the left and right bracket try...

            ^!Replace "\d{4}:\x20\K" >> "[" WARS
            ^!Replace ":\x20\[[^.?]+\x3F?\K" >> "]" WARS

            It's not quite clear whether there is a space following the '[' bracket or not. In my pattern, I left it out.

            Now you could select the titles with...

            ^!Find "\[[^]]+\]" RS

            Please note that this is tested with your four samples only -- I can't guarantee that this will work with ANY title.

            You possibly could also place the resulting URLS after each first square bracket by clip. Just put them into the same order as the titles, assign them to an array etc...

            Regards,
            Flo

             

             

          • Axel Berger
            ... To be honest, I wouldn t do it. The work and hassle is in finding the URL in the first place and the solution can t realistically be made general enough.
            Message 5 of 8 , May 19 10:17 AM
              "Phil freetochoose@... [ntb-clips]" wrote:
              > * Ishizaka, M., 2004: [ Climatic response of snow depth to recent warmer
              > winter seasons in heavy-snowfall areas in Japan]. Ann. Glaciol., 38,
              > 299–304.

              To be honest, I wouldn't do it. The work and hassle is in finding the URL
              in the first place and the solution can't realistically be made general
              enough. Two points though:
              1) I would not make the title into a link, I always choose the source for
              that, i.e. [Ann. Glaciol., 38, 299--304]
              2) You can at least automate formatting the link. After <Ctrl><C>-ing the
              URL and highlighting the text to become the link I run (many long lines):

              <a
              ^!Clip "×^?[Link to create==_Link|Link with image|Link with table|Link to
              bookmark|Bookmark|MailTo]"

              _×Link
              ^!Set %varURL%=^?{(T=O;F="Link Files|*.*")Enter a URL (add "a")};
              %varDSC%=^?{Enter a description for this link=^&}; %varEXT%=^?{(T=L)Type of
              Link=_|external|pdf|mail|webtv|mp3|word}
              ^!IfTrue ^$IsUrl("^%varURL%a.htm")$ SKIP
              ^!Set %varURL%=^$FileToUrl("^$GetRelativeName(^%varURL%)$")$
              ^!Set %varURL%=^$StrReplace("../";"/";"^%varURL%";False;False)$
              ^!Set %varURL%=^$StrReplace("&";"&";"^%varURL%";False;False)$
              ^!Set %varURL%=^$StrReplace("&amp;";"&";"^%varURL%";False;False)$
              ^!If "^$StrCopyRight("^%varURL%";2)$" <> "/a" SKIP
              ^!Set %varURL%=^$StrDeleteRight("^%varURL%";1)$
              ^!IfEmpty "^%varEXT%" empty
              ^!Goto ^%varEXT%
              :empty
              ^!InsertHtml <A HREF="^%varURL%">^%varDSC%</A>
              ^!Goto END
              :external
              ^!InsertHtml <A HREF="^%varURL%">^%varDSC% <IMG
              SRC="/pics/^%varEXT%.gif" CLASS="txt" BORDER="0" ALT="" TITLE="Externer
              Verweis"></A>
              ^!Goto END
              :pdf
              ^!InsertHtml <A HREF="^%varURL%">^%varDSC% <IMG
              SRC="/pics/^%varEXT%.gif" CLASS="txt" BORDER="0" ALT="" TITLE="PDF
              Dokument"></A>
              ^!Goto END
              :mail
              ^!InsertHtml <A HREF="^%varURL%">^%varDSC% <IMG
              SRC="/pics/^%varEXT%.gif" CLASS="txt" BORDER="0" ALT=""
              TITLE="eMail-Adresse"></A>
              ^!Goto END
              :webtv
              ^!InsertHtml <A HREF="^%varURL%">^%varDSC% <IMG
              SRC="/pics/^%varEXT%.gif" CLASS="txt" BORDER="0" ALT=""
              TITLE="Videofilmdatei"></A>
              ^!Goto END
              :mp3
              ^!InsertHtml <A HREF="^%varURL%">^%varDSC% <IMG
              SRC="/pics/^%varEXT%.gif" CLASS="txt" BORDER="0" ALT="" TITLE="MP3
              Audiodatei"></A>
              ^!Goto END
              :word
              ^!InsertHtml <A HREF="^%varURL%">^%varDSC% <IMG
              SRC="/pics/^%varEXT%.gif" CLASS="txt" BORDER="0" ALT="" TITLE="Office
              Dokument"></A>
              ^!Goto END

              Of course that's HTML syntax, not Wiki, but you get the gist.

              Axel
            • Phil
              That worked great, thanks Flo (Yes, there is a space after the [ but I could handle that.) You re the best Phil On Monday, May 19, 2014 12:55 PM, Phil
              Message 6 of 8 , May 19 10:27 AM
                That worked great, thanks Flo (Yes, there is a space after the [ but I could handle that.)

                You're the best
                Phil


                On Monday, May 19, 2014 12:55 PM, Phil <freetochoose@...> wrote:


                Thanks Flo, I will try that.

                Phil
                On Monday, May 19, 2014 12:20 PM, "flo.gehrke@... [ntb-clips]" <ntb-clips@yahoogroups.com> wrote:


                 
                ---In ntb-clips@yahoogroups.com, Phil <freetochoose@...> wrote :

                > My goal is to change titles to links...

                With regard to inserting the left and right bracket try...

                ^!Replace "\d{4}:\x20\K" >> "[" WARS
                ^!Replace ":\x20\[[^.?]+\x3F?\K" >> "]" WARS

                It's not quite clear whether there is a space following the '[' bracket or not. In my pattern, I left it out.

                Now you could select the titles with...

                ^!Find "\[[^]]+\]" RS

                Please note that this is tested with your four samples only -- I can't guarantee that this will work with ANY title.

                You possibly could also place the resulting URLS after each first square bracket by clip. Just put them into the same order as the titles, assign them to an array etc...

                Regards,
                Flo
                 






              • flo.gehrke
                ... No problem... (#1) if it s the only character in the Character Class. Test [^]] against a]b]c Matches a , b , and c . However, [^b]] matches a] ,
                Message 7 of 8 , May 19 1:25 PM
                  ---In ntb-clips@yahoogroups.com, <jshotsky@...> wrote :

                  > Can you reliably use a close bracket within a negative class
                  > without escaping it? I do this a lot, but always escape it, and the
                  > opening one as well, if needed

                  No problem...

                  (#1) if it's the only character in the Character Class.

                  Test '[^]]' against 'a]b]c'

                  Matches 'a', 'b', and 'c'. However, '[^b]]' matches 'a]', that is a non-b followed by a bracket because the second ']' is seen outside the Character Class. In this case, you have to write '[^b\]]' in order to match 'a' and 'c'.

                  (#2) if it's immediately following the opening bracket.

                  Test '[^]b]' against 'a\]b]c'

                  Matches 'a' and 'c'.

                  Anyway, I think you won't make a mistake when escaping it. From my point of view, we shouldn't escape what needs no escaping. There have been cases in which NT got confused by too many backslashes...

                  Regards,
                  Flo

                  P.S. From PCRE documentation:

                  SQUARE BRACKETS AND CHARACTER CLASSES

                  An opening square bracket introduces a character class, terminated by a
                  closing square bracket. A closing square bracket on its own is not spe-
                  cial. If a closing square bracket is required as a member of the class,
                  it should be the first data character in the class  (after  an  initial
                  circumflex, if present) or escaped with a backslash.
                • flo.gehrke
                  ... and , of course. Note: You can never test enough before posting ;-) Flo
                  Message 8 of 8 , May 19 1:45 PM
                    > Test '[^]b]' against 'a\]b]c'
                    > Matches 'a' and 'c'.

                    and '\', of course.

                    Note: You can never test enough before posting ;-)

                    Flo
                  Your message has been successfully submitted and would be delivered to recipients shortly.