numbers_modules.h

Go to the documentation of this file.
00001 
00002 //
00003 //    FreeLing - Open Source Language Analyzers
00004 //
00005 //    Copyright (C) 2004   TALP Research Center
00006 //                         Universitat Politecnica de Catalunya
00007 //
00008 //    This library is free software; you can redistribute it and/or
00009 //    modify it under the terms of the GNU General Public
00010 //    License as published by the Free Software Foundation; either
00011 //    version 2.1 of the License, or (at your option) any later version.
00012 //
00013 //    This library is distributed in the hope that it will be useful,
00014 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //    General Public License for more details.
00017 //
00018 //    You should have received a copy of the GNU General Public
00019 //    License along with this library; if not, write to the Free Software
00020 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021 //
00022 //    contact: Lluis Padro (padro@lsi.upc.es)
00023 //             TALP Research Center
00024 //             despatx C6.212 - Campus Nord UPC
00025 //             08034 Barcelona.  SPAIN
00026 //
00028 
00029 
00030 #ifndef _NUMBERS_MOD
00031 #define _NUMBERS_MOD
00032 
00033 #include <map>
00034 
00035 #include "fries/language.h"
00036 #include "freeling/automat.h"
00037 #include "regexp-pcre++.h"
00038 
00039 #define RE_NUM "^([0-9]+\\"+MACO_Thousand+")*[0-9]+(\\"+MACO_Decimal+")?[0-9]*$"
00040 #define RE_CODE "^.*[0-9].*$"
00041 
00042 // Auxiliary, kind of code
00043 #define CODE 1
00044 #define ORD 2
00045 
00046 
00051 
00052 class numbers_module : public automat {
00053 
00054    protected:
00055       // configuration options
00056       std::string MACO_Decimal, MACO_Thousand;
00057 
00059       std::map<std::string,float> value;
00061       std::map<std::string,int> tok;
00063       std::map<int,long double> power;
00064 
00066       long double bilion,milion,units;
00067       int block;
00068       int iscode;
00069       RegEx RE_number;
00070       RegEx RE_code;
00071  
00072    public:
00074       numbers_module(const std::string &, const std::string &);
00075 };
00076 
00081 
00082 class numbers_default : public numbers_module {
00083 
00084    private: 
00085       int ComputeToken(int,sentence::iterator&,sentence &);
00086       void ResetActions();
00087       void StateActions(int, int, int, sentence::const_iterator);
00088       void SetMultiwordAnalysis(sentence::iterator, int);
00089 
00090    public:
00092       numbers_default(const std::string &, const std::string &);
00093 };
00094 
00095 
00100 
00101 class numbers_es : public numbers_module {
00102 
00103    private:
00104       int ComputeToken(int,sentence::iterator&, sentence &);
00105       void ResetActions();
00106       void StateActions(int, int, int, sentence::const_iterator);
00107       void SetMultiwordAnalysis(sentence::iterator, int);
00108 
00109    public:
00111       numbers_es(const std::string &, const std::string &);
00112 };
00113 
00114 
00119 
00120 class numbers_ca : public numbers_module {
00121 
00122    private:
00123       int ComputeToken(int,sentence::iterator&,sentence &);
00124       void ResetActions();
00125       void StateActions(int, int, int, sentence::const_iterator);
00126       void SetMultiwordAnalysis(sentence::iterator, int);
00127 
00128    public:
00130       numbers_ca(const std::string &, const std::string &);
00131 };
00132 
00137 
00138 class numbers_gl : public numbers_module {
00139 
00140    private:
00141       int ComputeToken(int,sentence::iterator&,sentence &);
00142       void ResetActions();
00143       void StateActions(int, int, int, sentence::const_iterator);
00144       void SetMultiwordAnalysis(sentence::iterator, int);
00145 
00146    public:
00148       numbers_gl(const std::string &, const std::string &);
00149 };
00150 
00151 
00156 
00157 class numbers_it : public numbers_module {
00158 
00159    private:
00160       int  ComputeToken(int,sentence::iterator&, sentence &);
00161       void ResetActions();
00162       void StateActions(int, int, int, sentence::const_iterator);
00163       void SetMultiwordAnalysis(sentence::iterator, int);
00164 
00165       // !! unify process with other languages !! 
00166       long double hundreds;     //this is additional.
00167       long double thousands;    //this is additional.
00168       long double floatUnits;   // "e tre quarto". This variable will count how
00169                                 // many "halfs", "quartrs" we have
00170 
00171    public:
00173       numbers_it(const std::string &, const std::string &);
00174 };
00175 
00176 
00181 
00182 class numbers_en : public numbers_module {
00183 
00184    private: 
00185       int ComputeToken(int,sentence::iterator&, sentence &);
00186       void ResetActions();
00187       void StateActions(int, int, int, sentence::const_iterator);
00188       void SetMultiwordAnalysis(sentence::iterator, int);
00189 
00190    public:
00192       numbers_en(const std::string &, const std::string &);
00193 };
00194 
00195 
00196 #endif
00197 
Generated on Tue Jul 27 16:29:25 2010 for FreeLing by  doxygen 1.6.3