home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 93 / af093sub.adf / cookie.LZX / cookietool / cookietool.doc < prev    next >
Text File  |  1996-11-25  |  15KB  |  374 lines

  1.  
  2.  
  3.  
  4.                            CookieTool V2.1
  5.                            ===============
  6.  
  7.      A team of programs to help you maintain your cookie database:
  8.  
  9.           "CookieTool" itself eliminates duplicate entries,
  10.                   sorts alphabetically if you wish.
  11.             "CdbSplit" extracts parts to a seperate file,
  12.  by keyword, by size, as groups of 'similar' cookies, or a fixed number.
  13.  
  14.  
  15.  
  16. 0. Who needs it?
  17. ----------------
  18.  
  19. These tools are intended for users of "Cookie", "IntuiCookie" (both 
  20. available on Aminet, util/misc/), or generally for any plain text cookie 
  21. database with entries separated by "%%" lines.  They are nice for 
  22. crunching your cookie collection by a few KByte, but also for splitting
  23. it into seperate files of e.g. poems, quotations, anecdotes and miscel-
  24. laneous.
  25.  
  26. Note that "CookieTool" and "CdbSplit" know how to handle the database
  27. itself, but not the corresponding index file (also called 'hash file'). 
  28. That means you still need "cookhash" (which should be included with your
  29. cookie display program).
  30.  
  31.  
  32. 1. CookieTool command summary
  33. -----------------------------
  34.  
  35.     cookietool [options] <cookiefile> [logfile]
  36.  
  37. The crunched cookie database will be WRITTEN BACK to the input file (quite
  38. different from cookietool V1.x behaviour).  The deleted cookies will be 
  39. written to <logfile>, if one is specified.  (Thus one could restore the 
  40. original database by appending the logfile to the cookiefile again.)
  41.  
  42. options:      meaning:
  43.     -c        case-sensitive comparisons (for both deleting and sorting)
  44.     -d[0-3]   how fussy about word delimiters?
  45.               -d3: fussy, compare character by character
  46.               -d2: ignore number and kind of spaces between words (DEFAULT)
  47.               -d1: treat punctuation signs as spaces, too
  48.               -d0: completely ignore punctuation signs and spaces
  49.     -a        delete cookies that are "abbreviations" of another, too
  50.     -p        passive, don't delete anything
  51.     -s        sort output
  52.     -sl        " , looking at the last line only  \  intended to
  53.     -sw        " , looking at the last word only   }- sort quotations
  54.     -s<sep>    " , starting at the last occurence /  by source
  55.               of <sep>, e.g. '-s--' or '-s...'
  56.     -o        overwrite the input file directly (no tempfile), risky!
  57.               Use this *only* if your disk is so full that cookietool
  58.               couldn't create its tempfile.
  59.  
  60.  
  61. 2. CdbSplit command summary
  62. ---------------------------
  63.  
  64.     cdbsplit [options] <cookiefile> <hitfile>
  65.  
  66. The input file will always be OVERWRITTEN by a reduced version of the 
  67. database, so that cookies are moved (not copied) to the hit file.
  68. An existing hit file will never be overwritten, but may be appended to.
  69.  
  70. options:       meaning:
  71.     -c         case-sensitive comparisons (for both keywords and groups)
  72.     -d[0-3]    how fussy about word delimiters? (see above for details)
  73.     -f<n>      copy only the first <n> cookies
  74.     -F<n>      copy all but the first <n> cookies
  75.     -k<keywd>  search for a keyword
  76.     -K<keywd>  avoid a keyword
  77.     -l<l_min>  accept only cookies with <l_min> lines or more
  78.     -L<l_max>   "      "    "       "   <l_max> lines or less
  79.     -w<w_min>  accept only cookies <w_min> chars wide or more
  80.     -W<w_max>   "      "    "      <w_max> chars wide or less
  81.     -m<n>      find groups of cookies starting with <n> matching characters
  82.                (database must have been sorted!)
  83.     -a         append, if <hitfile> exists (instead of failing)
  84.  
  85.  
  86. 3. Examples
  87. -----------
  88.  
  89. These examples assume that your cookie database is in a single file
  90. called "cookies" (tacky name, hah :).  Oh, and I'd suggest that you make
  91. a backup of your cookies somewhere before trying "cookietool" on them.
  92.  
  93.  
  94. 3.1. Do what "onecookie" used to do
  95. -----------------------------------
  96.  
  97. The classic "onecookie" could only delete verbatim copies of a cookie,
  98. where even two spaces instead of one would make a difference.  CookieTool
  99. can be told to behave like this, too:
  100.  
  101.   cookietool cookies -c -d3
  102.  
  103. The default settings are a bit more generous:
  104.  
  105.   cookietool cookies
  106.  
  107. might delete a few cookies more.  Upper- and lowercase letters are now
  108. considered the same, and it doesn't matter if two words are seperated by 
  109. one or several spaces, by a tab sign, by a line break, etc.  So two 
  110. copies of the same text, but formatted in different ways, will still be
  111. recognized as identical.
  112.  
  113. The question is: do you really want such copies deleted automatically, or 
  114. would you rather decide yourself which one of such *almost* identical
  115. cookies should be deleted?  This question arises even more with the real
  116. liberal settings like
  117.  
  118.   cookietool cookies -d0
  119.  
  120. which for example recognizes "Kill ugly radio. -- Frank Zappa" and
  121. "Kill ugly radio... Frank Zappa" as identical.  (Both of these two styles 
  122. of supplying sources to quotations are frequently used.)  More on that
  123. question later.
  124.  
  125.  
  126. 3.2. Deleting abbreviations
  127. ---------------------------
  128.  
  129. It occurs rather frequently that one cookie seems to be an "abbreviation"
  130. of another.  Sayings may consist of more than one sentence, but the first
  131. sentence is sometimes quoted by itself.  And quotations are sometimes
  132. written down with, sometimes without their author.  In both cases the
  133. shorter cookie may be deleted, and cookietool can do that, too (-a).
  134.  
  135. However, one should not ignore puctuation signs with this option (don't
  136. use -d1 or -d0), because that would consider "A penny saved is a penny."
  137. as an abbreviation of "A penny saved is a penny earned.", which is not
  138. desireable.  It might be a good idea to create a log file of the deleted
  139. cookies and look at least at the shortest ones among them:
  140.  
  141.   cookietool cookies -a log
  142.   cdbsplit log log2 -L1 -W50      ; extract the shortest cookies
  143.   Ed log2      ; edit to leave only those cookies you want to put back
  144.   cdbsplit log2 cookies -a   ; put them back
  145.   Delete log log2
  146.  
  147. Using 'cdbsplit -a' without any search options is a nice way of moving
  148. cookies back into your main database.  Personally, I usually prefer
  149. "Type log2 >>cookies", "Delete log2" to do this, but note that this is
  150. risky:  If you accidentally type '>' instead of '>>', that would overwrite
  151. your main database instead of appending to it!  Such a thing can't happen 
  152. with cdbsplit.
  153.  
  154.  
  155. 3.3. Move cookies to and fro between files
  156. ------------------------------------------
  157.  
  158. Let's say you want to keep cookies which are quotations in a seperate
  159. file.  That's easy, they should be recognized by the "--" which precedes
  160. the source of the saying:
  161.  
  162.   cdbsplit cookies quotes -k--
  163.  
  164. However, sometimes "--" is used in the middle of sentences, too.  You 
  165. might want to edit these occurences to single "-"'s, so you can put those
  166. cookies back which aren't really quotations.  This is where the "avoid
  167. keyword" feature comes in handy.  And I'd suggest to sort the quotes file
  168. by source first, it usually becomes easier to read:
  169.  
  170.   cookietool quotes -sl       ; you might also try "-s--"
  171.   Ed quotes
  172.   cdbsplit quotes cookies -K-- -a
  173.  
  174. Or another example:  You're looking for a rather short keyword, that may
  175. appear as part of other words as well.  Let's say you want to move all
  176. Bart Simpson quotes to a separate "simpsons" file.  At first in a cautious
  177. way:
  178.  
  179.   cdbsplit cookies simpsons "-kBart " -d1 -c
  180.  
  181. Note how -d1 will make "Bart!" but not "Barton" be identified as "Bart ".
  182. But as this keyword fails if "Bart" appears at the very end of a cookie,
  183. you still have to collect the rest:
  184.  
  185.   cdbsplit cookies simpsons -kBart -a
  186.  
  187. Now look at the end of your "simpsons" file and check if anything went 
  188. wrong in this second pass.  In my case, I found a quotation by a guy named 
  189. "Barth".  Put it back:
  190.  
  191.   cdbsplit simpsons cookies -kBarth
  192.  
  193.  
  194. 3.4. Support for editing manually
  195. ---------------------------------
  196.  
  197. CdbSplit can help you collect all cookies that need reformatting (because
  198. they are too wide) in an extra file, and put them back later:
  199.  
  200.   cdbsplit -w76 cookies wide
  201.   Ed wide           ; add some line breaks
  202.   cdbsplit wide cookies
  203.  
  204. Now this was easy.  But cdbsplit can even help you to find groups of 
  205. "similar" cookies!  That's helpful to eliminate cookies that differ only
  206. by some typing error (e.g. 'seperate'/'separate'), something that 
  207. cookietool will *never* handle automatically.  To do this, you must sort 
  208. your database first, then tell cdbsplit how many agreeing characters make 
  209. "similar" cookies (I think 10 - 20 characters is usually a good choice):
  210.  
  211.   cookietool cookies -s -d0 -p
  212.   cdbsplit cookies temp -d0 -m20
  213.   Ed temp            ; delete some manually
  214.   cdbsplit temp cookies -a
  215.  
  216. When editing the "temp" file, you should find groups of two or more
  217. cookies with identical beginnings.  If you think they are really the same,
  218. you can delete all but one (!) of each group.  This is a tedious work,
  219. I know, but it's far easier than just sorting the database and looking
  220. for similar cookies with your eyes only. :)
  221.  
  222. Here's a more sophisticated procedure that will extract groups of cookies
  223. starting and ending with the same word (well, almost):
  224.  
  225.   cookietool cookies -s -d1 -p     ; regular sorting first
  226.   cookietool cookies -sw -d1 -p    ; *then* sort by last word
  227.   cdbsplit cookies temp -d1 -m3    ; yes, 3 matching characters will do!
  228.   Ed temp
  229.   cdbsplit temp cookies -a
  230.  
  231. Applying -s-- instead of -sw in the second pass could help you find 
  232. similar sayings that are attributed to the same person.
  233.  
  234.  
  235. 3.5. Joining "good" and "bad" cookie files
  236. ------------------------------------------
  237.  
  238. Suppose you have a well maintained cookie database, without double 
  239. entries, all the cookies are formatted the way you want them, and all the
  240. authors of quotations are written down in your preferred style.  Now you
  241. find an archive with new cookies somewhere and you want to add them to 
  242. your database, but you have reason to believe that this will introduce a 
  243. lot of double entries.  Here's how I would proceed.
  244.  
  245. In the following, assume that your good cookies are in a file called 
  246. "cookies", the new cookies are in a file called "visitors".
  247.  
  248. First make sure there are no double entries left in your main file, at 
  249. least none that cookietool can find:
  250.  
  251.   cookietool cookies -d0 log
  252.  
  253. And look at the number of cookies that cookietool reported, suppose it's
  254. 4711, you'll need it later.  B.t.w., normally this pass shouldn't delete
  255. anything, if your database is really in such good shape ;).  (Don't worry
  256. if it did, those cookies are in the "log" file now, but if you want to put
  257. them back, please do that only after this procedure is complete!)
  258.  
  259. Now append the "visitors" file, then delete all doubles from the new and
  260. larger "cookies" file:
  261.  
  262.   cdbsplit visitors cookies -a
  263.   cookietool cookies -d0
  264.  
  265. This will delete only new cookies (if any), because cookietool starts 
  266. deleting from the end of the file.  Of course, for this to work, it is
  267. essential that you assemble the files in this order (i.e. don't append
  268. "cookies" to "visitors")!  
  269.  
  270. Finally you might want to move the new cookies to their own file again.
  271. That's easy, tell cdbsplit to extract all but the 4711 first:
  272.  
  273.   cdbsplit cookies visitors -a -F4711
  274.  
  275. Now you can look at "visitors" to see what you've got, edit and reformat
  276. where needed, and then finally join the two databases for good.
  277.  
  278.  
  279. 3.6. Extract all poems :)
  280. -------------------------
  281.  
  282. You might do this by browsing through your database using a text editor 
  283. and marking all poems by an extra "#P" or some other unique piece of text.
  284. Extracting the poems is very straightforward then:
  285.  
  286.   cdbsplit -k#p cookies poems
  287.  
  288. Don't forget to edit "poems" once more to remove the "#P" marks, but this
  289. should be very easy using search/replace.
  290.  
  291. Of course, such a method is very versatile and powerful, but mainly 
  292. because it involves a lot of manpower :->.  Fortunately, there is another 
  293. solution for this problem:  Would you agree that a poem is something that 
  294. has at least four lines, but doesn't use the full line width?
  295. So let's try this:
  296.  
  297.   cdbsplit -l4 -W60 cookies poems
  298.  
  299. You should check the contents of "poems" manually now, and maybe you will 
  300. want to move some of the wider cookies back.  Not a problem:
  301.  
  302.   cdbsplit poems cookies -w51
  303.  
  304.  
  305. 4. Background information
  306. -------------------------
  307.  
  308. Just like "onecookie", "cookietool" has to load the complete database into
  309. memory first.  (Tough luck for those with a 1 Meg Amiga and a 1.2 MB
  310. database :-).  But unlike "onecookie" does, the cookies aren't compared 
  311. each against all others (O(n*n) operation) but sorted first and then 
  312. compared against their neighbours only (O(n*log n) operation).  For a
  313. database of 1000 cookies, that's about 100 times faster!
  314.  
  315. Overwriting input files is done by creating a tempfile and renaming it
  316. when all else is done.  So breaking (or crashing :) the programs won't 
  317. lead to data loss.  Unless, of course, you use cookietool with the '-o'
  318. option, but I already warned you about that!  (For those who absolutely 
  319. need to know:  Breaking cookietool while it is still reading data is 
  320. safe, even with -o, because the output file won't be opened until after 
  321. all deleting and sorting is done.  But please, kids, don't try this at
  322. home!  Or better still:  Don't use -o at all.)
  323.  
  324. Note that breaking "cdbsplit" while it is appending to another file is no 
  325. good idea.  All cookies that were already copied are then present in both
  326. files, and most likely the output file even ends with an incomplete 
  327. cookie!  The same can happen without your fault, if cdbsplit encounters a 
  328. "Disk Full" error.
  329. In both cases, don't append any further data to this output file, or the
  330. first of the new cookies will be merged with that incomplete cookie, due 
  331. to the missing %% separator!  You might run "cookietool" once on the 
  332. output file, that will ensure a valid file format again, and the 
  333. incomplete cookie will be removed.
  334.  
  335.  
  336. 5. History
  337. ----------
  338.  
  339. V1.0 - 
  340. V1.3  forget them, they were all crap, too hard to use
  341.  
  342. V2.0  no more reformatting of cookies, sorry for those who miss it :'(
  343.  
  344. V2.1  fixed a bug that would unnecessarily lose data after "Disk Full"
  345.     errors
  346.  
  347.  
  348. 6. The author
  349. -------------
  350.  
  351. Wilhelm Nöker  <wnoeker@t-online.de>
  352. Hertastr. 8, D-44388 Dortmund
  353.  
  354. Drop me an eMail,
  355.  
  356.  - if you like these programs,
  357.  - if you want to suggest some more features,
  358.  - or if you know a good source for cookies (perhaps other than Aminet).
  359.  
  360. But please *don't* mail me your cookies, at least unless I ask for it.
  361. I have to pay for my online time, and receiving a 2 Meg mail or such
  362. would really spoil my day. :-(
  363.  
  364.  
  365. 7. Credits
  366. ----------
  367.  
  368. CookieTool and CdbSplit were written using EdWord Pro 
  369. and the GNU C compiler (with libnix).
  370.  
  371. Thanks to Christian Kemp (author of IntuiCookie :) for reporting the Big
  372. Bug in V2.0.
  373.  
  374.