FreeLing  3.0
accents_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 3 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 #ifndef _ACCENTS_MOD
00030 #define _ACCENTS_MOD
00031 
00032 #include <string>
00033 #include <set>
00034 #include <map>
00035 
00036 #include "freeling/morfo/sufrule.h"
00037 
00044 
00045 class accents_module {
00046 
00047  public:
00049   accents_module();
00051   virtual void fix_accentuation(std::set<std::wstring> &, const sufrule &) const =0;
00053   virtual ~accents_module() {};
00054 
00055 };
00056 
00057 
00063 
00064 class accents_default: public accents_module {
00065 
00066  public:
00068   accents_default();
00069 
00071   void fix_accentuation(std::set<std::wstring> &, const sufrule &) const;
00072 };
00073 
00074 
00080 
00081 class accents_es: public accents_module {
00082 
00083  private:
00085   static boost::u32regex llana_acc;
00086   static boost::u32regex aguda_mal;
00087   static boost::u32regex monosil;
00088   static boost::u32regex last_vowel_put_acc;
00089   static boost::u32regex last_vowel_not_acc;
00090   static boost::u32regex any_vowel_acc;
00092   static std::map<std::wstring,std::wstring> with_acc;
00093   static std::map<std::wstring,std::wstring> without_acc;
00095   static std::wstring remove_accent_esp(const std::wstring &);
00097   static std::wstring put_accent_esp(const std::wstring &);
00098 
00099  public:
00101   accents_es();
00102 
00104   void fix_accentuation(std::set<std::wstring> &, const sufrule &) const;
00105 };
00106 
00112 
00113 class accents_gl: public accents_module {
00114 
00115  private:
00117   static boost::u32regex last_vowel_put_acc;
00118   static boost::u32regex last_vowel_not_acc;
00119   static boost::u32regex any_vowel_acc;
00120   static boost::u32regex any_closed_vowel_acc;
00121   static boost::u32regex oxytone_without_acc;
00122   static boost::u32regex oxytone_with_acc;
00123   static boost::u32regex diacritic_acc;
00124   static boost::u32regex past_subj_with_acc;
00125   static boost::u32regex infinitive_r_accusative_allomorph;
00126   static boost::u32regex present_s_accusative_allomorph;
00127    
00129   static std::map<std::wstring,std::wstring> with_acc;
00130   static std::map<std::wstring,std::wstring> without_acc;
00132   static std::wstring remove_accent_gl(const std::wstring &);
00134   static std::wstring put_accent_gl(const std::wstring &);
00136   static void fix_accusative_allomorph_gl(std::set<std::wstring> &);
00137 
00138  public:
00140   accents_gl();
00141 
00143   void fix_accentuation(std::set<std::wstring> &, const sufrule &) const;
00144 };
00145 
00146 
00147 #endif