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

TranslationOptionList.h « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 119a308f75970fcd3a8179d0c448dc39083cc509 (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
72
// -*- c++ -*-
#pragma once

#include <vector>
#include "util/exception.hh"
#include <iostream>
#include "Util.h"

namespace Moses
{

class TranslationOption;

/** wrapper around vector of translation options
 */
class TranslationOptionList
{
  friend std::ostream& operator<<(std::ostream& out, const TranslationOptionList& coll);

protected:
  typedef std::vector<TranslationOption*> CollType;
  CollType m_coll;

public:
  typedef CollType::iterator iterator;
  typedef CollType::const_iterator const_iterator;
  const_iterator begin() const {
    return m_coll.begin();
  }
  const_iterator end() const {
    return m_coll.end();
  }
  iterator begin() {
    return m_coll.begin();
  }
  iterator end() {
    return m_coll.end();
  }

  TranslationOptionList() {
  }
  TranslationOptionList(const TranslationOptionList &copy);
  ~TranslationOptionList();

  void resize(size_t newSize) {
    m_coll.resize(newSize);
  }
  size_t size() const {
    return m_coll.size();
  }

  const TranslationOption *Get(size_t ind) const {
    return m_coll.at(ind);
  }

  void Remove( size_t ind ) {
    UTIL_THROW_IF2(ind >= m_coll.size(),
                   "Out of bound index " << ind);
    m_coll.erase( m_coll.begin()+ind );
  }
  void Add(TranslationOption *transOpt) {
    UTIL_THROW_IF2(!transOpt, "Not a valid translation option!");
    m_coll.push_back(transOpt);
  }

  TO_STRING();

  size_t SelectNBest(size_t const N);
  size_t PruneByThreshold(float const th);

};
}