00001 /********************************* 00002 tercpp: an open-source Translation Edit Rate (TER) scorer tool for Machine Translation. 00003 00004 Copyright 2010-2013, Christophe Servan, LIUM, University of Le Mans, France 00005 Contact: christophe.servan@lium.univ-lemans.fr 00006 00007 The tercpp tool and library are free software: you can redistribute it and/or modify it 00008 under the terms of the GNU Lesser General Public License as published by 00009 the Free Software Foundation, either version 2.1 of the licence, or 00010 (at your option) any later version. 00011 00012 This program and library are distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this library; if not, write to the Free Software Foundation, 00019 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 **********************************/ 00021 #ifndef __TERCPPTERALIGNMENT_H__ 00022 #define __TERCPPTERALIGNMENT_H__ 00023 00024 00025 #include <vector> 00026 #include <cstdio> 00027 #include <cstring> 00028 #include "tools.h" 00029 #include "terShift.h" 00030 00031 00032 using namespace std; 00033 // using namespace TERCPPNS_HashMapSpace; 00034 namespace TERCPPNS_TERCpp 00035 { 00036 00037 class terAlignment 00038 { 00039 private: 00040 public: 00041 00042 vector<string> ref; 00043 vector<string> hyp; 00044 vector<string> aftershift; 00045 vector<terShift> allshifts; 00046 vector<int> hyp_int; 00047 vector<int> aftershift_int; 00048 00049 double numEdits; 00050 double numWords; 00051 double averageWords; 00052 vector<char> alignment; 00053 string bestRef; 00054 00055 int numIns; 00056 int numDel; 00057 int numSub; 00058 int numSft; 00059 int numWsf; 00060 00061 00062 terAlignment(); 00063 string toString(); 00064 void scoreDetails(); 00065 00066 00067 string join ( string delim, vector<string> arr ); 00068 double score(); 00069 double scoreAv(); 00070 string printAlignments(); 00071 string printAllShifts(); 00072 void set(terAlignment& l_terAlignment); 00073 void set(terAlignment* l_terAlignment); 00074 }; 00075 00076 } 00077 #endif