ROT13

Here is where the magnanimous folks that create externals post them (.zip archives only please).

Re: ROT13

Postby drpitcairn » Wed Oct 23, 2013 7:29 pm

I have been working on this formatting script most of the day and have it working pretty well. Basically what I did was to format (bold, color, etc.) the first 30 lines which is what the viewer will see after the search. Then the rest of the lines are formatted when a scrollbar is used or a search letter is typed (that goes to first letter of a remedy in the list). The advantage of this is that it splits the time up. The user can almost right away begin to read the results and if they then want more (and there is more than 30 lines) then that will come up fairly fast. I think it will work.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby codegreen » Thu Oct 24, 2013 10:47 am

Yeah, setting the style properties of chunks in fields via script is just too hopelessly inefficient an operation to do in bulk while the user is waiting (obviously another external is in order here...). BTW I assume you're aware that with quoted terms you're potentially hiliting things that don't match what the user searched for, right?

In the meantime your strategy of doing just what the user is looking at should probably let you squeak by. This version might be a bit faster and more flexible...

Code: Select all
on formatFieldResults startLine
  global searchTerms, tfieldName
  enum fldNum = num of cd fld tfieldName, numLines = 30, endLine = startLine + numLines - 1
  put the ticks into startTime
  set the textstyle of cd fld fldNum to plain
  get line startLine to endLine of cd fld fldNum
  put replace(searchTerms, quote, "") into theTerms
 
  set itemdel to ":"
  enum i = 0, lineNumber = startLine - 1
  repeat for each line theLine of it
    add 1 to i
    add 1 to lineNumber
    set the textstyle of item 1 of line lineNumber of cd fld fldNum to bold
    delete first item of theLine
    enum j = 0
    repeat for each word theWord of theLine
      add 1 to j
      if theWord starts with "(" then
        if isNumber(char 2 of theWord) then
          set textsize of word j of item 2 of line lineNumber of cd fld fldNum to 12
          next repeat
        end if
      end if
      repeat for each word theTerm in theTerms
        if theWord starts with theTerm then
          set the textcolor of word j of item 2 of line lineNumber of cd fld fldNum to 34
          exit repeat
        end if
      end repeat
    end repeat
  end repeat
  put the secs into stopTime
  put "The time was" && (the ticks -  startTime) && "ticks."
end formatFieldResults

I do have another question, as I realize there is some confusion in my head about what we are doing. When you send me a player project to try out, does that contain the script you post with it? That I am to try in my project? Or does it contain an external that you are developing? I realize that the "search now" script has become very fast without adding in any other externals to the project.
I ask partly because the player proj. you sent can search for quotes very nicely but my project cannot do that yet, at least with the script the way it is now.

Except where noted those projects contain both the scripts I posted and an external I wrote to replace the 'findTerms' handler of the earlier script version.

Although SC's raw script execution speed is pretty snappy (as evidenced by the fact that sucking the outer script loop that called the first findTerms external into the second version only improved performance by about 20% or so), trying to manipulate large chunks of text this way in a language which doesn't have the concept of pointers can never be anywhere near as efficient as doing it in one (like C) which does -- it just requires too much overhead.

I don't know what this project you're making is for, whether you plan to sell it or give it away, etc. Only you can decide whether the improved scripts alone are fast enough for your purposes, or whether you feel you need the extra performance boost of this external (and possibly another to format the results) and what that would be worth to you.

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby drpitcairn » Thu Oct 24, 2013 11:14 am

Mark,
Except where noted those projects contain both the scripts I posted and an external I wrote to replace the 'findTerms' handler of the earlier script version.

I had wondered if that is what I should do, get an external & scripts from the project but when I try to, it asks for a password. So I assumed that was not the thing to do. Should have asked sooner. Anyway, this last one downloaded, version 9, still has a password requirement.

BTW I assume you're aware that with quoted terms you're potentially hiliting things that don't match what the user searched for, right?

I don't have the quoted terms search working. Haven't really focused on it yet, but I know it does not work.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby codegreen » Thu Oct 24, 2013 2:15 pm

Here's a new version with an external to speed up the colorizing:

findTerms.sp45 10.zip
(36.9 KiB) Downloaded 526 times

Let me know if it does what you need...

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby drpitcairn » Thu Oct 24, 2013 4:05 pm

WOW! I see now why learning some of these more difficult languages (machine code?) is worth while. Amazing difference.
It does what I want except for some minor things.
If you look at the picture of finding "inflam" with the intention of finding all the words starting with those letters, it does that, but then the color is applied only to those search letters rather than the whole word. I don't know if it CAN color the whole word, if even possible, but my script does the whole word so asking.
inflam.gif
searching for "inflam"
inflam.gif (36.96 KiB) Viewed 19134 times

Then another thing is that there are some words in the text like "Aggravation:" and "Complementary:" that look redundant in the results to have the colon, so my script puts in a hyphen instead. Yours does that too, but could there be a space before the hyphen? So a space before and after? If not difficult might look even nicer with an en dash, though that not really important. See this picture for an example. Searched for "Aggrav"
aggrav..gif
search for "Aggrav."
aggrav..gif (33.26 KiB) Viewed 19134 times

Lastly, your output has a blank line between each sentence which makes it easier to read. In my script I format the field that holds the results a little differently. Here is the script for that:
Code: Select all
set the textstyle of cd fld "searchResults" of cd "search" to plain
  set the textcolor of cd fld "searchResults" of cd "search" to 256
  set the textfont of cd fld "searchresults" of cd "search" to "Verdana"
  set the textsize of cd fld "searchresults" of cd "search" to 14
  set the textcolor of cd fld "searchResults" of cd "search" to 256
  set the leftindent of cd fld "searchresults" of cd "search" to 20
  set the firstlineindent of cd fld "searchresults" of cd "search" to -20
  set the spaceafter of cd fld "searchresults" of cd "search" to 5
  set the focusHilite of cd fld "searchresults" of cd "search" to false
end openwindow

So if I use this script it will be easier to have the output without the blank lines.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby codegreen » Thu Oct 24, 2013 5:11 pm

Is this better?

findTerms.sp45 11.zip
(37.17 KiB) Downloaded 536 times
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby drpitcairn » Thu Oct 24, 2013 6:52 pm

Appearance perfect.

I am trying some searches with it, and noticed this anomaly, though may not be important.
I searched for "aggrav" with this result:
348 remedies consisting of 17117 lines searched, 196.5 results found. Elapsed time = 57 milliseconds.

I then did the same search in my project, got 393 lines instead of 196.5. So I copied the lines in your project output and pasted into another project field, and put the num of lines in the field and it was 393. So the number is the same but the report line is off.
I think what is happening is that it is report half of the total lines because if we double 196.5 we get 393. To check I searched for "prostate" and your proj. says 6 lines and my project says 12 for the same search.
So a tweak needed here if it matters.

I have not found anything else to mention. Works beautifully. I love the en dash. I am amazed you can do this so quickly.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby codegreen » Thu Oct 24, 2013 11:41 pm

Sorry, I forgot to tell the timing code each result was now just one line -- no biggie...

Here's a fix:

findTerms.sp45 12.zip
(37.11 KiB) Downloaded 555 times
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby drpitcairn » Fri Oct 25, 2013 9:35 am

I ran no. 12 and have a few things to report.

1) If a search word is preceded by a parenthesis, it is not being colored. See these two pictures. The first one was searching for the word "Nux-v." and the second for the word "hungry".
nux-paren..gif
search for "Nux-v."
nux-paren..gif (49.2 KiB) Viewed 19112 times

hungry.gif
search for "hungry"
hungry.gif (17.81 KiB) Viewed 19112 times

2) Searching for author abbreviations that are found in brackets are not colored. First picture was search for [Pit.] and the second for [A.}
pit.gif
search for "[Pit.]"
pit.gif (37.18 KiB) Viewed 19112 times

pit.gif
search for "[Pit.]"
pit.gif (37.18 KiB) Viewed 19112 times


On another note, regarding the word search external, can we another exclusion? If you remember that certain lines were excluded from the search, as in this script:
Code: Select all
if aLine starts with "Common Name" then next repeat
    if aLine starts with "GENERAL INDICATIONS" then next repeat
    if aLine contains "______" then next repeat
    if aLine starts with "(" then next repeat

Can we add one more line that excludes lines starting with "Comment:" as I may add this in to some of the data?

That's all for now. Will continue testing.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby mudhen » Fri Oct 25, 2013 1:21 pm

I downloaded findTerms.sp45 12 and have done some searches using the generated data. All searches came up with no results (which it counted as one result) although I searched words that I could see in the text, excluding footnotes. Will the externals in this project work on a PowerPC Mac? I am running 10.4.11.
mudhen
 
Posts: 4
Joined: Thu Sep 26, 2013 5:29 pm

Re: ROT13

Postby codegreen » Sat Oct 26, 2013 6:13 am

I haven't actually tried this stuff on a PPC yet, but AFAIK it should work. Are you sure you aren't using terms that only occur in the portions of the text that aren't searched (e.g. the 'GENERAL INDICATIONS' section, or lines that begin with an open paren)? Words like faint and hungry should definitely return hits with the dummy data, and if they don't please let us know.

BTW that business about zero hits being counted as one is happening because of the 'no hits' message being considered a result (after I somewhat carelessly rearranged the timing code to include the formatting step).

Thanks,
-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby mudhen » Sat Oct 26, 2013 6:51 am

I tried "faint" meat, meat, burn, burning, stom, top, gnaw, ear, [F.], [Br.], and others; then hungry, all with the same result. Search time was in the range of roughly 450-1000 milliseconds. For what it is worth, the trials on #11 each found one, but only one, result for valid searches, that result apparently being the first hit.
mudhen
 
Posts: 4
Joined: Thu Sep 26, 2013 5:29 pm

Re: ROT13

Postby codegreen » Sat Nov 02, 2013 9:04 am

Sorry, I've been too busy to look at this for a few days.

Here's another update which should fix (at least most of) the formatting issues you identified. Haven't had time to investigate the PPC side yet...

Let me know if you find any more problems.

-Mark

findTerms.sp45 13.zip
(37.75 KiB) Downloaded 555 times
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby drpitcairn » Sat Nov 02, 2013 10:28 am

Mark,
Thanks for the update. So far working fine except for one thing with brackets. If I search for the author designation such as [G.] then it finds that just fine and colors it as expected. However, if I leave off the second bracket, so it is like this = [G. then I get an error message. I will attach a picture of what I get so you can see. BTW, searching for words in parentheses works fine, even if I leave off the second parenthesis.
bracket.gif
searching for [G.
bracket.gif (38.96 KiB) Viewed 19055 times
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby drpitcairn » Sat Nov 02, 2013 10:47 am

Found one more thing. If I search for "pit" finds and colors. Also "Pit" found and colored, case insensitive. However, if I put in "Pit." with a period, then finds the word all right but no color red.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby drpitcairn » Sat Nov 02, 2013 11:06 am

Confirmed. If I put a period after a word, it is found but not colored.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby codegreen » Sun Nov 03, 2013 4:14 am

Here's another one to play with...

findTerms.sp45 14.zip
(38.28 KiB) Downloaded 554 times
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby drpitcairn » Sun Nov 03, 2013 8:36 am

Been testing, seems to be working perfectly. Haven't found any errors and I tried.
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby drpitcairn » Thu Nov 14, 2013 1:03 pm

I am not sure what is the next step. The last app download seems to work fine. Is it possible I can use it (script? external?) in my project? It would certainly make things move much faster. What do I do next?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby drpitcairn » Fri Nov 15, 2013 3:53 pm

Mark,
I had time today to put the externals in, and change the script. I learned some things from the script as well, interesting. Works very fine so far, blazingly fast. However, my tester says does not run on her PowerPC running 10.4. Did not crash but does not find anything. Want her to report more details?
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby drpitcairn » Thu Nov 28, 2013 8:40 am

Just to add to my prior posts how much I appreciate the help you have given here. It has transformed my projects, made them much more useful and very impressive at the speed of response to inquiries. It was very kind of you.

— Richard
User avatar
drpitcairn
 
Posts: 1023
Joined: Thu Apr 02, 2009 9:39 am
Location: Sedona, Arizona

Re: ROT13

Postby mudhen » Thu Dec 05, 2013 8:27 am

Any hope of getting FindTerms to run on Tiger?
mudhen
 
Posts: 4
Joined: Thu Sep 26, 2013 5:29 pm

Re: ROT13

Postby codegreen » Sat Dec 07, 2013 2:02 pm

Sorry, I was temporarily 'unhorsed' by an injury and a disk crash...

The Tiger problem seems to be caused by a bug in the PPC version of the gcc compiler (sadly by no means the first I've stumbled upon). Here's one with a workaround for it...

findTerms.sp45.zip
(55.27 KiB) Downloaded 520 times

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: ROT13

Postby mudhen » Fri Dec 20, 2013 9:09 pm

Thank you, Mark. Goodness, I hope you have recovered from you injury.

The searches are fairly fast, and it didn't crash, so a huge improvement.

However, although the search works for meat, cravings, debility, pickle, etc., action, lie, charact, and faint; it does not work for liver, chilly, clammy, mucous, labor, women, mark, lung, small, right, gleet, are, hard, cold, memb, membranes, gastric, or hand.

I don't see a pattern in the order of the words searched, the placement in the paragraph, the number of letters in the search word, or the letters with which the words begin. I tried some of the words several times, always with the same results.
mudhen
 
Posts: 4
Joined: Thu Sep 26, 2013 5:29 pm

Previous

Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest

cron