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

dates_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 Lesser 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 //    Lesser General Public License for more details.
00017 //
00018 //    You should have received a copy of the GNU Lesser 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 #ifndef _DATES_MOD
00030 #define _DATES_MOD
00031 
00032 #include <map>
00033 
00034 #include "language.h"
00035 #include "automat.h"
00036 #include "regexp.h"
00037 
00038 // Date/time regular expressions definitions
00039 
00040 #define RE_ROMAN "^([IVXLCDM]+)$"
00041 
00042 // Default:
00043 #define RE_DATE_DF "^(?:(?:((?:[0-3])?(?:\\d))/)(?:((?:(?:[0-1])?(?:\\d)))/)(\\d{1,4}))$"
00044 #define RE_TIME1_DF "^(?:((?:(?:[0-1])?(?:\\d))|(?:2(?:[01234])))(?:h)(((?:[0-5])?(?:\\d))(?:min|m)?)?)$"
00045 #define RE_TIME2_DF "^(?:((?:[0-5])?(?:\\d))(?:min\\.|min|m\\.|m))$"
00046 
00047 
00048 // Spanish:
00049 #define RE_DATE_ES "^(?:(?:((?:[0-3])?(?:\\d))/)(?:((?:(?:[0-1])?(?:\\d))|enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/)(\\d{1,4}))$"
00050 #define RE_TIME1_ES "^(?:((?:(?:[0-1])?(?:\\d))|(?:2(?:[01234])))(?:h)(((?:[0-5])?(?:\\d))(?:minutos|min|m)?)?)$"
00051 #define RE_TIME2_ES "^(?:((?:[0-5])?(?:\\d))(?:minutos|min\\.|min|m\\.|m))$"
00052 
00053 // Catalan:
00054 #define RE_DATE_CA "^(?:(?:((?:[0-3])?(?:\\d))/)(?:((?:(?:[0-1])?(?:\\d))|gener|febrer|març|abril|maig|juny|juliol|agost|setembre|octubre|novembre|desembre|gen|feb|mar|abr|mai|jun|jul|ago|set|oct|nov|des)/)(\\d{1,4}))$"
00055 #define RE_TIME1_CA "^(?:((?:(?:[0-1])?(?:\\d))|(?:2(?:[01234])))(?:h)(((?:[0-5])?(?:\\d))(?:minuts|min|m)?)?)$"
00056 #define RE_TIME2_CA "^(?:((?:[0-5])?(?:\\d))(?:minuts|min\\.|min|m\\.|m))$"
00057 
00058 // English:
00059 #define RE_DATE_EN "^(?:(?:((?:[0-3])?(?:\\d))/)(?:((?:(?:[0-1])?(?:\\d))|january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/)(\\d{1,4}))$"
00060 #define RE_TIME1_EN "^(?:((?:(?:[0-1])?(?:\\d))|(?:2(?:[01234])))(?:h)(((?:[0-5])?(?:\\d))(?:minutes|min|m)?)?)$"
00061 #define RE_TIME2_EN "^(?:((?:[0-5])?(?:\\d))(?:minutes|min\\.|min|m\\.|m))$"
00062 
00063 
00068 
00069 class dates_module: public automat {
00070 
00071    protected:
00073       map<string,int> nMes;
00075       map<string,string> nDia;
00077       string century,year,month,day,weekday,hour,minute,meridian;
00079       int temp;
00080       int sign;  // for the catalan "un quart menys(-1)/i(1) cinc de sis"
00082       map<string,int> tok;
00083 
00084       // required regular expressions objects
00085       RegEx RE_Date;
00086       RegEx RE_Time1;
00087       RegEx RE_Time2;
00088       RegEx RE_Roman;
00089 
00090    public:
00092       dates_module(const string &, const string &, const string &, const string &);
00093 };
00094 
00095 
00100 
00101 class dates_default : public dates_module {
00102 
00103    private:
00104       int ComputeToken(int, sentence::const_iterator, const sentence &);
00105       void ResetActions();
00106       void StateActions(int, int, int, sentence::const_iterator);
00107       void SetMultiwordAnalysis(sentence::iterator) const;
00108 
00109    public:
00111       dates_default();
00112 };
00113 
00118 
00119 class dates_es : public dates_module {
00120 
00121    private:
00122       int ComputeToken(int, sentence::const_iterator, const sentence &);
00123       void ResetActions();
00124       void StateActions(int, int, int, sentence::const_iterator);
00125       void SetMultiwordAnalysis(sentence::iterator) const;
00126 
00127    public:
00129       dates_es();
00130 };
00131 
00132 
00137 
00138 class dates_ca : public dates_module {
00139 
00140    private:
00141       int ComputeToken(int, sentence::const_iterator, const sentence &);
00142       void ResetActions();
00143       void StateActions(int, int, int, sentence::const_iterator);
00144       void SetMultiwordAnalysis(sentence::iterator) const;
00145 
00146    public:
00148       dates_ca();
00149 };
00150 
00151 
00152 
00153 #endif
00154 

Generated on Wed Apr 26 12:55:30 2006 for FreeLing by  doxygen 1.4.4