packages feed

gf-3.3: doc/gf-shell-reference.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<LINK REL="stylesheet" TYPE="text/css" HREF="../css/style.css">
<TITLE>The GF Software System</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1><a href="../"><IMG src="../doc/Logos/gf0.png"></a>The GF Software System</H1>
<FONT SIZE="4">
</FONT></CENTER>

<P>
The GF software system implements the GF programming language. Its
components are
</P>
<UL>
<LI>the <I>compiler</I>, 
translating <CODE>.gf</CODE> source files to <CODE>.gfo</CODE> object files, to
<CODE>.pgf</CODE> run-time grammars, and to various other formats
<LI>the <I>run-time system</I>,
performing parsing, generation, translation and other functions with
<CODE>.pgf</CODE> grammars
<LI>the <I>command interpreter</I>, also known as the <I>GF shell</I>,
executing user commands by calling the compiler and the run-time system
</UL>

<P>
This page describes the commands of the GF shell,
as well as the use of the compiler in batch mode.
</P>
    <UL>
    <LI><A HREF="#toc1">The GF shell</A>
      <UL>
      <LI><A HREF="#toc2">GF shell commands</A>
        <UL>
        <LI><A HREF="#toc3">!</A>
        <LI><A HREF="#toc4">?</A>
        <LI><A HREF="#toc5">ai = abstract_info</A>
        <LI><A HREF="#toc6">aw = align_words</A>
        <LI><A HREF="#toc7">ca = clitic_analyse</A>
        <LI><A HREF="#toc8">cc = compute_concrete</A>
        <LI><A HREF="#toc9">dc = define_command</A>
        <LI><A HREF="#toc10">dg = dependency_graph</A>
        <LI><A HREF="#toc11">dt = define_tree</A>
        <LI><A HREF="#toc12">e = empty</A>
        <LI><A HREF="#toc13">eb = example_based</A>
        <LI><A HREF="#toc14">gr = generate_random</A>
        <LI><A HREF="#toc15">gt = generate_trees</A>
        <LI><A HREF="#toc16">h = help</A>
        <LI><A HREF="#toc17">i = import</A>
        <LI><A HREF="#toc18">l = linearize</A>
        <LI><A HREF="#toc19">ma = morpho_analyse</A>
        <LI><A HREF="#toc20">mq = morpho_quiz</A>
        <LI><A HREF="#toc21">p = parse</A>
        <LI><A HREF="#toc22">pg = print_grammar</A>
        <LI><A HREF="#toc23">ph = print_history</A>
        <LI><A HREF="#toc24">ps = put_string</A>
        <LI><A HREF="#toc25">pt = put_tree</A>
        <LI><A HREF="#toc26">q = quit</A>
        <LI><A HREF="#toc27">r = reload</A>
        <LI><A HREF="#toc28">rf = read_file</A>
        <LI><A HREF="#toc29">rt = rank_trees</A>
        <LI><A HREF="#toc30">sd = show_dependencies</A>
        <LI><A HREF="#toc31">se = set_encoding</A>
        <LI><A HREF="#toc32">so = show_operations</A>
        <LI><A HREF="#toc33">sp = system_pipe</A>
        <LI><A HREF="#toc34">ss = show_source</A>
        <LI><A HREF="#toc35">t = tokenize</A>
        <LI><A HREF="#toc36">tq = translation_quiz</A>
        <LI><A HREF="#toc37">ut = unicode_table</A>
        <LI><A HREF="#toc38">vd = visualize_dependency</A>
        <LI><A HREF="#toc39">vp = visualize_parse</A>
        <LI><A HREF="#toc40">vt = visualize_tree</A>
        <LI><A HREF="#toc41">wf = write_file</A>
        </UL>
      </UL>
    <LI><A HREF="#toc42">The GF batch compiler</A>
    </UL>

<P></P>
<A NAME="toc1"></A>
<H2>The GF shell</H2>
<P>
The GF shell is invoked by the command <CODE>gf</CODE>, which takes arguments and
options according to the following syntax:
</P>
<PRE>
    gf (OPTION | FLAG)* FILE*
</PRE>
<P>
The shell maintains a  <I>state</I>, to which belong
</P>
<UL>
<LI>a multilingual PGF grammar
<LI>optionally, a set of compiled GF modules (retaining <CODE>oper</CODE> definitions)
<LI>a history of previous commands
<LI>a set of string, tree, and command macros
</UL>

<P>
Unless file arguments are provided to the <CODE>gf</CODE> command, the shell starts in an
empty state, with no grammars and no history. 
</P>
<P>
In the shell, a set of commands
is available. Some of these commands may change the grammars in the state. The general
syntax of commands is given by the following BNF grammar:
</P>
<PRE>
    COMMAND_LINE ::= COMMAND_PIPE
    COMMAND_LINE ::= COMMAND_PIPE ";" COMMAND_LINE
    COMMAND_PIPE ::= COMMAND
    COMMAND_PIPE ::= COMMAND "|" COMMAND_PIPE
    COMMAND      ::= COMMAND_ID (OPTION | FLAG)* ARGUMENT?
    OPTION       ::= "-"OPTION_ID
    FLAG         ::= "-"OPTION_ID "=" VALUE
    ARGUMENT     ::= QUOTED_STRING | TREE
    VALUE        ::= IDENT | QUOTED_STRING
</PRE>
<P>
A command pipe is a sequence of commands interpreted in such a way 
that the output of each command
is send as input to the next. The option <CODE>-tr</CODE> causes GF to show a trace,
i.e. the intermediate result of the command to which it is attached.
</P>
<P>
A command line is a sequence of pipes separated by <CODE>;</CODE>. These pipes are
executed one by one, in the order of appearance.
</P>
<A NAME="toc2"></A>
<H3>GF shell commands</H3>
<P>
The full set of GF shell commands is listed below with explanations. 
This list can also be obtained in the GF shell by the command <CODE>help -full</CODE>.
</P>
<P>
<hr>
</P>
<A NAME="toc3"></A>
<H4>!</H4>
<P>

<CODE>!</CODE>: <I>system command: escape to system shell.</I>
</P>
<P>

</P>
<UL>
<LI>Syntax: <CODE>! SYSTEMCOMMAND</CODE>
<P></P>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>! ls *.gf</CODE></TD>
<TD>list all GF files in the working directory</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc4"></A>
<H4>?</H4>
<P>

<CODE>?</CODE>: <I>system pipe: send value from previous command to a system command.</I>
</P>
<P>

</P>
<UL>
<LI>Syntax: <CODE>? SYSTEMCOMMAND</CODE>
<P></P>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>gt | l | ? wc</CODE></TD>
<TD>generate, linearize, word-count</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc5"></A>
<H4>ai = abstract_info</H4>
<P>

<CODE>ai</CODE> = <CODE>abstract_info</CODE>: <I>Provides an information about a function, an expression or a category from the abstract syntax.</I>
</P>
<P>

</P>
<P>
The command has one argument which is either function, expression or
a category defined in the abstract syntax of the current grammar. 
If the argument is a function then ?its type is printed out.
If it is a category then the category definition is printed.
If a whole expression is given it prints the expression with refined
metavariables and the type of the expression.
</P>
<UL>
<LI>Syntax: <CODE>ai IDENTIFIER  or  ai EXPR</CODE>
<P></P>

</UL>

<P>
<hr>
</P>
<A NAME="toc6"></A>
<H4>aw = align_words</H4>
<P>

<CODE>aw</CODE> = <CODE>align_words</CODE>: <I>show word alignments between languages graphically.</I>
</P>
<P>

</P>
<P>
Prints a set of strings in the .dot format (the graphviz format).
The graph can be saved in a file by the wf command as usual.
If the -view flag is defined, the graph is saved in a temporary file
which is processed by graphviz and displayed by the program indicated
by the flag. The target format is postscript, unless overridden by the
flag -format.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-giza</CODE></TD>
<TD>show alignments in the Giza format; the first two languages</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-format</CODE></TD>
<TD>format of the visualization file (default "png")</TD>
</TR>
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>alignments for this list of languages (default: all)</TD>
</TR>
<TR>
<TD><CODE>-view</CODE></TD>
<TD>program to open the resulting file</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>gr | aw</CODE></TD>
<TD>generate a tree and show word alignment as graph script</TD>
</TR>
<TR>
<TD><CODE>gr | aw -view="open"</CODE></TD>
<TD>generate a tree and display alignment on Mac</TD>
</TR>
<TR>
<TD><CODE>gr | aw -view="eog"</CODE></TD>
<TD>generate a tree and display alignment on Ubuntu</TD>
</TR>
<TR>
<TD><CODE>gt | aw -giza | wf -file=aligns</CODE></TD>
<TD>generate trees, send giza alignments to file</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc7"></A>
<H4>ca = clitic_analyse</H4>
<P>

<CODE>ca</CODE> = <CODE>clitic_analyse</CODE>: <I>print the analyses of all words into stems and clitics.</I>
</P>
<P>

</P>
<P>
Analyses all words into all possible combinations of stem + clitics.
The analysis is returned in the format stem &amp;+ clitic1 &amp;+ clitic2 ...
which is hence the inverse of 'pt -bind'. The list of clitics is give
by the flag '-clitics'. The list of stems is given as the list of words
of the language given by the '-lang' flag.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-raw</CODE></TD>
<TD>analyse each word separately (not suitable input for parser)</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-clitics</CODE></TD>
<TD>the list of possible clitics (comma-separated, no spaces)</TD>
</TR>
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>the language of analysis</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>ca -lang=Fin -clitics=ko,ni "nukkuuko minun vaimoni" | p</CODE></TD>
<TD>to parse Finnish</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc8"></A>
<H4>cc = compute_concrete</H4>
<P>

<CODE>cc</CODE> = <CODE>compute_concrete</CODE>: <I>computes concrete syntax term using a source grammar.</I>
</P>
<P>

</P>
<P>
Compute TERM by concrete syntax definitions. Uses the topmost
module (the last one imported) to resolve constant names.
N.B.1 You need the flag -retain when importing the grammar, if you want
the definitions to be retained after compilation.
N.B.2 The resulting term is not a tree in the sense of abstract syntax
and hence not a valid input to a Tree-expecting command.
This command must be a line of its own, and thus cannot be a part
of a pipe.
</P>
<UL>
<LI>Syntax: <CODE>cc (-all | -table | -unqual)? TERM</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-all</CODE></TD>
<TD>pick all strings (forms and variants) from records and tables</TD>
</TR>
<TR>
<TD><CODE>-list</CODE></TD>
<TD>all strings, comma-separated on one line</TD>
</TR>
<TR>
<TD><CODE>-one</CODE></TD>
<TD>pick the first strings, if there is any, from records and tables</TD>
</TR>
<TR>
<TD><CODE>-table</CODE></TD>
<TD>show all strings labelled by parameters</TD>
</TR>
<TR>
<TD><CODE>-unqual</CODE></TD>
<TD>hide qualifying module names</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc9"></A>
<H4>dc = define_command</H4>
<P>

<CODE>dc</CODE> = <CODE>define_command</CODE>: <I>define a command macro.</I>
</P>
<P>

</P>
<P>
Defines IDENT as macro for COMMANDLINE, until IDENT gets redefined.
A call of the command has the form %IDENT. The command may take an
argument, which in COMMANDLINE is marked as ?0. Both strings and
trees can be arguments. Currently at most one argument is possible.
This command must be a line of its own, and thus cannot be a part
of a pipe.
</P>
<UL>
<LI>Syntax: <CODE>dc IDENT COMMANDLINE</CODE>
<P></P>

</UL>

<P>
<hr>
</P>
<A NAME="toc10"></A>
<H4>dg = dependency_graph</H4>
<P>

<CODE>dg</CODE> = <CODE>dependency_graph</CODE>: <I>print module dependency graph.</I>
</P>
<P>

</P>
<P>
Prints the dependency graph of source modules.
Requires that import has been done with the -retain flag.
The graph is written in the file _gfdepgraph.dot
which can be further processed by Graphviz (the system command 'dot').
By default, all modules are shown, but the -only flag restricts them
by a comma-separated list of patterns, where 'name*' matches modules
whose name has prefix 'name', and other patterns match modules with
exactly the same name. The graphical conventions are:
  solid box = abstract, solid ellipse = concrete, dashed ellipse = other
  solid arrow empty head = of, solid arrow = **, dashed arrow = open
  dotted arrow = other dependency
</P>
<UL>
<LI>Syntax: <CODE>dg (-only=MODULES)?</CODE>
<P></P>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-only</CODE></TD>
<TD>list of modules included (default: all), literally or by prefix*</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>dg -only=SyntaxEng,Food*</CODE></TD>
<TD>shows only SyntaxEng, and those with prefix Food</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc11"></A>
<H4>dt = define_tree</H4>
<P>

<CODE>dt</CODE> = <CODE>define_tree</CODE>: <I>define a tree or string macro.</I>
</P>
<P>

</P>
<P>
Defines IDENT as macro for TREE or STRING, until IDENT gets redefined.
The defining value can also come from a command, preceded by "&lt;".
If the command gives many values, the first one is selected.
A use of the macro has the form %IDENT. Currently this use cannot be
a subtree of another tree. This command must be a line of its own
and thus cannot be a part of a pipe.
</P>
<UL>
<LI>Syntax: <CODE>dt IDENT (TREE | STRING | "&lt;" COMMANDLINE)</CODE>
<P></P>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>dt ex "hello world"</CODE></TD>
<TD>define ex as string</TD>
</TR>
<TR>
<TD><CODE>dt ex UseN man_N</CODE></TD>
<TD>define ex as string</TD>
</TR>
<TR>
<TD><CODE>dt ex &lt; p -cat=NP "the man in the car"</CODE></TD>
<TD>define ex as parse result</TD>
</TR>
<TR>
<TD><CODE>l -lang=LangSwe %ex | ps -to_utf8</CODE></TD>
<TD>linearize the tree ex</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc12"></A>
<H4>e = empty</H4>
<P>

<CODE>e</CODE> = <CODE>empty</CODE>: <I>empty the environment.</I>
</P>
<P>

</P>
<P>

</P>
<P>
<hr>
</P>
<A NAME="toc13"></A>
<H4>eb = example_based</H4>
<P>

<CODE>eb</CODE> = <CODE>example_based</CODE>: <I>converts .gfe files to .gf files by parsing examples to trees.</I>
</P>
<P>

</P>
<P>
Reads FILE.gfe and writes FILE.gf. Each expression of form
'%ex CAT QUOTEDSTRING' in FILE.gfe is replaced by a syntax tree.
This tree is the first one returned by the parser; a biased ranking
can be used to regulate the order. If there are more than one parses
the rest are shown in comments, with probabilities if the order is biased.
The probabilities flag and configuration file is similar to the commands
gr and rt. Notice that the command doesn't change the environment,
but the resulting .gf file must be imported separately.
</P>
<UL>
<LI>Syntax: <CODE>eb (-probs=FILE | -lang=LANG)* -file=FILE.gfe</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-api</CODE></TD>
<TD>convert trees to overloaded API expressions (using Syntax not Lang)</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-file</CODE></TD>
<TD>the file to be converted (suffix .gfe must be given)</TD>
</TR>
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>the language in which to parse</TD>
</TR>
<TR>
<TD><CODE>-probs</CODE></TD>
<TD>file with probabilities to rank the parses</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc14"></A>
<H4>gr = generate_random</H4>
<P>

<CODE>gr</CODE> = <CODE>generate_random</CODE>: <I>generate random trees in the current abstract syntax.</I>
</P>
<P>

</P>
<P>
Generates a list of random trees, by default one tree.
If a tree argument is given, the command completes the Tree with values to
all metavariables in the tree. The generation can be biased by probabilities,
given in a file in the -probs flag.
</P>
<UL>
<LI>Syntax: <CODE>gr [-cat=CAT] [-number=INT]</CODE>
<P></P>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-cat</CODE></TD>
<TD>generation category</TD>
</TR>
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>uses only functions that have linearizations in all these languages</TD>
</TR>
<TR>
<TD><CODE>-number</CODE></TD>
<TD>number of trees generated</TD>
</TR>
<TR>
<TD><CODE>-depth</CODE></TD>
<TD>the maximum generation depth</TD>
</TR>
<TR>
<TD><CODE>-probs</CODE></TD>
<TD>file with biased probabilities (format 'f 0.4' one by line)</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>gr</CODE></TD>
<TD>one tree in the startcat of the current grammar</TD>
</TR>
<TR>
<TD><CODE>gr -cat=NP -number=16</CODE></TD>
<TD>16 trees in the category NP</TD>
</TR>
<TR>
<TD><CODE>gr -lang=LangHin,LangTha -cat=Cl</CODE></TD>
<TD>Cl, both in LangHin and LangTha</TD>
</TR>
<TR>
<TD><CODE>gr -probs=FILE</CODE></TD>
<TD>generate with bias</TD>
</TR>
<TR>
<TD><CODE>gr (AdjCN ? (UseN ?))</CODE></TD>
<TD>generate trees of form (AdjCN ? (UseN ?))</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc15"></A>
<H4>gt = generate_trees</H4>
<P>

<CODE>gt</CODE> = <CODE>generate_trees</CODE>: <I>generates a list of trees, by default exhaustive.</I>
</P>
<P>

</P>
<P>
Generates all trees of a given category, with increasing depth.
By default, the depth is 4, but this can be changed by a flag.
If a Tree argument is given, the command completes the Tree with values
to all metavariables in the tree.
</P>
<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-cat</CODE></TD>
<TD>the generation category</TD>
</TR>
<TR>
<TD><CODE>-depth</CODE></TD>
<TD>the maximum generation depth</TD>
</TR>
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>excludes functions that have no linearization in this language</TD>
</TR>
<TR>
<TD><CODE>-number</CODE></TD>
<TD>the number of trees generated</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>gt</CODE></TD>
<TD>all trees in the startcat, to depth 4</TD>
</TR>
<TR>
<TD><CODE>gt -cat=NP -number=16</CODE></TD>
<TD>16 trees in the category NP</TD>
</TR>
<TR>
<TD><CODE>gt -cat=NP -depth=2</CODE></TD>
<TD>trees in the category NP to depth 2</TD>
</TR>
<TR>
<TD><CODE>gt (AdjCN ? (UseN ?))</CODE></TD>
<TD>trees of form (AdjCN ? (UseN ?))</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc16"></A>
<H4>h = help</H4>
<P>

<CODE>h</CODE> = <CODE>help</CODE>: <I>get description of a command, or a the full list of commands.</I>
</P>
<P>

</P>
<P>
Displays information concerning the COMMAND.
Without argument, shows the synopsis of all commands.
</P>
<UL>
<LI>Syntax: <CODE>h (-full)? COMMAND?</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-changes</CODE></TD>
<TD>give a summary of changes from GF 2.9</TD>
</TR>
<TR>
<TD><CODE>-coding</CODE></TD>
<TD>give advice on character encoding</TD>
</TR>
<TR>
<TD><CODE>-full</CODE></TD>
<TD>give full information of the commands</TD>
</TR>
<TR>
<TD><CODE>-license</CODE></TD>
<TD>show copyright and license information</TD>
</TR>
<TR>
<TD><CODE>-t2t</CODE></TD>
<TD>output help in txt2tags format</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc17"></A>
<H4>i = import</H4>
<P>

<CODE>i</CODE> = <CODE>import</CODE>: <I>import a grammar from source code or compiled .pgf file.</I>
</P>
<P>

</P>
<P>
Reads a grammar from File and compiles it into a GF runtime grammar.
If its abstract is different from current state, old modules are discarded.
If its abstract is the same and a concrete with the same name is already in the state
it is overwritten - but only if compilation succeeds.
The grammar parser depends on the file name suffix:
  .cf    context-free (labelled BNF) source
  .ebnf  extended BNF source
  .gfm   multi-module GF source
  .gf    normal GF source
  .gfo   compiled GF source
  .pgf   precompiled grammar in Portable Grammar Format
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-retain</CODE></TD>
<TD>retain operations (used for cc command)</TD>
</TR>
<TR>
<TD><CODE>-src</CODE></TD>
<TD>force compilation from source</TD>
</TR>
<TR>
<TD><CODE>-v</CODE></TD>
<TD>be verbose - show intermediate status information</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-probs</CODE></TD>
<TD>file with biased probabilities for generation</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc18"></A>
<H4>l = linearize</H4>
<P>

<CODE>l</CODE> = <CODE>linearize</CODE>: <I>convert an abstract syntax expression to string.</I>
</P>
<P>

</P>
<P>
Shows the linearization of a Tree by the grammars in scope.
The -lang flag can be used to restrict this to fewer languages.
A sequence of string operations (see command ps) can be given
as options, and works then like a pipe to the ps command, except
that it only affect the strings, not e.g. the table labels.
These can be given separately to each language with the unlexer flag
whose results are prepended to the other lexer flags. The value of the
unlexer flag is a space-separated list of comma-separated string operation
sequences; see example.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-all</CODE></TD>
<TD>show all forms and variants, one by line (cf. l -list)</TD>
</TR>
<TR>
<TD><CODE>-bracket</CODE></TD>
<TD>show tree structure with brackets and paths to nodes</TD>
</TR>
<TR>
<TD><CODE>-groups</CODE></TD>
<TD>all languages, grouped by lang, remove duplicate strings</TD>
</TR>
<TR>
<TD><CODE>-list</CODE></TD>
<TD>show all forms and variants, comma-separated on one line (cf. l -all)</TD>
</TR>
<TR>
<TD><CODE>-multi</CODE></TD>
<TD>linearize to all languages (default)</TD>
</TR>
<TR>
<TD><CODE>-table</CODE></TD>
<TD>show all forms labelled by parameters</TD>
</TR>
<TR>
<TD><CODE>-treebank</CODE></TD>
<TD>show the tree and tag linearizations with language names</TD>
</TR>
<TR>
<TD><CODE>-bind</CODE></TD>
<TD>bind tokens separated by Prelude.BIND, i.e. &amp;+</TD>
</TR>
<TR>
<TD><CODE>-chars</CODE></TD>
<TD>lexer that makes every non-space character a token</TD>
</TR>
<TR>
<TD><CODE>-from_amharic</CODE></TD>
<TD>from unicode to GF Amharic transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_ancientgreek</CODE></TD>
<TD>from unicode to GF ancient Greek transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_arabic</CODE></TD>
<TD>from unicode to GF Arabic transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_cp1251</CODE></TD>
<TD>decode from cp1251 (Cyrillic used in Bulgarian resource)</TD>
</TR>
<TR>
<TD><CODE>-from_devanagari</CODE></TD>
<TD>from unicode to GF Devanagari transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_greek</CODE></TD>
<TD>from unicode to GF modern Greek transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_hebrew</CODE></TD>
<TD>from unicode to GF unvocalized Hebrew transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_nepali</CODE></TD>
<TD>from unicode to GF Nepali transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_persian</CODE></TD>
<TD>from unicode to GF Persian/Farsi transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_telugu</CODE></TD>
<TD>from unicode to GF Telugu transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_thai</CODE></TD>
<TD>from unicode to GF Thai transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_urdu</CODE></TD>
<TD>from unicode to GF Urdu transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_utf8</CODE></TD>
<TD>decode from utf8 (default)</TD>
</TR>
<TR>
<TD><CODE>-lexcode</CODE></TD>
<TD>code-like lexer</TD>
</TR>
<TR>
<TD><CODE>-lexmixed</CODE></TD>
<TD>mixture of text and code (code between $...$)</TD>
</TR>
<TR>
<TD><CODE>-lextext</CODE></TD>
<TD>text-like lexer</TD>
</TR>
<TR>
<TD><CODE>-to_amharic</CODE></TD>
<TD>from GF Amharic transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_ancientgreek</CODE></TD>
<TD>from GF ancient Greek transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_arabic</CODE></TD>
<TD>from GF Arabic transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_cp1251</CODE></TD>
<TD>encode to cp1251 (Cyrillic used in Bulgarian resource)</TD>
</TR>
<TR>
<TD><CODE>-to_devanagari</CODE></TD>
<TD>from GF Devanagari transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_greek</CODE></TD>
<TD>from GF modern Greek transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_hebrew</CODE></TD>
<TD>from GF unvocalized Hebrew transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_html</CODE></TD>
<TD>wrap in a html file with linebreaks</TD>
</TR>
<TR>
<TD><CODE>-to_nepali</CODE></TD>
<TD>from GF Nepali transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_persian</CODE></TD>
<TD>from GF Persian/Farsi transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_telugu</CODE></TD>
<TD>from GF Telugu transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_thai</CODE></TD>
<TD>from GF Thai transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_urdu</CODE></TD>
<TD>from GF Urdu transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_utf8</CODE></TD>
<TD>encode to utf8 (default)</TD>
</TR>
<TR>
<TD><CODE>-unchars</CODE></TD>
<TD>unlexer that puts no spaces between tokens</TD>
</TR>
<TR>
<TD><CODE>-unlexcode</CODE></TD>
<TD>code-like unlexer</TD>
</TR>
<TR>
<TD><CODE>-unlexmixed</CODE></TD>
<TD>mixture of text and code (code between $...$)</TD>
</TR>
<TR>
<TD><CODE>-unlextext</CODE></TD>
<TD>text-like unlexer</TD>
</TR>
<TR>
<TD><CODE>-unwords</CODE></TD>
<TD>unlexer that puts a single space between tokens (default)</TD>
</TR>
<TR>
<TD><CODE>-words</CODE></TD>
<TD>lexer that assumes tokens separated by spaces (default)</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>the languages of linearization (comma-separated, no spaces)</TD>
</TR>
<TR>
<TD><CODE>-unlexer</CODE></TD>
<TD>set unlexers separately to each language (space-separated)</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>l -lang=LangSwe,LangNor no_Utt</CODE></TD>
<TD>linearize tree to LangSwe and LangNor</TD>
</TR>
<TR>
<TD><CODE>gr -lang=LangHin -cat=Cl | l -table -to_devanagari</CODE></TD>
<TD>hindi table</TD>
</TR>
<TR>
<TD><CODE>l -unlexer="LangAra=to_arabic LangHin=to_devanagari"</CODE></TD>
<TD>different unlexers</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc19"></A>
<H4>ma = morpho_analyse</H4>
<P>

<CODE>ma</CODE> = <CODE>morpho_analyse</CODE>: <I>print the morphological analyses of all words in the string.</I>
</P>
<P>

</P>
<P>
Prints all the analyses of space-separated words in the input string,
using the morphological analyser of the actual grammar (see command pg)
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-missing</CODE></TD>
<TD>show the list of unknown words in the input</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>the languages of analysis (comma-separated, no spaces)</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc20"></A>
<H4>mq = morpho_quiz</H4>
<P>

<CODE>mq</CODE> = <CODE>morpho_quiz</CODE>: <I>start a morphology quiz.</I>
</P>
<P>

</P>
<UL>
<LI>Syntax: <CODE>mq (-cat=CAT)? (-probs=FILE)? TREE?</CODE>
<P></P>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>language of the quiz</TD>
</TR>
<TR>
<TD><CODE>-cat</CODE></TD>
<TD>category of the quiz</TD>
</TR>
<TR>
<TD><CODE>-number</CODE></TD>
<TD>maximum number of questions</TD>
</TR>
<TR>
<TD><CODE>-probs</CODE></TD>
<TD>file with biased probabilities for generation</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc21"></A>
<H4>p = parse</H4>
<P>

<CODE>p</CODE> = <CODE>parse</CODE>: <I>parse a string to abstract syntax expression.</I>
</P>
<P>

</P>
<P>
Shows all trees returned by parsing a string in the grammars in scope.
The -lang flag can be used to restrict this to fewer languages.
The default start category can be overridden by the -cat flag.
See also the ps command for lexing and character encoding.
</P>
<P>
The -openclass flag is experimental and allows some robustness in 
the parser. For example if -openclass="A,N,V" is given, the parser
will accept unknown adjectives, nouns and verbs with the resource grammar.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-bracket</CODE></TD>
<TD>prints the bracketed string from the parser</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-cat</CODE></TD>
<TD>target category of parsing</TD>
</TR>
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>the languages of parsing (comma-separated, no spaces)</TD>
</TR>
<TR>
<TD><CODE>-openclass</CODE></TD>
<TD>list of open-class categories for robust parsing</TD>
</TR>
<TR>
<TD><CODE>-depth</CODE></TD>
<TD>maximal depth for proof search if the abstract syntax tree has meta variables</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc22"></A>
<H4>pg = print_grammar</H4>
<P>

<CODE>pg</CODE> = <CODE>print_grammar</CODE>: <I>print the actual grammar with the given printer.</I>
</P>
<P>

</P>
<P>
Prints the actual grammar, with all involved languages.
In some printers, this can be restricted to a subset of languages
with the -lang=X,Y flag (comma-separated, no spaces).
The -printer=P flag sets the format in which the grammar is printed.
N.B.1 Since grammars are compiled when imported, this command
generally shows a grammar that looks rather different from the source.
N.B.2 Another way to produce different formats is to use 'gf -make',
the batch compiler. The following values are available both for
the batch compiler (flag -output-format) and the print_grammar
command (flag -printer):
</P>
<P>
 bnf		BNF (context-free grammar)
 ebnf		Extended BNF
 fa		finite automaton in graphviz format
 gsl		Nuance speech recognition format
 haskell		Haskell (abstract syntax)
 js		JavaScript (whole grammar)
 jsgf		JSGF speech recognition format
 lambda_prolog		LambdaProlog (abstract syntax)
 pgf_pretty		human-readable pgf
 prolog		Prolog (whole grammar)
 prolog_abs		Prolog (abstract syntax)
 regexp		regular expression
 slf		SLF speech recognition format
 srgs_abnf		SRGS speech recognition format in ABNF
 srgs_abnf_nonrec		SRGS ABNF, recursion eliminated
 srgs_xml		SRGS speech recognition format in XML
 srgs_xml_nonrec		SRGS XML, recursion eliminated
 vxml		Voice XML based on abstract syntax
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-cats</CODE></TD>
<TD>show just the names of abstract syntax categories</TD>
</TR>
<TR>
<TD><CODE>-fullform</CODE></TD>
<TD>print the fullform lexicon</TD>
</TR>
<TR>
<TD><CODE>-funs</CODE></TD>
<TD>show just the names and types of abstract syntax functions</TD>
</TR>
<TR>
<TD><CODE>-langs</CODE></TD>
<TD>show just the names of top concrete syntax modules</TD>
</TR>
<TR>
<TD><CODE>-lexc</CODE></TD>
<TD>print the lexicon in Xerox LEXC format</TD>
</TR>
<TR>
<TD><CODE>-missing</CODE></TD>
<TD>show just the names of functions that have no linearization</TD>
</TR>
<TR>
<TD><CODE>-opt</CODE></TD>
<TD>optimize the generated pgf</TD>
</TR>
<TR>
<TD><CODE>-pgf</CODE></TD>
<TD>write current pgf image in file</TD>
</TR>
<TR>
<TD><CODE>-words</CODE></TD>
<TD>print the list of words</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-file</CODE></TD>
<TD>set the file name when printing with -pgf option</TD>
</TR>
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>select languages for the some options (default all languages)</TD>
</TR>
<TR>
<TD><CODE>-printer</CODE></TD>
<TD>select the printing format (see flag values above)</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>pg -funs | ? grep " S ;"</CODE></TD>
<TD>show functions with value cat S</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc23"></A>
<H4>ph = print_history</H4>
<P>

<CODE>ph</CODE> = <CODE>print_history</CODE>: <I>print command history.</I>
</P>
<P>

</P>
<P>
Prints the commands issued during the GF session.
The result is readable by the eh command.
The result can be used as a script when starting GF.
</P>
<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>ph | wf -file=foo.gfs</CODE></TD>
<TD>save the history into a file</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc24"></A>
<H4>ps = put_string</H4>
<P>

<CODE>ps</CODE> = <CODE>put_string</CODE>: <I>return a string, possibly processed with a function.</I>
</P>
<P>

</P>
<P>
Returns a string obtained from its argument string by applying
string processing functions in the order given in the command line
option list. Thus 'ps -f -g s' returns g (f s). Typical string processors
are lexers and unlexers, but also character encoding conversions are possible.
The unlexers preserve the division of their input to lines.
To see transliteration tables, use command ut.
</P>
<UL>
<LI>Syntax: <CODE>ps OPT? STRING</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-bind</CODE></TD>
<TD>bind tokens separated by Prelude.BIND, i.e. &amp;+</TD>
</TR>
<TR>
<TD><CODE>-chars</CODE></TD>
<TD>lexer that makes every non-space character a token</TD>
</TR>
<TR>
<TD><CODE>-from_amharic</CODE></TD>
<TD>from unicode to GF Amharic transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_ancientgreek</CODE></TD>
<TD>from unicode to GF ancient Greek transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_arabic</CODE></TD>
<TD>from unicode to GF Arabic transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_cp1251</CODE></TD>
<TD>decode from cp1251 (Cyrillic used in Bulgarian resource)</TD>
</TR>
<TR>
<TD><CODE>-from_devanagari</CODE></TD>
<TD>from unicode to GF Devanagari transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_greek</CODE></TD>
<TD>from unicode to GF modern Greek transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_hebrew</CODE></TD>
<TD>from unicode to GF unvocalized Hebrew transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_nepali</CODE></TD>
<TD>from unicode to GF Nepali transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_persian</CODE></TD>
<TD>from unicode to GF Persian/Farsi transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_telugu</CODE></TD>
<TD>from unicode to GF Telugu transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_thai</CODE></TD>
<TD>from unicode to GF Thai transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_urdu</CODE></TD>
<TD>from unicode to GF Urdu transliteration</TD>
</TR>
<TR>
<TD><CODE>-from_utf8</CODE></TD>
<TD>decode from utf8 (default)</TD>
</TR>
<TR>
<TD><CODE>-lexcode</CODE></TD>
<TD>code-like lexer</TD>
</TR>
<TR>
<TD><CODE>-lexmixed</CODE></TD>
<TD>mixture of text and code (code between $...$)</TD>
</TR>
<TR>
<TD><CODE>-lextext</CODE></TD>
<TD>text-like lexer</TD>
</TR>
<TR>
<TD><CODE>-to_amharic</CODE></TD>
<TD>from GF Amharic transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_ancientgreek</CODE></TD>
<TD>from GF ancient Greek transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_arabic</CODE></TD>
<TD>from GF Arabic transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_cp1251</CODE></TD>
<TD>encode to cp1251 (Cyrillic used in Bulgarian resource)</TD>
</TR>
<TR>
<TD><CODE>-to_devanagari</CODE></TD>
<TD>from GF Devanagari transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_greek</CODE></TD>
<TD>from GF modern Greek transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_hebrew</CODE></TD>
<TD>from GF unvocalized Hebrew transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_html</CODE></TD>
<TD>wrap in a html file with linebreaks</TD>
</TR>
<TR>
<TD><CODE>-to_nepali</CODE></TD>
<TD>from GF Nepali transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_persian</CODE></TD>
<TD>from GF Persian/Farsi transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_telugu</CODE></TD>
<TD>from GF Telugu transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_thai</CODE></TD>
<TD>from GF Thai transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_urdu</CODE></TD>
<TD>from GF Urdu transliteration to unicode</TD>
</TR>
<TR>
<TD><CODE>-to_utf8</CODE></TD>
<TD>encode to utf8 (default)</TD>
</TR>
<TR>
<TD><CODE>-unchars</CODE></TD>
<TD>unlexer that puts no spaces between tokens</TD>
</TR>
<TR>
<TD><CODE>-unlexcode</CODE></TD>
<TD>code-like unlexer</TD>
</TR>
<TR>
<TD><CODE>-unlexmixed</CODE></TD>
<TD>mixture of text and code (code between $...$)</TD>
</TR>
<TR>
<TD><CODE>-unlextext</CODE></TD>
<TD>text-like unlexer</TD>
</TR>
<TR>
<TD><CODE>-unwords</CODE></TD>
<TD>unlexer that puts a single space between tokens (default)</TD>
</TR>
<TR>
<TD><CODE>-words</CODE></TD>
<TD>lexer that assumes tokens separated by spaces (default)</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-env</CODE></TD>
<TD>apply in this environment only</TD>
</TR>
<TR>
<TD><CODE>-from</CODE></TD>
<TD>backward-apply transliteration defined in this file (format 'unicode translit' per line)</TD>
</TR>
<TR>
<TD><CODE>-to</CODE></TD>
<TD>forward-apply transliteration defined in this file</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>l (EAdd 3 4) | ps -code</CODE></TD>
<TD>linearize code-like output</TD>
</TR>
<TR>
<TD><CODE>ps -lexer=code | p -cat=Exp</CODE></TD>
<TD>parse code-like input</TD>
</TR>
<TR>
<TD><CODE>gr -cat=QCl | l | ps -bind</CODE></TD>
<TD>linearization output from LangFin</TD>
</TR>
<TR>
<TD><CODE>ps -to_devanagari "A-p"</CODE></TD>
<TD>show Devanagari in UTF8 terminal</TD>
</TR>
<TR>
<TD><CODE>rf -file=Hin.gf | ps -env=quotes -to_devanagari</CODE></TD>
<TD>convert translit to UTF8</TD>
</TR>
<TR>
<TD><CODE>rf -file=Ara.gf | ps -from_utf8 -env=quotes -from_arabic</CODE></TD>
<TD>convert UTF8 to transliteration</TD>
</TR>
<TR>
<TD><CODE>ps -to=chinese.trans "abc"</CODE></TD>
<TD>apply transliteration defined in file chinese.trans</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc25"></A>
<H4>pt = put_tree</H4>
<P>

<CODE>pt</CODE> = <CODE>put_tree</CODE>: <I>return a tree, possibly processed with a function.</I>
</P>
<P>

</P>
<P>
Returns a tree obtained from its argument tree by applying
tree processing functions in the order given in the command line
option list. Thus 'pt -f -g s' returns g (f s). Typical tree processors
are type checking and semantic computation.
</P>
<UL>
<LI>Syntax: <CODE>ps OPT? TREE</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-compute</CODE></TD>
<TD>compute by using semantic definitions (def)</TD>
</TR>
<TR>
<TD><CODE>-paraphrase</CODE></TD>
<TD>paraphrase by using semantic definitions (def)</TD>
</TR>
<TR>
<TD><CODE>-smallest</CODE></TD>
<TD>sort trees from smallest to largest, in number of nodes</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-number</CODE></TD>
<TD>take at most this many trees</TD>
</TR>
<TR>
<TD><CODE>-transfer</CODE></TD>
<TD>syntactic transfer by applying function, recursively in subtrees</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>pt -compute (plus one two)</CODE></TD>
<TD>compute value</TD>
</TR>
<TR>
<TD><CODE>p "4 dogs love 5 cats" | pt -transfer=digits2numeral | l</CODE></TD>
<TD>four...five...</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc26"></A>
<H4>q = quit</H4>
<P>

<CODE>q</CODE> = <CODE>quit</CODE>: <I>exit GF interpreter.</I>
</P>
<P>

</P>
<P>

</P>
<P>
<hr>
</P>
<A NAME="toc27"></A>
<H4>r = reload</H4>
<P>

<CODE>r</CODE> = <CODE>reload</CODE>: <I>repeat the latest import command.</I>
</P>
<P>

</P>
<P>

</P>
<P>
<hr>
</P>
<A NAME="toc28"></A>
<H4>rf = read_file</H4>
<P>

<CODE>rf</CODE> = <CODE>read_file</CODE>: <I>read string or tree input from a file.</I>
</P>
<P>

</P>
<P>
Reads input from file. The filename must be in double quotes.
The input is interpreted as a string by default, and can hence be
piped e.g. to the parse command. The option -tree interprets the
input as a tree, which can be given e.g. to the linearize command.
The option -lines will result in a list of strings or trees, one by line.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-lines</CODE></TD>
<TD>return the list of lines, instead of the singleton of all contents</TD>
</TR>
<TR>
<TD><CODE>-tree</CODE></TD>
<TD>convert strings into trees</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-file</CODE></TD>
<TD>the input file name</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc29"></A>
<H4>rt = rank_trees</H4>
<P>

<CODE>rt</CODE> = <CODE>rank_trees</CODE>: <I>show trees in an order of decreasing probability.</I>
</P>
<P>

</P>
<P>
Order trees from the most to the least probable, using either
even distribution in each category (default) or biased as specified
by the file given by flag -probs=FILE, where each line has the form
'function probability', e.g. 'youPol_Pron  0.01'.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-v</CODE></TD>
<TD>show all trees with their probability scores</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-probs</CODE></TD>
<TD>probabilities from this file (format 'f 0.6' per line)</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>p "you are here" | rt -probs=probs | pt -number=1</CODE></TD>
<TD>most probable result</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc30"></A>
<H4>sd = show_dependencies</H4>
<P>

<CODE>sd</CODE> = <CODE>show_dependencies</CODE>: <I>show all constants that the given constants depend on.</I>
</P>
<P>

</P>
<P>
Show recursively all qualified constant names, by tracing back the types and definitions
of each constant encountered, but just listing every name once.
This command requires a source grammar to be in scope, imported with 'import -retain'.
Notice that the accuracy is better if the modules are compiled with the flag -optimize=noexpand.
This command must be a line of its own, and thus cannot be a part of a pipe.
</P>
<UL>
<LI>Syntax: <CODE>sd QUALIFIED_CONSTANT+</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-size</CODE></TD>
<TD>show the size of the source code for each constants (number of constructors)</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>sd ParadigmsEng.mkV ParadigmsEng.mkN</CODE></TD>
<TD>show all constants on which mkV and mkN depend</TD>
</TR>
<TR>
<TD><CODE>sd -size ParadigmsEng.mkV</CODE></TD>
<TD>show all constants on which mkV depends, together with size</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc31"></A>
<H4>se = set_encoding</H4>
<P>

<CODE>se</CODE> = <CODE>set_encoding</CODE>: <I>set the encoding used in current terminal.</I>
</P>
<P>

</P>
<UL>
<LI>Syntax: <CODE>se ID</CODE>
<P></P>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>se cp1251</CODE></TD>
<TD>set encoding to cp1521</TD>
</TR>
<TR>
<TD><CODE>se utf8</CODE></TD>
<TD>set encoding to utf8 (default)</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc32"></A>
<H4>so = show_operations</H4>
<P>

<CODE>so</CODE> = <CODE>show_operations</CODE>: <I>show all operations in scope, possibly restricted to a value type.</I>
</P>
<P>

</P>
<P>
Show the names and type signatures of all operations available in the current resource.
This command requires a source grammar to be in scope, imported with 'import -retain'.
The operations include the parameter constructors that are in scope.
The optional TYPE filters according to the value type.
The grep STRINGs filter according to other substrings of the type signatures.
This command must be a line of its own, and thus cannot be a part
of a pipe.
</P>
<UL>
<LI>Syntax: <CODE>so (-grep=STRING)* TYPE?</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-raw</CODE></TD>
<TD>show the types in computed forms (instead of category names)</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-grep</CODE></TD>
<TD>substring used for filtering (the command can have many of these)</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc33"></A>
<H4>sp = system_pipe</H4>
<P>

<CODE>sp</CODE> = <CODE>system_pipe</CODE>: <I>send argument to a system command.</I>
</P>
<P>

</P>
<UL>
<LI>Syntax: <CODE>sp -command="SYSTEMCOMMAND", alt. ? SYSTEMCOMMAND</CODE>
<P></P>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-command</CODE></TD>
<TD>the system command applied to the argument</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>gt | l | ? wc</CODE></TD>
<TD>generate trees, linearize, and count words</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc34"></A>
<H4>ss = show_source</H4>
<P>

<CODE>ss</CODE> = <CODE>show_source</CODE>: <I>show the source code of modules in scope, possibly just headers.</I>
</P>
<P>

</P>
<P>
Show compiled source code, i.e. as it is included in GF object files.
This command requires a source grammar to be in scope, imported with 'import -retain'.
The optional MODULE arguments cause just these modules to be shown.
The -size and -detailedsize options show code size as the number of constructor nodes.
This command must be a line of its own, and thus cannot be a part of a pipe.
</P>
<UL>
<LI>Syntax: <CODE>ss (-strip)? (-save)? MODULE*</CODE>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-detailedsize</CODE></TD>
<TD>instead of code, show the sizes of all judgements and modules</TD>
</TR>
<TR>
<TD><CODE>-save</CODE></TD>
<TD>save each MODULE in file MODULE.gfh instead of printing it on terminal</TD>
</TR>
<TR>
<TD><CODE>-size</CODE></TD>
<TD>instead of code, show the sizes of all modules</TD>
</TR>
<TR>
<TD><CODE>-strip</CODE></TD>
<TD>show only type signatures of oper's and lin's, not their definitions</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>ss</CODE></TD>
<TD>print complete current source grammar on terminal</TD>
</TR>
<TR>
<TD><CODE>ss -strip -save MorphoFin</CODE></TD>
<TD>print the headers in file MorphoFin.gfh</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc35"></A>
<H4>t = tokenize</H4>
<P>

<CODE>t</CODE> = <CODE>tokenize</CODE>: <I>Tokenize string usng the vocabulary.</I>
</P>
<P>

</P>
<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-lang</CODE></TD>
<TD>The name of the concrete to use</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc36"></A>
<H4>tq = translation_quiz</H4>
<P>

<CODE>tq</CODE> = <CODE>translation_quiz</CODE>: <I>start a translation quiz.</I>
</P>
<P>

</P>
<UL>
<LI>Syntax: <CODE>tq -from=LANG -to=LANG (-cat=CAT)? (-probs=FILE)? TREE?</CODE>
<P></P>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-from</CODE></TD>
<TD>translate from this language</TD>
</TR>
<TR>
<TD><CODE>-to</CODE></TD>
<TD>translate to this language</TD>
</TR>
<TR>
<TD><CODE>-cat</CODE></TD>
<TD>translate in this category</TD>
</TR>
<TR>
<TD><CODE>-number</CODE></TD>
<TD>the maximum number of questions</TD>
</TR>
<TR>
<TD><CODE>-probs</CODE></TD>
<TD>file with biased probabilities for generation</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>tq -from=Eng -to=Swe</CODE></TD>
<TD>any trees in startcat</TD>
</TR>
<TR>
<TD><CODE>tq -from=Eng -to=Swe (AdjCN (PositA ?2) (UseN ?))</CODE></TD>
<TD>only trees of this form</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc37"></A>
<H4>ut = unicode_table</H4>
<P>

<CODE>ut</CODE> = <CODE>unicode_table</CODE>: <I>show a transliteration table for a unicode character set.</I>
</P>
<P>

</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-amharic</CODE></TD>
<TD>Amharic</TD>
</TR>
<TR>
<TD><CODE>-ancientgreek</CODE></TD>
<TD>ancient Greek</TD>
</TR>
<TR>
<TD><CODE>-arabic</CODE></TD>
<TD>Arabic</TD>
</TR>
<TR>
<TD><CODE>-devanagari</CODE></TD>
<TD>Devanagari</TD>
</TR>
<TR>
<TD><CODE>-greek</CODE></TD>
<TD>modern Greek</TD>
</TR>
<TR>
<TD><CODE>-hebrew</CODE></TD>
<TD>unvocalized Hebrew</TD>
</TR>
<TR>
<TD><CODE>-persian</CODE></TD>
<TD>Persian/Farsi</TD>
</TR>
<TR>
<TD><CODE>-nepali</CODE></TD>
<TD>Nepali</TD>
</TR>
<TR>
<TD><CODE>-telugu</CODE></TD>
<TD>Telugu</TD>
</TR>
<TR>
<TD><CODE>-thai</CODE></TD>
<TD>Thai</TD>
</TR>
<TR>
<TD><CODE>-urdu</CODE></TD>
<TD>Urdu</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc38"></A>
<H4>vd = visualize_dependency</H4>
<P>

<CODE>vd</CODE> = <CODE>visualize_dependency</CODE>: <I>show word dependency tree graphically.</I>
</P>
<P>

</P>
<P>
Prints a dependency tree in the .dot format (the graphviz format, default)
or the MaltParser/CoNLL format (flag -output=malt for training, malt_input)
for unanalysed input.
By default, the last argument is the head of every abstract syntax
function; moreover, the head depends on the head of the function above.
The graph can be saved in a file by the wf command as usual.
If the -view flag is defined, the graph is saved in a temporary file
which is processed by graphviz and displayed by the program indicated
by the flag. The target format is png, unless overridden by the
flag -format.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-v</CODE></TD>
<TD>show extra information</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-file</CODE></TD>
<TD>configuration file for labels per fun, format 'fun l1 ... label ... l2'</TD>
</TR>
<TR>
<TD><CODE>-format</CODE></TD>
<TD>format of the visualization file (default "png")</TD>
</TR>
<TR>
<TD><CODE>-output</CODE></TD>
<TD>output format of graph source (default "dot")</TD>
</TR>
<TR>
<TD><CODE>-view</CODE></TD>
<TD>program to open the resulting file (default "open")</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>gr | vd</CODE></TD>
<TD>generate a tree and show dependency tree in .dot</TD>
</TR>
<TR>
<TD><CODE>gr | vd -view=open</CODE></TD>
<TD>generate a tree and display dependency tree on a Mac</TD>
</TR>
<TR>
<TD><CODE>gr -number=1000 | vd -file=dep.labels -output=malt</CODE></TD>
<TD>generate training treebank</TD>
</TR>
<TR>
<TD><CODE>gr -number=100 | vd -file=dep.labels -output=malt_input</CODE></TD>
<TD>generate test sentences</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc39"></A>
<H4>vp = visualize_parse</H4>
<P>

<CODE>vp</CODE> = <CODE>visualize_parse</CODE>: <I>show parse tree graphically.</I>
</P>
<P>

</P>
<P>
Prints a parse tree the .dot format (the graphviz format).
The graph can be saved in a file by the wf command as usual.
If the -view flag is defined, the graph is saved in a temporary file
which is processed by graphviz and displayed by the program indicated
by the flag. The target format is png, unless overridden by the
flag -format.
</P>
<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-format</CODE></TD>
<TD>format of the visualization file (default "png")</TD>
</TR>
<TR>
<TD><CODE>-view</CODE></TD>
<TD>program to open the resulting file (default "open")</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>p "John walks" | vp</CODE></TD>
<TD>generate a tree and show parse tree as .dot script</TD>
</TR>
<TR>
<TD><CODE>gr | vp -view="open"</CODE></TD>
<TD>generate a tree and display parse tree on a Mac</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc40"></A>
<H4>vt = visualize_tree</H4>
<P>

<CODE>vt</CODE> = <CODE>visualize_tree</CODE>: <I>show a set of trees graphically.</I>
</P>
<P>

</P>
<P>
Prints a set of trees in the .dot format (the graphviz format).
The graph can be saved in a file by the wf command as usual.
If the -view flag is defined, the graph is saved in a temporary file
which is processed by graphviz and displayed by the program indicated
by the flag. The target format is postscript, unless overridden by the
flag -format.
With option -mk, use for showing library style function names of form 'mkC'.
</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-api</CODE></TD>
<TD>show the tree with function names converted to 'mkC' with value cats C</TD>
</TR>
<TR>
<TD><CODE>-mk</CODE></TD>
<TD>similar to -api, deprecated</TD>
</TR>
<TR>
<TD><CODE>-nofun</CODE></TD>
<TD>don't show functions but only categories</TD>
</TR>
<TR>
<TD><CODE>-nocat</CODE></TD>
<TD>don't show categories but only functions</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-format</CODE></TD>
<TD>format of the visualization file (default "png")</TD>
</TR>
<TR>
<TD><CODE>-view</CODE></TD>
<TD>program to open the resulting file (default "open")</TD>
</TR>
</TABLE>

<UL>
<LI>Examples:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>p "hello" | vt</CODE></TD>
<TD>parse a string and show trees as graph script</TD>
</TR>
<TR>
<TD><CODE>p "hello" | vt -view="open"</CODE></TD>
<TD>parse a string and display trees on a Mac</TD>
</TR>
</TABLE>

<P>

</P>
<P>
<hr>
</P>
<A NAME="toc41"></A>
<H4>wf = write_file</H4>
<P>

<CODE>wf</CODE> = <CODE>write_file</CODE>: <I>send string or tree to a file.</I>
</P>
<P>

</P>
<UL>
<LI>Options:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-append</CODE></TD>
<TD>append to file, instead of overwriting it</TD>
</TR>
</TABLE>

<UL>
<LI>Flags:
<P></P>
</UL>

<TABLE ALIGN="center" CELLPADDING="4">
<TR>
<TD><CODE>-file</CODE></TD>
<TD>the output filename</TD>
</TR>
</TABLE>

<P>

</P>
<A NAME="toc42"></A>
<H2>The GF batch compiler</H2>
<P>
With the option <CODE>-batch</CODE>, GF can be invoked in batch mode, i.e.
without opening the shell, to compile files from <CODE>.gf</CODE> to <CODE>.gfo</CODE>. 
The <CODE>-s</CODE> option ("silent") eliminates all messages except errors. 
</P>
<PRE>
    $ gf -batch -s LangIta.gf
</PRE>
<P>
With the option <CODE>-make</CODE>, and as a set of
top-level grammar files (with the same abstract syntax) as arguments,
GF produces a <CODE>.pgf</CODE> file. The flag <CODE>-optimize-pgf</CODE> minimizes 
the size of the <CODE>.pgf</CODE> file, and is recommended for grammars to be shipped.
</P>
<PRE>
    $ gf -make -optimize-pgf LangIta.gf LangEng.gf LangGer.gf
</PRE>
<P>
The flag <CODE>-output-format</CODE> changes the output format from <CODE>.pgf</CODE> to
some other format. For instance
</P>
<PRE>
    $ gf -make -output-format=js LangEng.pgf LangGer.pgf
</PRE>
<P>
Notice that the arguments can be <CODE>.pgf</CODE> files, which in this case
are merged and written into a JavaScript grammar file.
</P>
<P>
More options and instructions are obtained with
</P>
<PRE>
    $ gf -help
</PRE>
<P>
To run GF from a <I>script</I>, redirection of standard input can be used:
</P>
<PRE>
    $ gf &lt;script.gfs
</PRE>
<P>
The file <CODE>script.gfs</CODE> should then contain a sequence of GF commands, one per line.
Unrecognized command lines are skipped without terminating GF.
</P>

<!-- html code generated by txt2tags 2.5 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags -thtml ./doc/gf-shell-reference.t2t -->
</BODY></HTML>