hmm_tagger.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 #ifndef _TAGGER
00030 #define _TAGGER
00031 
00032 #include <map>
00033 #include <list>
00034 #include <set>
00035 
00036 #include "fries/language.h"
00037 #include "freeling/tagger.h"
00038 
00049 
00050 class viterbi {  
00051   public:
00053     viterbi(int);
00055     ~viterbi();
00056   
00058     std::map <std::string, double> *delta_log;
00060     std::map <std::string, std::string> *phi;
00061 };
00062 
00063 
00071 
00072 class emission_states: public std::set<std::string> {};
00073 
00074 
00081 
00082 class hmm_tagger: public POS_tagger {
00083    private:
00084       // Configuration options
00085       std::string Language;
00086 
00088       std::map <std::string, double> PTag;
00089       std::map <std::string, double> PBg;
00090       std::map <std::string, double> PTrg;
00091       std::map <std::string, double> PInitial;
00092       std::map <std::string, double> PWord;
00093 
00095       std::multimap <std::string, std::string> Forbidden;
00097       float ZERO_logprob;
00098 
00100       double c[3];
00101 
00102       bool is_forbidden(const std::string &, sentence::const_iterator) const;
00103       double ProbA_log(const std::string &, const std::string &, sentence::const_iterator) const;
00104       double ProbB_log(const std::string &, const word &) const;
00105       double ProbPi_log(const std::string &) const;
00106 
00108       std::list<emission_states> FindStates(const sentence &) const;
00109 
00110    public:
00112        hmm_tagger(const std::string &, const std::string &, bool, unsigned int);
00113 
00115        void analyze(std::list<sentence> &);
00117        std::list<sentence> analyze(const std::list<sentence> &);
00118 };
00119 
00120 #endif
00121 
Generated on Tue Jul 27 16:29:25 2010 for FreeLing by  doxygen 1.6.3