• 大小: 3.59MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-15
  • 语言: C/C++
  • 标签: 分词  C  中文分词  

资源简介

包内包含中文分词作业描述、C语言源程序、可执行文件和说明文档

资源截图

代码片段和文件信息

#include 
#include 
#include 


#define BOOL char
#define bool BOOL
#define TRUE 1
#define FALSE 0
#define MAX_CWORD_LEN 18 //最长的词
#define MAX_SWORD_LEN 256 //最长的句子
#define MAX_CDIM 90
#define MAX_WORD 8000

//不进行索引的单词
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[] = {
“的““吗““么““啊““说““对““在““和““是“
“被““最““所““那““这““有““将““会““与“
“於““于““他““她““它““您““为““欢迎“
};



//标点符号及汉字的标点符号注意 + - “ 这三个符号,因为在搜索的时候需要通过他们进行异或等条件判断

char arrayAsciiSymbol[] ={
‘!‘‘\\‘‘*‘‘(‘‘)‘‘-‘‘_‘‘+‘‘=‘‘{‘‘}‘‘[‘‘]‘‘:‘‘;‘‘\‘‘‘\“‘‘‘‘<‘‘>‘‘.‘‘?‘‘/‘‘|‘‘@‘‘#‘‘$‘‘%‘‘^‘‘&‘
};



//汉字词典
typedef struct _WORD_NODE
{
char strWord[MAX_CWORD_LEN+1];
// todo 可以增加 两个字,三个字,四个字,五个字的数组,这样查起来更快
struct  _WORD_NODE *nextWord;
}WORD_NODE;    //定义结构体类型

struct _CH_DICT {
WORD_NODE *lstWord;
}CH_DICT[MAX_CDIM][MAX_CDIM];    //定义结构体二维数组变量:词典

char SEG_LIST[MAX_WORD];  //定义数组存放分词后的句串
int WNUM_IN = 0;
int WNUM_OUT = 0;


char  *strTrim(char str[])
{
  int firstchar=0;
  int endpos=0;
  int i;
  int firstpos=0;

  for(i=0;str[i]!=‘\0‘;i++){
    if(str[i]==‘ ‘ || str[i] == ‘\r‘ || str [i] == ‘\n‘ || str [i]==‘\t‘){
      if(firstchar==0) firstpos++;
    }
    else{
      endpos=i;
      firstchar=1;
    }
  }

  for(i=firstpos;i<=endpos;i++)
    str[i-firstpos]=str[i];    //去除待处理字符串中的空格、换行等
  str[i-firstpos]=‘\0‘;

  return str;
}

int addDictWord(char *strWord  int len)
{
unsigned char firstCharlastChar;
WORD_NODE* curLst;

WORD_NODE* newWord *curTmp ;

firstChar = strWord[0] ;
lastChar  = strWord[len-1];

if (firstChar < 161 || lastChar < 161 ) //建立汉字词典,不允许出现非汉字或是汉字的全角符号
  return -1;

newWord = (WORD_NODE*)malloc(sizeof(WORD_NODE));
if ( newWord == NULL)
return -1;
strcpy(newWord->strWord

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    4599128  2005-01-13 22:30  中文分词\分词作业\ziguang.txt

     文件        144  2007-04-10 23:21  中文分词\分词作业\作业布置.txt

     文件     875008  2008-10-18 15:03  中文分词\分词作业\最大匹配分词法.doc

     文件       4580  2007-04-10 23:17  中文分词\分词作业\测试文档-2.txt

     文件       2542  2005-04-11 09:25  中文分词\分词作业\测试文档.txt

     文件       7376  2005-04-11 09:26  中文分词\分词作业\测试文档(已分词)-2.txt

     文件       4176  2005-04-11 09:27  中文分词\分词作业\测试文档(已分词).txt

     文件      11670  2008-11-01 21:36  中文分词\中文分词作业源代码和文档\fenci.cpp

     文件     192602  2008-11-01 21:09  中文分词\中文分词作业源代码和文档\fenci.exe

     文件       4580  2008-11-01 18:26  中文分词\中文分词作业源代码和文档\output\input.txt

     文件       5936  2008-11-01 21:12  中文分词\中文分词作业源代码和文档\output\output.txt

     文件    4599128  2005-01-13 22:30  中文分词\中文分词作业源代码和文档\output\ziguang.txt

     文件      25600  2008-11-01 21:47  中文分词\中文分词作业源代码和文档\程序说明文档.doc

     目录          0  2008-11-01 21:12  中文分词\中文分词作业源代码和文档\output

     目录          0  2008-10-23 22:22  中文分词\分词作业

     目录          0  2008-11-01 21:12  中文分词\中文分词作业源代码和文档

     目录          0  2008-11-15 10:40  中文分词

----------- ---------  ---------- -----  ----

             10332470                    17


评论

共有 条评论