Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

traing2p.h

Go to the documentation of this file.
00001 /* traing2p.h    $Revision: 1.3 $ $Date: 2005/12/10 20:33:54 $
00002    Copyright (C) 2002 University of Bonn.
00003    http://www.ikp.uni-bonn.de/boss
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA  02111-1307, USA.
00019 */
00020 
00025 #ifndef TRAING2P_H
00026 #define TRAING2P_H
00027 
00028 
00029 #include <iostream>
00030 #include <stdlib.h>
00031 #include <vector>
00032 #include <string>
00033 #include "boss_g2p/boss_g2p.h"
00034 #include "boss_g2pmatrix.h"
00035 #include "phimbl/phimbl.h"
00036 
00037 
00042 #define MAX_NUMBER_OF_ALIGNMENTS 1000
00043 
00044 struct t_MappingTableEntry {
00045   string key;
00046   string target;
00047 };
00048 
00049 inline istream & operator >> (istream &in, t_MappingTableEntry & mte)
00050 { return in >> mte.key >> mte.target; }
00051 
00052 typedef map< string, string > t_MappingTableMap;
00053 typedef enum {G2P, SYLL} TrainingType;
00054 
00055 struct t_Alignment {
00056   string word;
00057   BOSS::t_SVector graph;
00058   vector<BOSS::t_SVector> phon;
00059   BOSS::t_SVector best;
00060   bool accepted;
00061   void size() { cerr << graph.size() << " " << phon.size() << " " << best.size() << endl; }
00062 };
00063 //typedef vector<t_Alignment> t_AlVector;
00064 
00065 class Traing2p : public BOSS_g2p {
00066  public:
00067   Traing2p(BOSS::Config & config) : BOSS_g2p(config) {}
00068   Traing2p(const BOSS_g2p & c) : BOSS_g2p(c) {}
00069   Traing2p(BOSS::Config & config, const string & traintype, const bool & createflag, const string & phonfile, const string & treefile, const string & lexfile, const string & featurefile, const LabelFormat & F);
00070   
00071  protected:
00072   void trainphon(const string & lexfile, const string & treefile, const string & featurefile, const LabelFormat & F);
00073   void trainsyll(const string & lexfile, const string & treefile, const string & featurefile, const LabelFormat & F);
00074   void trainstress(const string & lexfile, const string & treefile, const string & featurefile, const LabelFormat & F);
00075   void create_tree(const string & featurefile, const string & treefile);
00076   string clean_blftrans(const string & s);
00077   string clean_blftrans(const string & s, bool syll_flag);
00078   string remove_quotes(const string & s);
00079   BOSS::t_SVector extract_graphemes(t_MappingTableMap & mt);
00080   t_Alignment align_pair(const string & graph, const string & phon, BOSS_g2pMatrix & gpm);
00081   void assign_scores(const t_Alignment & al, BOSS_g2pMatrix & gpm);
00082   t_Alignment find_bestAlignment(t_Alignment al, BOSS_g2pMatrix & gpm);
00083   BOSS::t_SVector generateSyllFeatures(const BOSS::t_SVector & t);
00084   BOSS::t_SVector generateStressFeatures(const BOSS::t_SVector & t);
00085   BOSS::t_SVector generate_trainset(BOSS_g2pMatrix & gpm);
00086   void print_matrix(BOSS_g2pMatrix & m);
00087   double binomial(const double & n, const double k);
00088   BOSS::Phimbl phimbl;
00089 };
00090 
00091 #endif
00092 

Generated on Tue Dec 20 23:14:38 2005 for BOSS by doxygen 1.3.6