⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 word.h.svn-base

📁 moses开源的机器翻译系统
💻 SVN-BASE
字号:
// $Id$/***********************************************************************Moses - factored phrase-based language decoderCopyright (C) 2006 University of EdinburghThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA***********************************************************************/#pragma once#include <iostream>#include <vector>#include <list>#include "TypeDef.h"#include "Factor.h"#include "Util.h"class Phrase;/*** * hold a set of factors for a single word */class Word{	friend std::ostream& operator<<(std::ostream&, const Word&);protected:	typedef const Factor * FactorArray[MAX_NUM_FACTORS];	FactorArray m_factorArray; /**< set of factors */public:	/** deep copy */	Word(const Word &copy) {		std::memcpy(m_factorArray, copy.m_factorArray, sizeof(FactorArray));	}	/** empty word */	Word() {		std::memset(m_factorArray, 0, sizeof(FactorArray));	}	~Word() {}	//! returns Factor pointer for particular FactorType	const Factor*& operator[](FactorType index) {		return m_factorArray[index];	}	const Factor * const & operator[](FactorType index) const {		return m_factorArray[index];	}	//! Deprecated. should use operator[]	inline const Factor* GetFactor(FactorType factorType) const {		return m_factorArray[factorType];	}	inline void SetFactor(FactorType factorType, const Factor *factor)	{		m_factorArray[factorType] = factor;	}	/** add the factors from sourceWord into this representation,	 * NULL elements in sourceWord will be skipped */	void Merge(const Word &sourceWord);	/** get string representation of list of factors. Used by PDTimp so supposed 	* to be invariant to changes in format of debuggin output, therefore, doesn't 	* use streaming output or ToString() from any class so not dependant on 	* these debugging functions.	*/	std::string GetString(const std::vector<FactorType> factorType,bool endWithBlank) const;	TO_STRING();	//! transitive comparison of Word objects  inline bool operator< (const Word &compare) const  { // needed to store word in GenerationDictionary map          // uses comparison of FactorKey          // 'proper' comparison, not address/id comparison          return Compare(*this, compare) < 0;  }	/* static functions */		/** transitive comparison of 2 word objects. Used by operator<. 	*	Only compare the co-joined factors, ie. where factor exists for both words.	*	Should make it non-static	*/	static int Compare(const Word &targetWord, const Word &sourceWord);};struct WordComparer{	//! returns true if hypoA can be recombined with hypoB	bool operator()(const Word *a, const Word *b) const	{		return *a < *b;	}};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -