?? postag.cpp
字號(hào):
// PosTag.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "PosTag.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "PosTagDoc.h"
#include "PosTagView.h"
extern int MorphorAnalyze(char *sen);
extern SentenceType g_objMorSent;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPosTagApp
BEGIN_MESSAGE_MAP(CPosTagApp, CWinApp)
//{{AFX_MSG_MAP(CPosTagApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_DICTIONARY_BUILDINDEXSTEP1, OnDictionaryBuildindexstep1)
ON_COMMAND(ID_DICTIONARY_BUILDINDEXSTEP2, OnDictionaryBuildindexstep2)
ON_COMMAND(ID_DICTIONARY_BUILDINDEXSTEP3, OnDictionaryBuildindexstep3)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPosTagApp construction
CPosTagApp::CPosTagApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
bIsInit=false;
m_obDiction=NULL;
m_obSysDiction=NULL; //系統(tǒng)詞典數(shù)據(jù)
m_obAddtionDiction=NULL; //系統(tǒng)附加詞典數(shù)據(jù)
m_obUserDiction=NULL; //用戶詞典數(shù)據(jù)
m_fpSysIndexDat=NULL; //系統(tǒng)詞典索引
m_fpAddtionIndexDat=NULL; //系統(tǒng)附加詞典索引
m_fpUserIndexDat=NULL; //用戶詞典索引
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CPosTagApp object
CPosTagApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CPosTagApp initialization
BOOL CPosTagApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_POSTAGTYPE,
RUNTIME_CLASS(CPosTagDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CPosTagView));
pDocTemplate->SetContainerInfo(IDR_POSTAGTYPE_CNTR_IP);
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CPosTagApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CPosTagApp commands
void CPosTagApp::OnDictionaryBuildindexstep1()
{
// TODO: Add your command handler code here
CString strMsg;
strMsg.Format("本函數(shù)是對(duì)英漢詞典重建索引的第一步,\n \
執(zhí)行本步后,舊的索引文件將被刪除.\n繼續(xù)嗎?");
if ( AfxMessageBox(strMsg,MB_YESNO) == IDYES ) {
char szInDefineName[] = "DictRes\\define.txt";
char szOutDefineName[] = "CaimPrg\\DictDef.h";
char szDicIndexName[] = "DictRes\\EcDict";
char szCodeTableName[] = "DictRes\\CodeTab.txt";
char szEngInfoName[] = "DictRes\\EngInfo.txt";
BOOL bResult = BuildIndexStepOne(szInDefineName,szOutDefineName,
szDicIndexName,szEngInfoName,
szCodeTableName,"ecdic\\ecdic.dic");
if ( bResult ) {
strMsg.Format("重建索引的第一步正確完成!\n \
請(qǐng)對(duì)%s文件使用ULTRAEDIT對(duì)第一列進(jìn)行逆序排序 \
(字母z開頭的在前,字母a開頭的在后), \
排序后按原名保存,并執(zhí)行第二步",szEngInfoName);
} else {
strMsg.Format("重建索引的第一步出現(xiàn)錯(cuò)誤!");
}
AfxMessageBox( strMsg );
}
}
void CPosTagApp::OnDictionaryBuildindexstep2()
{
// TODO: Add your command handler code here
CString strMsg;
strMsg.Format("本函數(shù)是對(duì)英漢詞典重建索引的第二步,\n \
注意:在執(zhí)行本步之前,請(qǐng)先對(duì)EngInfo.txt按逆序進(jìn)行排序.\n繼續(xù)嗎?");
if ( AfxMessageBox(strMsg,MB_YESNO) == IDYES ) {
char szEngInfoName[] = "DictRes\\EngInfo.txt";
char szHuffmanFreqDataName[] = "DictRes\\HuffFreq.dat";
char szEngHuffName[] = "DictRes\\EngHuff.txt";
BOOL bResult;
bResult = BuildIndexStepTwo(szEngInfoName,szHuffmanFreqDataName,
szEngHuffName);
if ( bResult ) {
strMsg.Format("重建索引的第二步正確完成!\n \
請(qǐng)對(duì)%s文件使用ULTRAEDIT對(duì)第一列按順序進(jìn)行排序, \
排序后按原名保存,并執(zhí)行第三步",szEngHuffName);
} else {
strMsg.Format("重建索引的第二步出現(xiàn)錯(cuò)誤!");
}
AfxMessageBox( strMsg );
}
}
void CPosTagApp::OnDictionaryBuildindexstep3()
{
CString strMsg;
strMsg.Format("本函數(shù)是對(duì)英漢詞典重建索引的第三步,\n \
注意:在執(zhí)行本步之前,請(qǐng)先對(duì)EngHuff.txt按順序進(jìn)行排序.\n繼續(xù)嗎?");
if ( AfxMessageBox(strMsg,MB_YESNO) == IDYES ) {
char szEngHuffName[] = "DictRes\\EngHuff.txt";
char szDicIndexName[] = "DictRes\\EcDict";
BOOL bResult;
bResult = BuildIndexStepThree(szEngHuffName,szDicIndexName,"ecdic\\Ecdic.dic");
if ( bResult ) {
strMsg.Format("重建索引正確完成!\n");
} else {
strMsg.Format("重建索引的第三步出現(xiàn)錯(cuò)誤!");
}
AfxMessageBox( strMsg );
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -