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
|
|
|
|
{
|
|
|
|
|
2016-03-31 23:00:16 +03:00
|
|
|
class Word
|
|
|
|
{
|
2015-10-23 18:46:35 +03:00
|
|
|
public:
|
2016-05-06 18:07:57 +03:00
|
|
|
explicit Word();
|
|
|
|
explicit Word(const Word ©);
|
2015-12-07 19:49:02 +03:00
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
virtual ~Word();
|
|
|
|
|
2016-03-31 23:00:16 +03:00
|
|
|
void CreateFromString(FactorCollection &vocab, const System &system,
|
|
|
|
const std::string &str);
|
2015-10-26 17:58:59 +03:00
|
|
|
|
2016-04-20 22:22:57 +03:00
|
|
|
virtual size_t hash() const;
|
2015-11-26 03:53:12 +03:00
|
|
|
int Compare(const Word &compare) const;
|
|
|
|
|
2016-04-20 22:22:57 +03:00
|
|
|
virtual bool operator==(const Word &compare) const
|
2015-11-26 03:53:12 +03:00
|
|
|
{
|
2016-03-31 23:00:16 +03:00
|
|
|
int cmp = Compare(compare);
|
|
|
|
return cmp == 0;
|
2015-11-26 03:53:12 +03:00
|
|
|
}
|
|
|
|
|
2016-04-20 22:22:57 +03:00
|
|
|
virtual bool operator!=(const Word &compare) const
|
2015-12-15 16:36:44 +03:00
|
|
|
{
|
2016-03-31 23:00:16 +03:00
|
|
|
return !((*this) == compare);
|
2015-12-15 16:36:44 +03:00
|
|
|
}
|
|
|
|
|
2016-04-20 22:22:57 +03:00
|
|
|
virtual bool operator<(const Word &compare) const;
|
2015-10-23 22:53:36 +03:00
|
|
|
|
2016-03-31 23:00:16 +03:00
|
|
|
const Factor* operator[](size_t ind) const
|
|
|
|
{
|
|
|
|
return m_factors[ind];
|
2015-10-28 20:47:37 +03:00
|
|
|
}
|
|
|
|
|
2016-03-31 23:00:16 +03:00
|
|
|
const Factor*& operator[](size_t ind)
|
|
|
|
{
|
|
|
|
return m_factors[ind];
|
2015-10-28 20:47:37 +03:00
|
|
|
}
|
|
|
|
|
2016-06-11 03:31:40 +03:00
|
|
|
virtual void OutputToStream(std::ostream &out) const;
|
2016-06-20 16:59:31 +03:00
|
|
|
virtual std::string Debug(const System &system) const;
|
2016-04-21 18:22:09 +03:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|