資源簡介
用C語言編寫的源代碼. 實現了準確的中文分詞.

代碼片段和文件信息
/******************************************
http://www.sqlet.com
mail:199909@gmail.com
中文分詞測試版
author:linfj
詞典文件:sqlet.dict
*******************************************/
#include?
#include?
#include?
#define?BOOL char
#define?bool BOOL
#define?TRUE 1
#define?FALSE 0
#define?MAX_CWORD_LEN 10 //最長的詞
#define?MAX_SWORD_LEN 256 //最長的句子
#define MAX_CDIM 90
//不進行索引的單詞
char?*arrayEnglishStop[]?=?{
“a“?“b“?“c“?“d“?“e“?“f“?“g“?“h“?“i“?“j“?“k“?“l“?“m“?“n“?“o“?“p“?“q“?“r“?“s“?“t“?“u“?“v“?“w“?“x“?“y“?“z“?
“1“?“2“?“3“?“4“?“5“?“6“?“7“?“8“?“9“?“0“??
“about“?“above“?“after“?“again“?“all“?“also“?“am“?“an“?“and“?“any“?“are“?“as“?“at“?
“back“?“be“?“been“?“before“?“behind“?“being“?“below“?“but“?“by“?
“can“?“click“?“do“?“does“?“done“?“each“?“else“?“etc“?“ever“?“every“?
“few“?“for“?“from“?“generally“?“get“?“go“?“gone“?“has“?“have“?“hello“?“here“?“how“?
“if“?“in“?“into“?“is“?“just“?“keep“?“later“?“let“?“like“?“lot“?“lots“?“made“?
“make“?“makes“?“many“?“may“?“me“?“more“?“most“?“much“?“must“?“my“?“need“?“no“?“not“?
“now“?“of“?“often“?“on“?“only“?“or“?“other“?“others“?“our“?“out“?“over“?“please“?“put“?
“so“?“some“?“such“?“than“?“that“?“the“?“their“?“them“?“then“?“there“?“these“?“they“?
“this“?“try“?“to“?“up“?“us“?“very“?“want“?“was“?“we“?“well“?“what“?“when“?“where“?
“which“?“why“?“will“?“with“?“within“?“you“?“your“?“yourself“
};
//詞典索引時字或詞不需要索引
char?*arrayChineseStop[]?=?{
“的““嗎““么““啊““說““對““在““和““是“
“被““最““所““那““這““有““將““會““與“
“於““于““他““她““它““您““為““歡迎“
};
//全角的ASCII要全部轉成半角英文字符以后還要加入其它的符號如.;/|等
//區碼為163的都要轉成ascii
//163 !?"?#?¥?%?&?'?(?)?*?+?,?-?.?/?0?1?2?3?4?5?6?7?8?9?:?;?<?=?>???@?A?B?C?D?E?F?G?H?I?J?K?L?M?N?O?P?Q?R?S?T?U?V?W?X?Y?Z?[?\?]?^?_?`?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?{?|?}? ̄?
// ! ??#??$??%??&??‘???(??)??%?+????-??.??/???0???1??2?
unsigned?char?*arrayWideAscii[]?=?{
“a““b““c““d““e““f““g““h““i““j““k““l““m““n““o““p““q““r““s““t““u““v““w““x““y““z““.“
“A““B““C““D““E““F““G““H““I““J““K““L““M““N““O““P““Q““R““S““T““U““V““W““X““Y““Z““-“
};
//標點符號及漢字的標點符號注意?+?-?“?這三個符號,因為在搜索的時候需要通過他們進行異或等條件判斷
char?arrayAsciiSymbol[]?={
‘!‘‘\\‘‘*‘‘(‘‘)‘‘-‘‘_‘‘+‘‘=‘‘{‘‘}‘‘[‘‘]‘‘:‘‘;‘‘\‘‘‘\“‘‘‘‘<‘‘>‘‘.‘‘?‘‘/‘‘|‘‘@‘‘#‘‘$‘‘%‘‘^‘‘&‘
};
//BIG5與GB對照把所有big5轉成gb后進行處理
//$arrayBig5ToG?=?array?();
//UTF8的轉換
//漢字詞典
typedef?struct?_WORD_NODE
{
char strWord[MAX_CWORD_LEN+1];
//?todo?可以增加?兩個字,三個字,四個字,五個字的數組,這樣查起來更快
struct??_WORD_NODE *nextWord;
}WORD_NODE;
//分詞結果
typedef?struct?_SEG_NODE
{
char strWord[MAX_CWORD_LEN+1];
struct _SEG_NODE *nextWord;
}SEG_NODE;
struct?_CH_DICT?{
WORD_NODE *lstWord;
}CH_DICT[MAX_CDIM][MAX_CDIM];
struct?_SEG_LIST?{
SEG_NODE *lstWord;
}S
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????14853??2005-11-27?23:16??splitword.c
-----------?---------??----------?-----??----
????????????????14853????????????????????1
- 上一篇:OpenGL紋理茶壺
- 下一篇:Kinectv2 __MFC
評論
共有 條評論