btred documentation

Table of contents


btred

ToC

btred - non-interactive scriptable version of the tree editor TrEd

SYNOPSIS

ToC

  btred [-c config-file]
        [-t context] [-m|-I macro-file] [-e code] [-i init-code]
        [-N|-H] [-T] [-S | --no-save] [--knit] [-P] [-F]
        [-s strip-sfx] [-a append-sfx] [-p strip-prefix] [-r add-prefix]
        [-f out-fmt] [-n file-encoding] [-d terminal-encoding]
        [-W] [-q|-Q] [-D] [-V] [-L port] [-b hub]
        [-x extra_attribs] [-X gov,ord?,hide?] [-R]
        [-o script options -- ] [-l file-list] files...
or
  btred -u          for usage
  btred -h          for help
  btred --man       for the manual page

DESCRIPTION

ToC

btred is an off-line TrEd macro processor which applies macros on given files

OPTIONS

ToC

Filename arguments

Each filename on the command-line or in a file list may be optionally followed by a suffix which identifies a node to be selected when the file is opened (this means that $this will point the the selected node and $root will point to the root of that tree). The suffix can be of one of the following following forms:

#ID where ID is an identifier of a node (for file formats that have identifiers, e.g. PML).

##N where N is a number. This selects the root of the N-th tree

##N.M where N and M are numbers. This selects the M-th node in the depth-first order in the N-th tree.

--macro-file|-m filename

File with macro definitions to load instead of the standard macro file (by default tred.mac).

WARNING: since extensions may require the standard macro file, using this option automatically disables all extensions. One may use --enable-extensions extension-list... to selectively enable required extensions.

--include-macro-file|-I filename

A file containing additional set of macros to load. This option is typically used instead of --macro-file to allow loading macros both from filename and the default macro set (tred.mac). --macro-file can still be used in combination with --include-macro-file to supply a replacement for tred.mac.

--execute|-e perl-code

Macro code to apply to given files. If no code is specified, btred expects a function called `autostart' to be defined in the used context and defaults to `autostart()' as the macro code.

The macro code may use all functions defined in a given macro file, the default macro file tred.def, plus all functions and methods from Treex::PML (see Treex::PML documentation).

Note, that a lot of information on the current node, file etc. can be obtained using some pre-defined macro from `tred.def'. The documentation for `tred.def' is a highly recommended reading for btred macro coder and macros defined there in should be prefered in all applicable situations.

As in TrEd, the following variables can be used in macros:

$this - the current node (the root of the first tree in a file at the beginning)

$root - the root node of the current tree

Among many other, the following functions are defined (see 'tred.def' for a full list):

CurrentFile() - current FSFile object (see section on FSFile in Treex::PML documentation)

CurrentTreeNumber() - current tree number

CurrentContext() - current macro context

ChangingFile() - - macro may call this function to indicate that the file should be saved at the end of the pocessing.

--initial-code|-i code

Code to be evaluated before any file is open.

--context|-t

Start in a given macro context (Perl package). The default context is `TredMacro'.

--preload-module|-M module-name

Preload a given Perl module at btred startup so as it is available to all macros (even if running in a safe compartment). This option may be specified more than once with different modules.

--filelist|-l file-list

Read a list of filenames to process from a given file (one filename per line). Files specified in a file-list are processed prior to files specified on the command-line. If file-list is a file with .fl extension, then the first line may contain a file-list name (as in TrEd). Moreover, unlike in other file-lists, filenames in .fl file-lists are asssumed to be relative to the file-list file location.

--glob|-g

Apply Perl glob function on the filename patterns given on the command-line. This expands possible wild-card patterns on each of the filename command-line argument as the standard Unix shell /bin/csh would do. This can not only help in a situation where the shell used does not support wildcard expansion, but can also be used to reduce the number of the command-line arguments passed to the process in cases where the argument list would after the shell-expansion exceed a system limit. By default, this flag is 'on' for the Windows platform and 'off' on all other systems.

--strip-prefix|-p regexp

Remove strings matching a given regexp from the beginning of filenames before saving.

--add-prefix|-r prefix

Prepend output filenames with a given prefix.

--strip-suffix|-s regexp

Strip strings matching a given regexp from the end of filenames.

--add-suffix|-a suffix

Append a given suffix to the filenames.

--output-format|-f [fs|csts|trxml|tei|storable]

Format to use for files being saved.

--config-file|-c filename

TrEd configuration file (overrides ~/.tredrc).

--option|-O name=value

Override configuration option from the config file with a given value. This flag can be used several times for different options.

Special syntax of the name part allows some modifications of existing option values for options that are delimited lists (this cannot be used to modify default or implicit values):

nameX=value

Treat the option as a list delimited by the delimiter X and prepend the value to the list.

nameX+=value

Treat the option as a list delimited by the delimiter X and append the value to the list.

nameX-=value

Treat the option as a list delimited by the delimiter X and remove the value from the list (if exists).

Only the following characters can be used as a delimiter:

      ; : , & | / + - \s \t SPACE

where SPACE is a space character, \s matches arbitrary white-space, and \t matches TAB character.

The options can be combined; for example

  -O "extensionRepos\\s"-=http://foo/bar -O "extensionRepos\\s"+=http://foo/bar

first removes any occurrence of the URL http://foo/bar from the white-space separated list of extensionRepos and then appends the URL to the end of the list.

--resource-dir|-Z dirname

Specifies resource path. This option can be repeated and overrides ResoucePath setting in the TrEd configuration file.

Individual paths can also be separated by colon (POSIX/Unix) or semi-colon (Windows) separator. If there is a lone leading or trailing separator, the default resource path is prepended or appended, respectively.

--all-trees|-T

Apply the macro code to all trees (wrapping the code into a if ($root) { do {{ CODE }} while TredMacro::NextTree() } loop).

--all-nodes|-N

Apply the macro code tn all nodes (you still must use --all-trees or -T to aplly to all trees in a file) (wrapping the code into a while ($this) { CODE ; $this=$this->following }; loop).

--all-nonhidden-nodes|-H

Apply the macro code to all nodes except the hidden ones (you still must use --all-trees or -T to process all trees in a file). This option wraps the code into a while ($this) { CODE ; $this=$this->following_visible(FS()) }; loop).

--file-encoding|-n encoding

Allows to specify character encoding of input files (does not apply to XML files).

--terminal-encoding|-d encoding

Automatically apllies a given character encoding to all stdout and stderr output operations. Works only with Perl >= 5.8.

--save|-S

Unconditionally save files after macro code was applied. By default, files are saved only if the $FileChanged variable has been set to 1 within the macro code.

--knit|-K ALL|NONE|name1,name2,...

If a file is saved, save/update also listed types of reffiles the file pulled data from. For the moment, this only makes sense with the PML backend which supports so called knitting, i.e. a method to pull certain data from external resources and push it back (with all changes) to the original position in the resource when saving the file. This option allows to list the types of resources (in PML the types are the reference names listed in the PML schema) which should be saved. Default is NONE. This type of resources does not include so called secondary files.

--no-save

Never ever save any files (this way you may protect your files from being saved even if applying a macro that modifies them and sets $TredMacro::FileChanged to 1).

--allow-no-trees|-0

Allow files with no trees (normaly such files are considered broken). Note: the short flag is -zero.

--allow-switch-context

By default, SwitchContext() macro in btred is a no-op.

If this flag is used, SwitchContext() operates as in TrEd, i.e. it changes the macro context and calls allow_switch_context_hook, pre_switch_context_hook, and switch_context_hook appropriately.

--safe-mode|-F

Run macro code in a safe compartment restricting some operations that could be used by a malicious code writer to explore and compromise the user's environment and potentially the entire system. Most notably, this blocks most IO operations. NO WARRANTY! If unsure, do not run the macro code at all.

--obey-locks

If used, btred will refuse to open or overwrite a file that is locked by TrEd.

--csts-tree-attributes|-X gov,ord?,hide?

CSTS format is "many in one"; there may be more tree structures in one file. This option can be used to specify which tree structure should be used. Provide a comma separated list consisting of names of node atributes corresponding to CSTS elements that contain the necessary information to build a tree out of a CSTS file. The first attribute should be an attribute containing the index of the governing node; the second one is optional and specifies the ordering attribute; the third one is also optional and if specified, it should be the attribute used to mark hidden nodes with the string 'hide'. If the third argument is specified as empty (i.e. there is a trailing comma), default to 'X_hide' with preset-value 'hide'.

Examples: -X govTR,dord - corresponds to elements <TRg> and <tfr> in CSTS

  -X govMD_c,ord,x_MD_c_hide
                 - corresponds to <MDg src="c">, <r>,
                   and <x name="MD_c_hide">).

--tectogrammatical-trees|-R

Build tectogrammatic trees from CSTS files.

--fs2csts-attributes|-x list

Comma separated list of FS attribute names that should be preserved as <x> elements when saving to CSTS.

--confing-file|-c filename

Use a given TrEd configuration file.

--preload-files|-P

Preload all given files into memory before applying the macros (DOES NOT WORK WITH RESTRICTED MODE).

--warn-only|-W

Do not stop (die) on errors, just warn.

--validate-fs|-V

Force Treex::PML to test validity of values assigned to @L (list) attributes in FS files.

--quiet|-q

Print only general processing information on stderr.

--very-quiet|-Q

Do not print anything to stderr at all (except for fatal errors).

--debugging|-D

Print a lot of debugging information on the stderr.

--carp

Replace 'die' with 'Carp::confess', so that a complete stack trace is printed upon error. Useful for debugging.

--dump-macros

Dump all macros currently being loaded to STDOUT and exit. Useful for debugging.

--server-port|-L port

Start btred server, listening on a given port; implies -P. Use a suitable client such as ntred to apply a macro code on the files possesed by the server.

--allow-host|-b hostname

Accept only connections from a given host when operating in the server-mode.

--extra-backends|-B backends

Comma separated list of user-defined IO-backend modules to load.

--define-symbol|-y symbol

Symbol name or a name=value pair to be used by macro-preprocessor (equivalent to a #define instruction at the beginning of the macro file). Multiple definitions symbols may be separated by a comma and the option may be repeated.

--no-secondary-files|-Y

Neither load or save "secondary" files. Normally, secondary files (if loaded) are saved along with their primary files (the exactly same file-name prefix/suffix processing and format apply to both the primary and secondary files). A secondary file is a file required by a (normal - primary) file to be loaded along with it; this is typical for files containing some form of a stand-off annotation where one tree is built upon another. Note however, that this does not include so called knitting - an operation where the stand-off annotation is handled by a IO backend and the resulting knitted file appears to btred as a single unit.

--enable-extensions|-j list

Give a comma-separated list of installed TrEd extension names to temporarily enable if disabled in the extension configuration. Use '*' to enable all currently enabled extensions.

--disable-extensions|-J list

Give a comma-separated list of installed TrEd extension names to temporarily disable if enabled in the extension configuration. Use '*' to disable all currently enabled extensions.

--list-extensions

Print out a list of available extensions and exit. Each extension name is given on a separate line and disabled extensions are preceded by '!'. This command takes into account options of --disable-extensions and --enable-extensions, so it can be used to test their interaction.

--lib

Prints path to module directory containing Treex::PML and other TrEd specific libraries and exit.

--usage|-u

Print a brief help message on usage and exits.

--help|-h

Prints the help page and exits.

--man

Displays the help as manual page.

LICENSE

ToC

This software is distributed under GPL - The General Public Licence. Full text of the GPL can be found in the LICENSE file distributed with this program and also on-line at http://www.gnu.org/copyleft/gpl.html.

AUTHOR

ToC

Petr Pajas <pajas@matfyz.cz>

Copyright 2000-2008 Petr Pajas, All rights reserved.