2010-04-08 21:16:10 +04:00
|
|
|
#pragma once
|
2010-10-12 20:17:41 +04:00
|
|
|
// $Id$
|
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based, hierarchical and syntactic language decoder
|
|
|
|
Copyright (C) 2009 Hieu Hoang
|
2011-02-24 16:57:11 +03:00
|
|
|
|
2010-10-12 20:17:41 +04:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2011-02-24 16:57:11 +03:00
|
|
|
|
2010-10-12 20:17:41 +04:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2011-02-24 16:57:11 +03:00
|
|
|
|
2010-10-12 20:17:41 +04:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
***********************************************************************/
|
2010-04-08 21:16:10 +04:00
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
2012-09-20 00:48:10 +04:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2010-04-08 21:16:10 +04:00
|
|
|
#include "Word.h"
|
|
|
|
|
|
|
|
namespace OnDiskPt
|
|
|
|
{
|
2012-05-15 19:16:16 +04:00
|
|
|
class Vocab;
|
2010-04-08 21:16:10 +04:00
|
|
|
|
2012-09-20 00:48:10 +04:00
|
|
|
|
2012-06-29 04:12:31 +04:00
|
|
|
/** A contiguous phrase. SourcePhrase & TargetPhrase inherit from this and add the on-disk functionality
|
|
|
|
*/
|
2010-04-08 21:16:10 +04:00
|
|
|
class Phrase
|
|
|
|
{
|
2011-02-24 16:57:11 +03:00
|
|
|
friend std::ostream& operator<<(std::ostream&, const Phrase&);
|
2010-04-08 21:16:10 +04:00
|
|
|
|
|
|
|
protected:
|
2012-09-20 00:48:10 +04:00
|
|
|
std::vector<WordPtr> m_words;
|
2011-02-24 16:57:11 +03:00
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
public:
|
2013-06-10 21:11:55 +04:00
|
|
|
Phrase() {
|
|
|
|
}
|
2011-02-24 16:57:11 +03:00
|
|
|
|
2012-10-18 19:35:42 +04:00
|
|
|
virtual ~Phrase() {}
|
|
|
|
|
2012-09-20 00:48:10 +04:00
|
|
|
void AddWord(WordPtr word);
|
|
|
|
void AddWord(WordPtr word, size_t pos);
|
2011-02-24 16:57:11 +03:00
|
|
|
|
|
|
|
const Word &GetWord(size_t pos) const {
|
|
|
|
return *m_words[pos];
|
|
|
|
}
|
|
|
|
size_t GetSize() const {
|
|
|
|
return m_words.size();
|
|
|
|
}
|
|
|
|
|
2012-05-15 19:35:00 +04:00
|
|
|
virtual void DebugPrint(std::ostream &out, const Vocab &vocab) const;
|
2012-05-15 19:16:16 +04:00
|
|
|
|
2011-02-24 16:57:11 +03:00
|
|
|
int Compare(const Phrase &compare) const;
|
|
|
|
bool operator<(const Phrase &compare) const;
|
|
|
|
bool operator>(const Phrase &compare) const;
|
|
|
|
bool operator==(const Phrase &compare) const;
|
2010-04-08 21:16:10 +04:00
|
|
|
};
|
|
|
|
|
2012-09-20 00:48:10 +04:00
|
|
|
typedef boost::shared_ptr<Phrase> PhrasePtr;
|
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
}
|