duplicate-sort.rex

Pipelines v2.1

 

.....|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....10...

Home

     **** Top of file ****
   1
   2 /* The following pipeline reads the file: Winston.txt, splits each record at a word boundary,
   3    translates the records to lowercase, sorts the records to identify duplicates, arranges the
   4    resulting records in descending order of occurrence, and finally builds a four column
   5    aligned output matrix. */
   6
   7 Address Rxpipe
   8
   9 'pipe (endchar ?)',
  10      '< &installdrive:\&installpath\examples\input\winston.txt',
  11      '| take 10',                 /* Select the first 10 records */
  12      '| xlate x01-x2f x20',       /* Remove all but 0-9, a-z, A-Z and ''(quote) */
  13              'x3a-x40 x20',
  14              'x5b-x5f x20',
  15              'x7b-xff x20',
  16              '' '',
  17      '| split',                   /* Split record at word boundary. */
  18      '| strip',                   /* Strip whitespace. */
  19      '| a: locate',               /* Route away null records. */
  20      '| b: faninany',             /* Merge streams. */
  21      '| xlate lower',             /* Translate to lowercase. */
  22      '| sort count',              /* Sort with duplicate count. */
  23      '| sort 1-10 d',             /* Arrange in descending order of occurrence. */
  24      '| snake 4 align',           /* Build a 4 column aligned output matrix. */
  25      '| cons',                    /* Display on the console. */
  26      '?',
  27      'a:',
  28      '| specs /(blank line)/ 1',  /* Give a null record a description. */
  29      '| b:'
  30
  31 Say 'Hit Enter to close..'
  32 Parse Pull
  33
  34 Exit 0
     **** End of file ****
 

Console output

 
.....|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....10...
   1          7 the                  1 bright               1 hallway              1 simply
   2          6 a                    1 cabbage              1 handsome             1 slipped
   3          5 of                   1 chin                 1 has                  1 smelt
   4          4 (blank line)         1 clocks               1 heavy                1 smith
   5          3 and                  1 cold                 1 him                  1 stairs
   6          3 it                   1 coloured             1 indoor               1 striking
   7          3 to                   1 day                  1 into                 1 swirl
   8          2 an                   1 depicted             1 large                1 tacked
   9          2 face                 1 display              1 made                 1 than
  10          2 for                  1 doors                1 man                  1 thirteen
  11          2 his                  1 dust                 1 mansions             1 though
  12          2 in                   1 effort               1 mats                 1 through
  13          2 quickly              1 end                  1 metre                1 too
  14          2 winston              1 enormous             1 more                 1 victory
  15          2 with                 1 enough               1 moustache            1 vile
  16          1 about                1 entering             1 not                  1 wall
  17          1 along                1 escape               1 nuzzled              1 was
  18          1 april                1 features             1 old                  1 were
  19          1 at                   1 five                 1 one                  1 wide
  20          1 been                 1 forty                1 poster               1 wind
  21          1 black                1 from                 1 prevent
  22          1 boiled               1 glass                1 rag
  23          1 breast               1 gritty               1 ruggedly
  24 Hit Enter to close..