91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 28KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-09
  • 語(yǔ)言: C/C++
  • 標(biāo)簽: 分詞??

資源簡(jiǎn)介

基于C++編寫的中文分詞程序,內(nèi)有完整的代碼,且有小詞庫(kù),解壓即可運(yùn)行

資源截圖

代碼片段和文件信息

//fc.cpp
#include?
#include?
#include?
#include?“fc.h“


CSegment::CSegment(int?MaxLen)
{
m_MaxLen=MaxLen;
m_nPosIndex=0;
}

CSegment::~CSegment()
{
}

void?CSegment::MM(CString&?sourceint?lenint?frompos)
{
CString?tmp=SubString(sourcefromposlen);
if(m_nPosIndex>=source.GetLength?()-1)?return;

char*?tmpstr=(char*)tmp.LockBuffer?();
if(Match(tmpstr))
{//匹配
m_sResult=m_sResult+CString(tmpstr)+“/“;
m_nPosIndex=m_nPosIndex+m_MaxLen;
m_MaxLen=6;
MM(sourcem_MaxLenm_nPosIndex);
}
else
{//不匹配
if(m_MaxLen>1)
{
m_MaxLen=m_MaxLen-2;
MM(sourcem_MaxLenm_nPosIndex);
}
else
{
m_sResult=m_sResult+“字典中沒(méi)有‘“+CString(tmpstr)+“’字/“;
????????????m_nPosIndex=m_nPosIndex+2;
m_MaxLen=6;
MM(sourcem_MaxLenm_nPosIndex);
}
}
tmp.UnlockBuffer?();
}


CString?CSegment::SubString(CString?&?sourceint?fromposint?len)
{//取子串
char?*mStr;//子串
char?sChar[3];
int?nLen=source.GetLength?();
mStr=new?char[nLen];//malloc?buffer
mStr[0]=0;
sChar[2]=0;
int?nPosIndex=fromposLensxLen;
//還需做判斷,若所取的最大的字符數(shù)已經(jīng)超過(guò)了源串剩下的子串,則處理。
sxLen=(nLen-frompos);//源串剩下的子串的長(zhǎng)度
if(len>sxLen)
Len=sxLen;
else
Len=len;
Len=Len+nPosIndex;

while(nPosIndex {
sChar[0]=source.GetAt?(nPosIndex);//Get?a?char
sChar[1]=0;
if(source.GetAt?(nPosIndex)<0)
{//double?byte?char
nPosIndex+=1;
sChar[1]=source.GetAt?(nPosIndex);
}
nPosIndex+=1;
strcat(mStrsChar);
}
CString?result(mStr);
delete?mStr;//記住到后面要把指針刪除調(diào)
return?result;
}

BOOL?CSegment::Match(char*?str)
{//取出了子串mStr后,就要打開(kāi)文本文件(字典D),循環(huán)讀取字典D中有否該子串,有則返回正確,否則返回錯(cuò)誤。
FILE?*?dict=fopen(“dic.txt““r“);
if(dict==NULL)?return?0;
unsigned?int?len=strlen(str);
char?*?cmp=new?char[len+1];
while(fgets(cmplen+1dict)!=NULL)//當(dāng)讀取到文件結(jié)束時(shí),退出循環(huán)
{//比較讀取的串cmp和str是否相同
if(strcmp(cmpstr)==0)//匹配
{
fclose(dict);
return?1;?
}
}
fclose(dict);
return?0;
}




?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件????????220??2005-09-12?16:10??分詞\DIC.TXT

?????文件???????2140??2011-03-24?18:45??分詞\fc.cpp

?????文件????????372??2011-03-14?05:43??分詞\fc.h

?????文件???????3537??2011-03-24?18:19??分詞\ReadMe.txt

?????文件???????1078??2011-03-24?18:19??分詞\res\分詞.ico

?????文件????????396??2011-03-24?18:19??分詞\res\分詞.rc2

?????目錄??????????0??2011-03-24?18:19??分詞\res

?????文件????????774??2011-03-24?18:41??分詞\resource.h

?????文件????????206??2011-03-24?18:19??分詞\StdAfx.cpp

?????文件???????1054??2011-03-24?18:19??分詞\StdAfx.h

?????文件??????35304??2011-03-24?19:01??分詞\分詞.aps

?????文件???????1057??2011-03-24?19:06??分詞\分詞.clw

?????文件???????2013??2011-03-24?18:19??分詞\分詞.cpp

?????文件???????4253??2011-03-24?19:07??分詞\分詞.dsp

?????文件????????533??2011-03-24?18:19??分詞\分詞.dsw

?????文件???????1280??2011-03-24?18:19??分詞\分詞.h

?????文件??????41984??2011-03-24?19:07??分詞\分詞.ncb

?????文件??????48640??2011-03-24?19:07??分詞\分詞.opt

?????文件????????664??2011-03-24?19:01??分詞\分詞.plg

?????文件???????5247??2011-03-24?19:01??分詞\分詞.rc

?????文件???????4272??2011-03-24?18:55??分詞\分詞Dlg.cpp

?????文件???????1317??2011-03-24?18:28??分詞\分詞Dlg.h

?????目錄??????????0??2011-03-24?19:12??分詞

-----------?---------??----------?-----??----

???????????????156341????????????????????23


評(píng)論

共有 條評(píng)論