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

📄 zhiwentiqudlg.cpp

📁 关键词抽取技术广泛应用于信息检索、文本分类/聚类、信息过滤
💻 CPP
字号:
// ZhiWenTiQuDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HLSwknlTool.h"
#include "ZhiWenTiQuDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CZhiWenTiQuDlg dialog


CZhiWenTiQuDlg::CZhiWenTiQuDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CZhiWenTiQuDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CZhiWenTiQuDlg)
	m_strMarkSource = _T("");
	m_strMarkResult = _T("");
	//}}AFX_DATA_INIT
}

BOOL CZhiWenTiQuDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	GetDlgItem(IDC_STATIC_ZW)->SetWindowText("语意指纹:");
	GetDlgItem(IDC_BUTTON_MARKLOAD)->SetWindowText("载入(&L)");
	GetDlgItem(IDC_BUTTON_MARKANALYSE)->SetWindowText("分析(&S)");
	GetDlgItem(IDC_BUTTON_MARKERASE)->SetWindowText("清空(&E)");
	GetDlgItem(IDC_EDIT_MARKSOURCE)->SetFocus();
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CZhiWenTiQuDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CZhiWenTiQuDlg)
	DDX_Text(pDX, IDC_EDIT_MARKSOURCE, m_strMarkSource);
	DDX_Text(pDX, IDC_EDIT_MARKRESULT, m_strMarkResult);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CZhiWenTiQuDlg, CDialog)
	//{{AFX_MSG_MAP(CZhiWenTiQuDlg)
	ON_BN_CLICKED(IDC_BUTTON_MARKLOAD, OnButtonMarkload)
	ON_BN_CLICKED(IDC_BUTTON_MARKANALYSE, OnButtonMarkanalyse)
	ON_BN_CLICKED(IDC_BUTTON_MARKERASE, OnButtonMarkerase)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZhiWenTiQuDlg message handlers

void CZhiWenTiQuDlg::OnButtonMarkload() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	//选择文件
	CFileDialog cdlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"文本文件(*.txt)|*.txt|All File(*.*)|*.*||",this);
	if(cdlg.DoModal()==IDOK)
	{
		CFile file ;
		CString strFile = cdlg.GetFileName();
		if(!file.Open(strFile,CFile::modeRead))//打开选择的文件
		{
			AfxMessageBox("文件打开失败!");
			return ;
		}
		int nLen = file.GetLength();//获得文件长度
		LPSTR lpTemp = m_strMarkSource.GetBuffer(nLen+1);
		file.Read(lpTemp,nLen);//读取文件内容
		lpTemp[nLen] = _T('\0');
		m_strMarkSource.ReleaseBuffer();
		file.Close();

		m_strMarkResult = "";
		
		UpdateData(FALSE);//显示在界面中
	}
}

void CZhiWenTiQuDlg::OnButtonMarkanalyse() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	
	m_strMarkResult = "";
	
	///打开分词句柄
	HANDLE hHandle = HLOpenSplit();
	if(hHandle == INVALID_HANDLE_VALUE)
	{
		AfxMessageBox("分词句柄打开失败!");
		return ;
	}
	int nExtra =0;
	nExtra |= HL_CAL_OPT_FINGER;
	DWORD dwStart = GetTickCount();
	HLSplitWord(hHandle,(LPCTSTR)m_strMarkSource,nExtra);//进行分词
	DWORD dwEnd = GetTickCount();
	CString strMsg ;
	strMsg.Format("字节:%d  耗时:%dms",m_strMarkSource.GetLength(),(dwEnd-dwStart));
	AfxMessageBox(strMsg);
	LPBYTE pData ;
	unsigned long nDataLen ;
	if(HLGetFingerM(hHandle,pData,nDataLen))//获得语义指纹
	{
		for(int j = 0 ; j < nDataLen ; j++)
		{
			CString strU ;
			strU.Format("%2.2x ",pData[j]);
			m_strMarkResult += strU ;
		}
	}
	HLCloseSplit(hHandle);//关闭分词句柄
	
	UpdateData(FALSE);
}

void CZhiWenTiQuDlg::OnButtonMarkerase() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	
	m_strMarkSource = _T("");
	GetDlgItem(IDC_EDIT_MARKSOURCE)->SetFocus();
	m_strMarkResult = _T("");
	
	UpdateData(FALSE);
}


BOOL CZhiWenTiQuDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE))
		return true;	
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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