- named query results can be stored on disk in the DataDirectory
> set DataDirectory ".";
> DICKENS;
NB: you need to re-activate your working corpus after setting the
DataDirctory option
- save named query to disk (in a platform-dependent uncompressed binary format)
> save Go;
- md* flags show whether a named query is loaded in memory
(m), saved on disk (d), or has been modified from the
version saved on disk (*)
> show named;
- discard a named query result to free memory
> discard Go;
- set DataDirectory to load previously-saved named queries from disk
(after discarding, or in a new CQP session)
> set DataDirectory ".";
> show named;
> cat Go;
note that the actual data is only read into memory when the query results are accessed
- write KWIC output to text file (use TAB key for filename completion)
> cat Go > "go.txt";
use set PrintOptions hdr;
to add header with information about the
corpus and the query (previous CQP versions did this automatically)
- if the filename ends in .gz or .bz2, the file will
automatically be compressed (this requires the respective command-line
utilities gzip and bzip2 to be available)4
- append to an existing file with
>>
; this also works for compressed files
> cat Go >> "go.txt";
- you can also write to a pipe5 (this example saves only matches that occur
in questions, i.e. sentences ending in ?)
> set Context 1 s;
> cat Go > "| grep '\?$' > go2.txt";
- set PrintMode and PrintOptions for HTML output
and other formats (still supported, but not recommended: see Section 2.4)
- frequency counts for matches can also be written to a text file
> count Go by lemma cut 5 > "go.cnt";
- new in CQP v3.4.14: cat can also be used to print an arbitrary
string or redirect it to a file; within an entered string, escape sequences
\t
(TAB), \r
(CR)
and \n
(LF) are interpreted, all other backslashes are passed through verbatim;
note that the string is not automatically terminated with a newline
> cat "Just another\n\tCQP hacker.\n";
- the new functionality can be combined with output redirection, which is
particularly convenient for adding header rows to tabular output files,
e.g.
> cat "f\tmatch [results]\n" > "go.cnt";
> count Go by lemma cut 5 >> "go.cnt";