                      LTCHUNK   V 3.0

================================================================
I. GENERAL DESCRIPTION
================================================================ 

LT_CHUNK is software for the disambiguation of words part-of-speech and
the identification of simple noun and verb groups in English texts.  It
can handle both plain ASCII and (n)SGML/XML marked-up files.  It
includes:
  ltchunk - text chunking program;
  lttok - English tokenizer buld on Finite State Automata
  ltpos - probabilistic part-of-speech tagger based on
          Hidden Markov Models plugged with Maximum Entropy 
          probability estimators;
  sgtransduce - a grammar interpreter which is supplemented with
         grammars to recognize verb and noun groups;
  and other supporting utilities; 
  
This distribution contains binary executable files (compiled under
SOLARIS/LINUX/WIN32) and resources which provide a model of General
English.  Tagger re-training utilities are not included in this release
but the tagger can be extended to cover new lexica (in Pro version
only). For more information on text chunking/tagging look at
    http://www.ltg.ed.ac.uk/~mikheev/tagger_demo.html

This version (3.0) differs from 2.X in using new algorithms for
sentence boundary disambiguation and  compiled resource files which
makes the initialization faster. 
 
 
(C) Andrei Mikheev 1996, 1997, 1998, 1999, 2000
(C) LTG, University of Edinburgh 1996, 1997, 1998, 1999, 2000


Particular attention is drawn to as follows:

  1. You cannot distribute copies of the Program without obtaining
     an agreement with the Language Technology Group of the University of
     Edinburgh.

 11. BECAUSE THE SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO
     WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
     LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
     HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
     WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
     NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
     FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
     QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
     PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
     SERVICING, REPAIR OR CORRECTION.




================================================================
II. INSTALLATION
================================================================

-----------------------------------------
A. UNPACKING
-----------------------------------------
Make a directory, for example, LTCHUNK connect to it and unpack the
distribution
   some_dir>> mkdir LT_CHUNK
   some_dir>> cd LT_CHUNK
   LT_CHUNK>> uncompress ../ltchunk_sol-30.tar.Z
   LT_CHUNK>> tar xvf ../ltchunk_sol-30.tar 


-----------------------------------------
B. DIRECTORY POINTERS CHANGE
-----------------------------------------

To install the LTG Chunker you should run

>>ltinstall

this will set internal directory pointers to your current directory

or

>>ltinstall "YOUR_DIR"

this will set internal directory pointers to YOUR_DIR directory


================================================================
III. RUNNING THE CHUNKER
================================================================
You can run the chunker to handle plain ASCII or (n)SGML/XML
marked-up texts. 

------------------------------------------
A. Running the chunker over ASCII texts
------------------------------------------
An example of chunking an ASCII text is

 >> cat EXAMPLES/text | bin/ltchunk

The output of the program will contain noun groups enclosed into [[ ]]
brackets and verb groups enclosed into (( )) brackets:

  [[ A Pentagon study  ]](( re-affirmed  ))[[ the conclusion  ]]of 
[[ previous government investigations  ]]that 
[[ both Rear Admiral Husband E. Kimmel ]]and [[ his Army counterpart ]], 
[[ Maj. Gen. Walter C. Short ]], ``(( committed ))[[ errors  ]]of [[ judgment  ]]''.  

You can also output part-of-speech information with every word using the flag -show_tags:
  >> cat EXAMPLES/text     | bin/ltchunk -show_tags

In this mode the chunker will output words as word_TAG structures:

  [[ A_DT Pentagon_NNP study_NN  ]](( re-affirmed_VBD  ))
[[ the_DT conclusion_NN  ]]of_IN [[ previous_JJ government_NN investigations_NNS  ]]
that_IN [[ both_DT Rear_NNP Admiral_NNP Husband_NNP E._NNP Kimmel_NNP ]]
and_CC [[ his_PRP$ Army_NNP counterpart_NN ]],_, [[ Maj._NNP Gen._NNP Walter_NNP C._NNP Short_NNP ]],_, 
``(( committed_VBD ))[[ errors_NNS  ]]of_IN [[ judgment_NN  ]]''._.

For the explanation of Penn Treebank  TAGS look at:
   http://www.ltg.ed.ac.uk/~mikheev/tagger_demo.html#PennTagset


-----------------------------------------
B. Running the chunker over XML texts
------------------------------------------
An example of chunking XML text is:

 >> cat /LTCHUNK/EXAMPLES/text.xml | /LTCHUNK/bin/ltchunk -q ".*/TEXT" -qs ".*/P" 
 >> cat /LTCHUNK/EXAMPLES/text.xml | /LTCHUNK/bin/ltchunk -q ".*/TEXT" -qs ".*/P" -show_tags

Here you specify a LT_NSL query (".*/P") which says that the content of  P
elements only should be chunked and all other fields should be left  without
modification. The XML format allows you to apply processing only to that
parts of your documents which are relevant e.g. P elements contain text but
SLUG elements of the file EXAMPLES/text.xml would require specialized
processing.  

In xml mode input file might have an appropriate Document Type Definition
(DTD).  If input file and its DTD are located in different directories
you can use -u option which sets the URL (absolute or relative) for the
DTD file. When input file and its DTD are located in the same directory
but you use input file as a stream i.e. you pipe it to the chunker you
should use -u option if your current directory is different from the
directory of the DTD file. Remember that the URL should always be ending
by "/". Example: -u /home/mikheev/LTCHUNK/EXAMPLE/ or -u EXAMPLE/


For more information on  the advantages of explicit SGML markup look at
  http://www.ltg.ed.ac.uk/~mikheev/papers.html#anlp-97

For extended specification of the LTNSL query language look at 
  http://www.ltg.ed.ac.uk/~mikheev/workbench.html#QUERY


-----------------------------------------------
C. Running the chunker in the client/server mode
------------------------------------------------
The chunker spends a considerable time on loading the necessary resources
on initialization. It is possible, however, to run it in the client/server
mode where some of the chunker's modules are pre-loaded and hence
do not require initialization every single time the chunker is called.
To load the server do:

  host>>/LTCHUNK/bin/ltpos     -server   #PORT_NUMBER  resource_file
for example
  galloway>>/LTCHUNK/bin/ltpos -server   4243   /LTCHUNK/data/resource.penn,xml

galloway is the name of your machine where  4243 port is to be
used as Internet socket.

Now, when you want to run the chunker you should provide it with the
information about the host and the port. For the examples above, this
will be:

 >> cat /LTCHUNK/EXAMPLES/text     | /LTCHUNK/bin/ltchunk -host galloway -port 4243                     
 >> cat /LTCHUNK/EXAMPLES/text     | /LTCHUNK/bin/ltchunk -host galloway -port 4243 -show_tags           
 >> cat /LTCHUNK/EXAMPLES/text.xml | /LTCHUNK/bin/ltchunk -host galloway -port 4243 -q ".*/TEXT" -qs ".*/P"            
 >> cat /LTCHUNK/EXAMPLES/text.xml | /LTCHUNK/bin/ltchunk -host galloway -port 4243 -q ".*/TEXT" -qs ".*/P" -show_tags 



================================================================
IV. EXTENDING  LEXICAL COVERAGE (PRO VERSION ONLY)
================================================================

Lexical coverage of the tagger is supported by the POS-TAG lexicon and
unknown-word guessing rules. All these are specified to the tagger in the
resource file (data/resource.penn,xml) in the LEXICON section under
"lexicon" field for the lexicon and "*-guess" fields for the guessing
rule files. This release does not include guessing rule training software
since the pre-trained rules proved to be domain-neutral to a large extent.
Thus the only resource you can modify is the lexicon itself.

The provided resource specification file data/resource.xml uses
data/penn_pos_tag.lex.map as the lexicon. This file has format:
  WORD CLASS_NUMBER
  book 155
  include 186
  the  34

CLASS_NUMBER is the number of the unique combination of POS-TAGS and it
is specified in data/RAW/penn.class file.

When you specify a new word you have to find a CLASS_NUMBER for it in the
class file (data/RAW/penn.class). You can do it by hand or use the
provided utilities
   bin/conv_lex.awk and bin/map_lex.awk  
(You should have "awk" installed on your computer).

bin/conv_lex.awk converts lexicon between multi-line and single line formats
  book NN
  book VB           <======>  book NN VB VBP
  book VBP

bin/conv_lex.awk 0    ====>  conversion
bin/conv_lex.awk 1   <====   conversion


bin/map_lex.awk  maps lexicon between TAG-SET and CLASS_NUMBER
  book NN VB VBP  <======>  book 155

bin/map_lex.awk class_file 0   ====>  mapping
bin/map_lex.awk class_file 1  <====   mapping

For example, data/RAW/penn_pos_tag.lex.map file was produced from
data/RAW/penn_pos_tag.lex as:

 >>cat data/RAW/penn_pos_tag.lex | sort -u | 
    bin/conv_lex.awk 0 |
         bin/map_lex.awk data/RAW/penn.class 0 > data/RAW/penn_pos_tag.lex.map

Watch out for words which failed to be mapped to any existing
class. Such words should be removed from the lexicon. For example:
 >> cat data/RAW/penn_pos_tag.lex.map | egrep ' [0-9]+$'  

Now you can compile the lexicon file for faster loading time

>>bin/dcmp penn_pos_tag.lex.map

this will produce file penn_pos_tag.lex.map.cmp which you should
specify in the LEXICON section of the resopurce file (e.g. 
resource.penn,xml) under "lexicon" field.


To produce the tag file from the mapped file do:

 >>cat data/RAW/penn_pos_tag.lex.map | 
     bin/map_lex.awk data/RAW/penn.class 1 |
         bin/conv_lex.awk 1 > data/RAW/penn_pos_tag.lex


================================================================
V. TAILORING THE LTCHUNK TOKENIZER (PRO VERSION ONLY)
================================================================

The tokenizer is responsible for segmenting the input text into words
and sentences. The rules for this are specified in the tokenizer resource file
  data/lttok_res.cmp. This file is compiled from a resource file 
  data/RAW/lttok_res.xml 

The FSA section specifies how to tokenize words. Every REX element
specifies a regular expression which should be matched to get a token
of a certain type. For example:
                    ----------------------  ^
  <REX name=ORD>[0-9]+[\-]*((th)|(rd))</REX>

applies the expression [0-9]+[ \-]*((th)|(rd)) and if it is satisfied
it assigns the tag ORD  to it.  The REX rules are applied in the very
order they are specified in the resource file and the longest matching rule
is selected. YOu can also specify a lookahead for a rule in the bo
attribute of the REX elemnt:

 <REX name=ORD bo=1>[0-9]+[ \-]*((th)|(rd))[, ]</REX>

here we allowed for a whitespace in between e.g. "5 th" bu to prevent
wrong tokenization "<ORD>5 th</ORD>ousand" we also specified that the
following symbol should be in "[, ]" and for not to include it into
the matched ordinal we specify backoff of 1 (i.e. bo=1).


                         APPENDIX


================================================================
I. RUNNING THE TAGGER ON ITS OWN
================================================================
  >>cat /LTCHUNK/EXAMPLES/text     | ltpos                           /LTCHUNK/data/resource.xml
  >>cat /LTCHUNK/EXAMPLES/text.xml | ltpos -q ".*/TEXT" -qs ".*/P"   /LTCHUNK/data/resource.xml

-q  ".*/TEXT" - specifies document level element
-qs ".*/P" - specifies LTNSL query "which fields of the text to process" within document;
/LTCHUNK/data/resource.xml - resource file


If your text is already tokenized in (n)SGML/XML format use
option -tok, -element_label and -pos_attr. For instance, if your text is
in the form:
   <S>
     <T>I</T> <T>go</T> <T>home</T><T>.</T>
   </S>

if you call:
 ltpos  -q ".*/S"  -qs "." -qw ".*/T"  -pos_attr "POS"  /LTCHUNK/data/resource.penn,xml

you will produce:
   <S>
     <T POS='PRP'>I</T> <T POS='VBP'>go</T> <T POS='RB'>home</T><T POS='.'>.</T>
   </S>

Indeed you can use -element_label and -pos_attr options without the -tok
option to redefine standard <W C=TAG> setting. Note that your DTD
should provide definitions for these new settings.


You can run the tagger in the client/server  mode similar as it
explained for the chunker.
Server installation:
  galloway>>ltpos -server  4243   /LTCHUNK/data/resource.penn,xml

Client call:

 >>tagger_clnt.per -host galloway  -port 4243  -q ".*/S" -qs "." (...other options...)


================================================================
II. RUNNING THE TOKENIZER ON ITS OWN
================================================================
 
The tokenizer works only with (n)SGML/XML files:

  >>cat EXAMPLES/text.xml | lttok -q ".*/P"  -mark W -attr C  /LTCHUNK/data/lttok_res.cmp

where   
 -q ".*/P" - specifies LTNSL query "which fields of the text to process";
 -mark W   - specifies what elements (W) the tokens will be packed to;
 -attr C   - specifies in what attribute of the tokens (W) their type will stored;
 /LTCHUNK/data/BROWN/lttok_res.xml - resource file 
          ( see section TAILORING LTCHUNK TOKENIZER in ../README file).


================================================================
III. GETTING RID FROM UNWANTED SGML MARKUP
================================================================

The chunker, tagger and the tokenizer are annotation tools and
they add their own SGML markup to (n)SGML/XML files. To convert
this markup to simple ascii strings you can use sgdelmarkup
utility (provided).

sgdelmarkup 
   -q LTNSL query  - from which elements to strip markup
   -u URL          - url for the DTD of the input stream;
   -p strip pattern - how to represent these elements
      pattern defined as a seqence of:
          str{element_attribute}str      where
            str -- a delimiter and can be an empty string
            element_attribute -- either name of an attribute,
                                 # - PCDATA or @ - element label;
  
 
example:
  >>sgdelmarkup -q ".*/W" -p "{#}_{C}"
<W C=NN>book</W>   ==>  book_NN

 >>sgdelmarkup -q ".*/W" -p "{@}:{#}_{C}"
<W C=NN>book</W>   ==>  W:book_NN


So after you apply an annotation tool you can strip markup:
 >>cat EXAMPLES/text.xml  
   | ltpos -q ".*/TEXT" -qs  ".*/P"  /LTCHUNK/data/resource.xml  ## produces : <W C=NN>book</W>
   | sgdelmarkup -q ".*/W" -p "{#}_{C}"                 ## produces : book_NN


 









