mosesdecoder/contrib/other-builds/moses2/Word.h

60 lines
1023 B
C
Raw Normal View History

2015-10-23 18:46:35 +03:00
/*
* Word.h
*
* Created on: 23 Oct 2015
* Author: hieu
*/
2015-10-23 22:53:36 +03:00
#pragma once
2015-10-26 19:32:47 +03:00
#include <iostream>
2015-10-23 22:53:36 +03:00
#include "TypeDef.h"
2015-11-13 13:40:55 +03:00
#include "legacy/Factor.h"
2015-11-13 01:51:13 +03:00
#include "legacy/FactorCollection.h"
2015-10-23 18:46:35 +03:00
2015-12-10 23:49:30 +03:00
namespace Moses2
{
2015-10-23 18:46:35 +03:00
class Word {
2015-10-26 19:32:47 +03:00
friend std::ostream& operator<<(std::ostream &, const Word &);
2015-10-23 18:46:35 +03:00
public:
2015-10-24 01:19:31 +03:00
Word();
2015-12-07 19:49:02 +03:00
Word(const Word &copy);
2015-10-24 01:19:31 +03:00
virtual ~Word();
2015-11-18 14:08:32 +03:00
void CreateFromString(FactorCollection &vocab, const System &system, const std::string &str);
2015-10-26 17:58:59 +03:00
2015-10-24 01:19:31 +03:00
size_t hash() const;
2015-11-26 03:53:12 +03:00
int Compare(const Word &compare) const;
bool operator==(const Word &compare) const
{
int cmp = Compare(compare);
return cmp == 0;
}
2015-12-15 16:36:44 +03:00
bool operator!=(const Word &compare) const
{
return !( (*this) == compare );
}
2015-11-25 20:35:22 +03:00
bool operator<(const Word &compare) const;
2015-10-23 22:53:36 +03:00
2015-11-13 01:51:13 +03:00
const Factor* operator[](size_t ind) const {
2015-10-28 20:47:37 +03:00
return m_factors[ind];
}
2015-11-13 01:51:13 +03:00
const Factor*& operator[](size_t ind) {
2015-10-28 20:47:37 +03:00
return m_factors[ind];
}
2015-12-18 21:38:24 +03:00
std::string GetString(const FactorList &factorTypes) const;
2015-10-23 22:53:36 +03:00
protected:
2015-11-13 01:51:13 +03:00
const Factor *m_factors[MAX_NUM_FACTORS];
2015-10-26 17:58:59 +03:00
2015-10-23 18:46:35 +03:00
};
2015-12-10 23:49:30 +03:00
}