📄 wordsegment.cpp
字号:
#include "stdafx.h"
#include "WordSegment.h"
const unsigned int CWordSegment::cwsTag = 0x0001; // word classify tag
const unsigned int CWordSegment::cwsUserDict = 0x0002; // User defining dictionary
const unsigned int CWordSegment::cwsCPlaceName = 0x0004; // Chinese place name
const unsigned int CWordSegment::cwsCName = 0x0008; // chinese name
const unsigned int CWordSegment::cwsTranslationName = 0x0010; // translation name, include translation
// person name and place name etc.
const unsigned int CWordSegment::cwsIdiom = 0x0040; // chinese Idiom dictionary
const unsigned int CWordSegment::cwsOrganiseName = 0x0080; // chinese organise name and etc.
CWordSegment g_WordSeg;
bool CWordSegment::InitFCDll(char * m_strPath)
{
char strFileName[MAX_PATH];
strcpy(strFileName,m_strPath);
strcat(strFileName,"\\Fc2000ws.ini");
FILE *stream;
if( (stream = fopen( strFileName, "w+" )) == NULL )
return false;
fprintf(stream,"%s\n","[DeskTop]");
fprintf(stream,"%s","LibPath=");
fprintf(stream,"%s",m_strPath);
fprintf(stream,"%s\n","\\dict\\");
fprintf(stream,"%s\n","ServerAddress=zhou");
fprintf(stream,"%s\n","WebServer=True");
fclose(stream);
strcpy(strFileName,m_strPath);
strcat(strFileName,"\\cws2000.DLL");
hFcDLL = LoadLibrary(strFileName);
if (hFcDLL != NULL)
{
fcwsSegment = (TcwsSegment)GetProcAddress(hFcDLL, "cwsSegment");
fcwsGetWord = (TcwsGetWord)GetProcAddress(hFcDLL, "cwsGetWord");
fcwsSetSegSetting = (TcwsSetSegSetting)GetProcAddress(hFcDLL, "cwsSetSegSetting");
fcwsGetSegSetting = (TcwsGetSegSetting)GetProcAddress(hFcDLL, "cwsGetSegSetting");
return true;
}
else
return false;
}
void CWordSegment::FreeFCDll(void)
{
if (hFcDLL != NULL)
FreeLibrary(hFcDLL);
}
int CWordSegment::cwsSegment(char far* sentence)
{
if ((hFcDLL != NULL) && (fcwsSegment != NULL))
return fcwsSegment( sentence );
else
return -1;
}
char far* CWordSegment::cwsGetWord(int index, char far* buffer, char far* tag)
{
if ((hFcDLL != NULL) && (fcwsGetWord != NULL))
return fcwsGetWord( index, &buffer, &tag );
else
return NULL;
}
void CWordSegment::cwsSetSegSetting(unsigned int aSetting)
{
if ((hFcDLL != NULL) && (fcwsSetSegSetting != NULL))
fcwsSetSegSetting( aSetting );
}
unsigned int CWordSegment::cwsGetSegSetting(void)
{
if ((hFcDLL != NULL) && (fcwsGetSegSetting != NULL))
return fcwsGetSegSetting();
else
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -