Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

mootMorph.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- */
00002 
00003 /*
00004    libmootm : moocow's morphology library
00005    Copyright (C) 2003-2005 by Bryan Jurish <moocow@ling.uni-potsdam.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011    
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016    
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with this library; if not, write to the Free Software
00019    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00020 */
00021 
00022 
00023 /*--------------------------------------------------------------------------
00024  * File: mootMorph.h
00025  * Author: Bryan Jurish <moocow@ling.uni-potsdam.de>
00026  * Description:
00027  *   + moocow's PoS tagger : morphology
00028  *--------------------------------------------------------------------------*/
00029 
00030 #ifndef _moot_MORPH_H_
00031 #define _moot_MORPH_H_
00032 
00036 #define moot_MORPH_DEBUG
00037 //#undef moot_MORPH_DEBUG
00038 
00041 #define MOOT_HAVE_HASH_STRING
00042 
00043 #include <stdio.h>
00044 
00045 #include <mootToken.h>
00046 #include <mootTokenIO.h>
00047 
00048 #include <mootFSMBase.h>
00049 #include <mootFSMPotsdam.h>
00050 #include <mootFSMgfsm.h>
00051 #include <mootFSMRWTH.h>
00052 
00053 namespace mootm {
00054   using namespace std;
00055   using namespace moot;
00056 
00057 /*--------------------------------------------------------------------------
00058  * mootMorph : morphological tagger class
00059  *--------------------------------------------------------------------------*/
00060 
00064 class mootMorph {
00065 public:
00066 
00068   typedef enum {
00069     vlSilent=0,       
00070     vlErrors=10,      
00071     vlWarnings=20,    
00072     vlEverything=127  
00073   } VerbosityLevel;
00074 
00075 public:
00076   /*------------------------------------------------------------
00077    * public data : guts
00078    */
00080 
00081 
00092   mootFSM mfsm;
00094 
00095 
00096   /*------------------------------------------------------------
00097    * public data : flags
00098    */
00099 
00103   bool want_avm;
00104 
00106   bool force_reanalysis;
00107 
00109   bool first_analysis_is_best;
00110 
00115   bool ignore_first_analysis;
00116   
00118   int verbose;
00120   
00121   /*------------------------------------------------------------
00122    * public data : statistics
00123    */
00124 
00128   unsigned int ntokens;
00129 
00131   unsigned int nanalyzed;
00132 
00134   unsigned int nunknown;
00135 
00140   unsigned int nprogress;
00142 
00143 
00144 public:
00145   /*------------------------------------------------------------
00146    * public methods: constructor / destructor
00147    */
00148 
00152   mootMorph(void) :
00153     want_avm(false),
00154     force_reanalysis(false),
00155     first_analysis_is_best(false),
00156     ignore_first_analysis(false),
00157     verbose(vlErrors),
00158     ntokens(0),
00159     nanalyzed(0),
00160     nunknown(0),
00161     nprogress(0)
00162   {};
00163 
00165   ~mootMorph() {};
00167 
00168   /*------------------------------------------------------------
00169    * public methods: initialization
00170    */
00171 
00174 
00176   bool load(const string &fst_filename, const string &syms_filename="")
00177   { return mfsm.load(fst_filename, syms_filename); };
00178 
00180   bool valid(void) const
00181   { return mfsm.valid(); };
00182 
00184 
00185   /*------------------------------------------------------------
00186    * public methods: top-level: analysis utilities
00187    */
00188 
00191 
00193   bool analyze_io(TokenReader *reader, TokenWriter *writer);
00194 
00196   bool analyze_stream(FILE *in=stdin, FILE *out=stdout, const char *srcname=NULL);
00197 
00199   bool analyze_strings(int argc, char **argv, FILE *out=stdout, const char *srcname=NULL);
00200 
00209   inline mootToken& analyze_token(mootToken &tok)
00210   {
00211     //-- analyze
00212     mfsm.analyze_token(tok, want_avm, (verbose >= vlWarnings));
00213 
00214     //-- track statistics
00215     nanalyzed++;
00216     if (tok.analyses().empty()) nunknown++;
00217 
00218     return tok;
00219   };
00220 
00222 
00223 
00224 
00225 
00226   /*------------------------------------------------------------
00227    * public methods: Miscellany
00228    */
00231 
00233   void carp(char *fmt, ...) const;
00234 
00236 };
00237 
00238 }; /* namespace mootm */
00239 
00240 #ifdef HAVE_CONFIG_H
00241 # include <mootmUnConfig.h>
00242 #endif
00243 
00244 #endif // _moot_MORPH_H_

Generated on Fri Dec 2 18:14:56 2005 for libmootm by  doxygen 1.4.3-20050530