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

📄 win_cdemo.cpp

📁 中科院计算所的分词程序
💻 CPP
字号:
// win_cDemo.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "win_cDemo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include "ICTCLAS30.h"


// 唯一的应用程序对象

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// 初始化 MFC 并在失败时显示错误
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: 更改错误代码以符合您的需要
		_tprintf(_T("致命错误: MFC 初始化失败\n"));
		nRetCode = 1;
	}
	else
	{
		// TODO: 在此处为应用程序的行为编写代码。

		printf("hello world!\n");
		
		//init ICTCLAS
		if(!ICTCLAS_Init())
		{
			printf("ICTCLAS INIT FAILED!\n");
			system("pause");
			return -1;
		}
		printf("ICTCLAS init success!\n");

		//未加词典
		char sString[1000] = "点击下载超女纪敏佳深受观众喜爱。禽流感爆发在非典之后。";
		const char * sResult;
		printf("Before User-defined dictionary used:\n");
		sResult = ICTCLAS_ParagraphProcess(sString,2);
		printf("%s\n",sResult);

		//imp userdict
		int iWordCount = ICTCLAS_ImportUserDict("userdict.txt");
		printf("import %d user words!\n",iWordCount);

		//加词典后
		printf("After User-defined dictionary used:\n");
		sResult = ICTCLAS_ParagraphProcess(sString,1);
		printf("%s\n",sResult);

		//file paragraphprocess
		double bFileParagraph;
		bFileParagraph = ICTCLAS_FileProcess("test.txt","test_result.txt",1);
		
		//loop
		printf("input you string to paragraph!(input \"q\" to exit)\n");
		scanf("%s",sString);
		while(strcmp(sString,"q")!=0)
		{
			sResult = ICTCLAS_ParagraphProcess(sString,1);
			printf("%s\n",sResult);
			printf("input you string to paragraph!(input \"q\" to exit)\n");
			scanf("%s",sString);
		}

		//word Exist  ??没有接口?
//		const result_t *pVecResult;

	

		ICTCLAS_Exit();


		system("pause");
	}

	return nRetCode;
}

⌨️ 快捷键说明

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