Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Permutation.h « mert - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b8be86a1b4013b2fc06541b494d48d22f8c1fc25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *  Permutation.h
 *  met - Minimum Error Training
 *
 *  Created by Alexandra Birch 18 Nov 2009.
 *
 */

#ifndef PERMUTATION_H
#define PERMUTATION_H


#include <limits>
#include <vector>
#include <iostream>
#include <fstream>

#include "Util.h"

namespace MosesTuning
{


class Permutation
{

public:
  //Can be HAMMING_DISTANCE or KENDALLS_DISTANCE
  Permutation(const std::string &alignment = std::string(), const int sourceLength = 0, const int targetLength = 0 );

  ~Permutation() {};

  inline void clear() {
    m_array.clear();
  }
  inline size_t size() {
    return m_array.size();
  }


  void set(const std::string &alignment,const int sourceLength);

  float distance(const Permutation &permCompare, const distanceMetric_t &strategy = HAMMING_DISTANCE) const;

  //Const
  void dump() const;
  size_t getLength() const;
  std::vector<int> getArray() const;
  int getTargetLength() const {
    return m_targetLength;
  }


  //Static
  static std::string convertMosesToStandard(std::string const & alignment);
  static std::vector<int> invert(std::vector<int> const & inVector);
  static bool checkValidPermutation(std::vector<int> const & inVector);

protected:
  std::vector<int> m_array;
  int m_targetLength;
  float calculateHamming(const Permutation & compare) const;
  float calculateKendall(const Permutation & compare) const;

private:
};


}

#endif