00001 /* 00002 * Permutation.h 00003 * met - Minimum Error Training 00004 * 00005 * Created by Alexandra Birch 18 Nov 2009. 00006 * 00007 */ 00008 00009 #ifndef PERMUTATION_H 00010 #define PERMUTATION_H 00011 00012 00013 #include <limits> 00014 #include <vector> 00015 #include <iostream> 00016 #include <fstream> 00017 00018 #include "Util.h" 00019 00020 namespace MosesTuning 00021 { 00022 00023 00024 class Permutation 00025 { 00026 00027 public: 00028 //Can be HAMMING_DISTANCE or KENDALLS_DISTANCE 00029 Permutation(const std::string &alignment = std::string(), const int sourceLength = 0, const int targetLength = 0 ); 00030 00031 ~Permutation() {}; 00032 00033 inline void clear() { 00034 m_array.clear(); 00035 } 00036 inline size_t size() { 00037 return m_array.size(); 00038 } 00039 00040 00041 void set(const std::string &alignment,const int sourceLength); 00042 00043 float distance(const Permutation &permCompare, const distanceMetric_t &strategy = HAMMING_DISTANCE) const; 00044 00045 //Const 00046 void dump() const; 00047 size_t getLength() const; 00048 std::vector<int> getArray() const; 00049 int getTargetLength() const { 00050 return m_targetLength; 00051 } 00052 00053 00054 //Static 00055 static std::string convertMosesToStandard(std::string const & alignment); 00056 static std::vector<int> invert(std::vector<int> const & inVector); 00057 static bool checkValidPermutation(std::vector<int> const & inVector); 00058 00059 protected: 00060 std::vector<int> m_array; 00061 int m_targetLength; 00062 float calculateHamming(const Permutation & compare) const; 00063 float calculateKendall(const Permutation & compare) const; 00064 00065 private: 00066 }; 00067 00068 00069 } 00070 00071 #endif