mosesdecoder/moses/TranslationOptionList.h

73 lines
1.4 KiB
C
Raw Normal View History

2015-02-06 01:29:47 +03:00
// -*- c++ -*-
#pragma once
#include <vector>
#include "util/exception.hh"
#include <iostream>
#include "Util.h"
namespace Moses
{
2015-02-19 15:27:23 +03:00
class TranslationOption;
2015-02-19 15:27:23 +03:00
/** 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);
}
2015-02-19 15:27:23 +03:00
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);
}
2015-02-19 15:27:23 +03:00
TO_STRING();
2015-02-10 02:13:01 +03:00
2015-02-19 15:27:23 +03:00
size_t SelectNBest(size_t const N);
size_t PruneByThreshold(float const th);
2015-02-19 15:27:23 +03:00
};
}