next up previous contents index
Next: table2sus Up: Conversion to sus Files Previous: Conversion to sus Files   Contents   Index

text2sus

text2sus is a very powerful filter. In general, the syntax is as follows:

text2sus [<options>] [<label>|<label>=<regexp>] ...


It scans an input file and extracts strings following specified keywords <label> or strings that match user-defined regular expressions <regexp>. Next, we will discuss some of the features provided by text2sus. For more detailed information please refer to the manual.

Subsequently, we consider an output file, say out.txt, produced by sort-demo (only the relevant part is shown):

out.txt [...]

STARTING experiment...
* [1] ascending ordered sequence <1,...,n>
  type = ascending
    T0 =     0.16
    T1 =     0.00
    T2 =     0.16
    T3 =     0.09
     r =        1
 
* [2] descending ordered sequence <n,...,1>
  type = descending
    T0 =     0.16
    T1 =     0.22
    T2 =     0.40
    T3 =     0.10
     r =        1
 
* [3] r sequences of n random numbers from [1,...,n]
  type = random
    T0 =     0.15
    T1 =     0.16
    T2 =     0.36
    T3 =     0.00
     r =       10
 
ready!


The simplest way of extracting certain keyword-value pairs from some text file is by specifying a keyword <label>. The first number or word after any occurrence of <label> will be interpreted as a value.

$\Rightarrow$ Tutorial 21:
Convert the output file out.txt into a sus file and try to extract the type data and the running times of the insertion sort algorithm (T1)

Solution:
text2sus type T1 < out.txt

$\Rightarrow$ Tutorial 22:
Write an option file text2sus.opt1 such that the following call


text2sus @ text2sus.opt1 < out.txt



produces a sus file that contains the running times of all four algorithms together with the type of the experiment and a short description of the experiment. Use the sus2text filter to verify your result, i.e.,


text2sus @ text2sus.opt1 < out.txt | sus2text



should produce something similar to this:

result

                                   description       type   T0   T1   T2   T3
 
          ascending ordered sequence <1,...,n>  ascending 0.16 0.00 0.16 0.09
         descending ordered sequence <n,...,1> descending 0.16 0.22 0.40 0.10
r sequences of n random numbers from [1,...,n]     random 0.15 0.16 0.36 0.00

Solution:

text2sus.opt1

description=\* \[[123]\] (.*)
type
T0
T1
T2
T3

Here, for the description, we need to define a regular expression: '\* \[[123]\] (.*)'. The '\* \[' matches the '* [' at the beginning of the lines we are interested in, '[123]' matches '1', '2' or '3', '\]' matches the ']', and finally, '(.*)' matches the rest of the line. As '(.*)' is the first group in the regular expression, the value of this match will be stored with label description.


next up previous contents index
Next: table2sus Up: Conversion to sus Files Previous: Conversion to sus Files   Contents   Index
Tobias Polzin 2002-11-18