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

📄 dictment.h

📁 计算机英汉机器翻译系统中的英语词性标注方法实现
💻 H
字号:
#ifndef DICTMENT_H
#define DICTMENT_H

const int MAX_DEFINE_LINE_LEN = 100;
const int MAX_DIC_NUM = 159; // 原始的英汉词典的文件个数

class ObWord:public CObject
{
public:				
	int m_nIndex;
	void GiveVolue(int nIndex)
	{
		m_nIndex = nIndex;
	}
};

const int MAX_SOU_LINE_LEN = 300; // 源词典最大的一行的长度

typedef struct Slot{ // 槽
	BOOL m_bIsTranRule; // 当前是翻译规则还是槽
	LPSTR m_pszSlotName; // 槽名
	LPSTR m_pszSlotValue; // 槽值
	Slot *m_pNextSlot; // 下一个槽
} Slot;

typedef struct ChinesePart{
	LPSTR m_pszChinese; // 中文译文
	int m_nChineseLen; // 中文译文长度
	LPSTR m_pszCate; // 词性
	LPSTR m_pszHead; // 语义大类
	
	Slot *m_pFirstSlot; // 第一个槽
	Slot *m_pLastSlot; // 最后一个槽

	Slot *m_pCurrSlot; // 当前正在操作的槽

	ChinesePart *m_pNextPart; // 下一个中文译文(义项)部分
} ChinesePart;

// 词的类型定义
// 注意:
// 改动类型定义时请务必改动STYLE_FIRST和STYLE_LAST的值,
// 使 STYLE_FIRST 等于定义值等于类型定义的最小值,
// STYLE_LAST值等于类型定义的最大值
const int STYLE_FIRST = 0; 
const int STYLE_ORIG = 0;
const int STYLE_ED	= 1; // 过去时
const int STYLE_ING = 2; // 过去分词
const int STYLE_IS = 3;
const int STYLE_S = 4;
const int STYLE_AM = 5;
const int STYLE_ARE = 6;
const int STYLE_ED1 = 7;
const int STYLE_ED2 = 8;
const int STYLE_LAST = 8;
// 注:上面类型的定义如果改动,请务必改动DictSearch::OutputNodeToFile
// 中对应的定义

const int MAX_SLOT_NAME_NUM = 100; // 最大的槽名数

class COneWord {
public:
	COneWord();
	~COneWord();

	LPSTR m_pszEnglish; // 英文
	int m_nEnglishLen; //  英文长度
	BOOL m_bIsExistOrig; // 是否存在原形
	// Eg:
	//	#abstracted\^abstract[ed]
	//	*心不在焉,Cate=A
	//	$
	LPSTR m_pszOrig; // 原形
	int m_nOrigLen;
	int m_nWordStyle; // 词的类型:过去式,进行式,
	BOOL m_bIsExistAmbig; // 是否存在兼类
	LPSTR m_pszAmbig; // 兼类内容
	int m_nAmbigLen;

	ChinesePart *m_pFirstChinese; // 第一个中文译文
	ChinesePart *m_pLastChinese; // 最后一个中文译文
	ChinesePart *m_pCurrChinese; // 当前正在操作的中文译文
	LPSTR m_pszDicName;
	int m_nCurrReadLineNum; // 当前正在读第几行
	
	CMapStringToOb m_mapCate; // Cate 的种类
	CMapStringToOb m_mapHead; // Head 的种类
	CMapStringToOb m_mapAmbig; // 兼类的种类
	CMapStringToOb m_mapNoValueSlot; // 没有槽值的槽的种类
	
	int m_nSlotNameNum; // 槽名的数量
	CStringArray m_arraySlotName; // 槽名的种类
	CMapStringToOb m_mapSlotName; // 槽名的种类
	CMapStringToOb m_mapSlotValue[MAX_SLOT_NAME_NUM]; // 槽值

	BOOL FillMap(CMapStringToOb &mapName,FILE *fpDefine);
	BOOL FillMapWithArray(CMapStringToOb &mapName,
						  CStringArray &arrayName,
						  int &nNameNum,FILE *fpDefine);
	BOOL Init(LPSTR pszDefineName);
	void FreeMap(CMapStringToOb &mapName);
	void ExitInit();

public:
	BOOL m_bIsWriteLog; // 是否写错误说明
	FILE *m_fpErrLogFile; // 错误说明文件
	
	BOOL m_bIsWriteErrToDic; // 是否写错误写到词典中
	FILE *m_fpTarDic; // 带错误标记的词典文件

public:
	BOOL SetEnglishOfWordItem(LPSTR pszEnglish,int nEnglishLen);
	BOOL SetChiTextOfWordItem(LPSTR pszChinese,int nChineseLen);
	BOOL SetCateOfWordItem(LPSTR pszCate,int nCateLen);
	BOOL SetHeadOfWordItem(LPSTR pszHead,int nHeadLen);
	BOOL SetOrigWord(LPSTR pszLeft);
	BOOL SetAmbig(LPSTR pszLeft);
	Slot *MakeSlot(BOOL bIsTranRule,LPSTR pszSlotName,
						 int nSlotNameLen,LPSTR pszSlotValue,
						 int nSlotValueLen);
	BOOL SetSoltOfWordItem(LPSTR pszLeft);
	BOOL SetChiPartOfWordItem(LPSTR pszChiPart);
	BOOL ReadWordFromSouDict(FILE *fpSouFile,LPSTR pszSouName,FILE *fpTarDic,
							 BOOL &bIsEof);

	void FreeSlotLink(Slot *pFirstSlot);
	void FreeChineseLink();
	void EmptyWordContent();
	void GotoNextWordBegin(FILE *fpSouFile);
	void GetEnglish(LPSTR &pszEnglish,int &nEngLen);
};

//yys 98.5.14 Bgn
//添加一个形参 szDicName
extern BOOL FormatCheck(LPSTR pszLogFile,LPSTR pszDefineName,LPSTR pszErrLineInfo,char *szDicName);
//yys 98.5.14 End

extern void DumpSlot(Slot *pCurrSlot,FILE *fpSlotName,
			  FILE *fpSlotValue,FILE *fpNoValuSlot,FILE *fpRule);
extern void DumpChinesePart(ChinesePart *pCurrChinese,
					 FILE *fpCate,FILE *fpHead,FILE *fpSlotName,
					 FILE *fpSlotValue,FILE *fpNoValuSlot,FILE *fpRule);
extern void DumpDict(BOOL bIsWriteErrorToLog,LPSTR pszLogFile,LPSTR pszDefineName);

extern BOOL RemoveErrorInfoFromDict();
#endif


⌨️ 快捷键说明

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