module Gram:Gram implements n-gram grammars.sig
..end
author: Jeff Heinz
last updated: June 2, 2007
This page explains how to use the gram
command line executable.
Gram implements n-gram grammars.
Like other OCaML executables, the program is run by typing ./gram
or
ocamlrun gram
at the command prompt. If you compiled using ocamlopt
then you can just type gram
. Generally it is invoked as follows.
gram subcommand
options
The output of the gram
command is always written to standard output.
Therefore it is possible to pipe it |
to other commands or direct it >
to a file.
By itself gram
will not do anything-- the argument subcommand
is mandatory.
The subcommand
arguments recognized by gram
are shown in the list below.
A brief description of each subcommand is given.
accepts
: gram accepts gramfile word
options returns true if the
n-gram grammar in gramfile
accepts word
. find
: gram find file
options prints to standard output the n-grams in
file. The option -c
provides counts of the n-grams. If
no input file is specified, gram
reads from standard input.2fsa
: gram 2fsa file
converts the n-gram grammar in file to a fsa
(readable with the fsa
command). If
no input file is specified, gram
reads from standard input.Following the first argument (the main command) you can optionally list as many of the following flags as you like (separated by spaces):
-n N
sets n
to N
. I.e. the grammar is a N
-gram grammar. The default value of N
is 2.-c
is used with the subcommand find
. Counts of the n-grams are printed with each n-gram.-d delim
specifies how segments are delimited in the string representation of a word (default ""
).-b B
specifies the word boundary symbol as B
.