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

📄 prob.c

📁 中心词驱动的短语结构句法分析器。该模型考虑了跟随介词短语的名词短语的中心词的作用。 有MIT大学Colling开发
💻 C
📖 第 1 页 / 共 2 页
字号:
  5           punc  6           cc  7           p  8           ch  9           dist  10..12      subcat  13          th  14..15      wh*/void calc_newdist(int *newd,int d){  if(d>=100)    {      *newd = 100;      d-=100;    }  else    *newd=0;  if(d>=10)    {      if(DISTAFLAG)	*newd += 10;      d-=10;    }  if(d>=1)    {      if(DISTVFLAG)	*newd += 1;    }}void make_dep1_string(unsigned char *string,int wm,int tm,int cm,int wh,int th,int p,int ch,int dist,int subcat,int cc,int punc){  int newdist;  calc_newdist(&newdist,dist);  string[3] = (char) tm;  string[4] = (char) cm;  string[5] = (char) punc;  string[6] = (char) cc;  string[7] = (char) p;  string[8] = (char) ch;  string[9] = (char) newdist;  byte3_to_char(&string[10],subcat);  string[13] = (char) th;  byte2_to_char(&string[14],wh);}/*make string for P(wm | cm,t, context)   position    element  3..4        wm  5           tm  6           cm  7           punc  8           cc  9           p  10           ch  11          dist  12..14      subcat  15          th  16..17      wh*/void make_dep2_string(unsigned char *string,int wm,int tm,int cm,int wh,int th,int p,int ch,int dist,int subcat,int cc,int punc){  int newdist;  calc_newdist(&newdist,dist);  byte2_to_char(&string[3],wm);  string[5] = (char) tm;  string[6] = (char) cm;  string[7] = (char) punc;  string[8] = (char) cc;  string[9] = (char) p;  string[10] = (char) ch;  string[11] = (char) newdist;  byte3_to_char(&string[12],subcat);  string[15] = (char) th;  byte2_to_char(&string[16],wh);}/*make string for P(wm | cm,t, context)   position    element  3..4        wm  5           tm*/void add_tagword_counts(int wm,int tm,hash_table *hash){  unsigned char buffer[1000];  int bos[] = {1,1};  wm = fwords[wm];  byte2_to_char(&buffer[3],wm);  buffer[5] = (char) tm;  add_counts_level(buffer,D2OLEN,bos,3,D2PROBTYPE,hash);  add_counts_level(buffer,S2OLEN,bos,2,S2PROBTYPE,hash);  add_counts_level(buffer,CP2OLEN,bos,3,CP2PROBTYPE,hash);}void byte2_to_char(unsigned char *string,int n){  string[0] = (n & 255);  string[1] = n/256;}void byte3_to_char(unsigned char *string,int n){  string[0] = (n&255);  string[1] = ((n/256)&255);  string[2] = n/65536;}/*make string for P(ch | p,th,wh)  position    element  3           ch  4           p  5           th  6..7        wh*/void make_unary_string(unsigned char *string,int ch,int wh,int th,int p){  string[3] = (char) ch;  string[4] = (char) p;  string[5] = (char) th;  byte2_to_char(&string[6],wh);}/*make string for P(ch,th | p==TOP)  position    element  3           ch  4           th  5           TOP*/void make_s1_string(unsigned char *string,int ch,int wh,int th,int p){  string[3] = (char) ch;  string[4] = (char) th;  string[5] = (char) p;}/*make string for P(wh | ch,th, p==TOP)  position    element  3..4        wh  5           th  6           ch  7           TOP*/void make_s2_string(unsigned char *string,int ch,int wh,int th,int p){  byte2_to_char(&string[3],wh);  string[5] = (char) th;  string[6] = (char) ch;  string[7] = (char) p;}/*make string for P(subcat | wh,ch,th, p,dir)  position    element  3..5        subcat  6           ch  7           p  8           dir  9           th  10..11      wh*/void make_subcat_string(unsigned char *string,int subcat,int ch,int wh,int th,int p,int dir){  byte3_to_char(&string[3],subcat);  string[6] = (char) ch;  string[7] = (char) p;  string[8] = (char) dir;  string[9] = (char) th;  byte2_to_char(&string[10],wh);}/*make string for P(ch | wh,th)  position    element  3           ch  4           0  5           th  6..7        wh*/void make_prior1_string(unsigned char *string,int ch,int wh,int th){  string[3] = (char) ch;  string[4] = 0;  string[5] = (char) th;  byte2_to_char(&string[6],wh);}/*make string for P(wh, th |  p==anything)  position    element  3..4        wh  5           th  6           0*/void make_prior2_string(unsigned char *string,int ch,int wh,int th){  byte2_to_char(&string[3],wh);  string[5] = (char) th;  string[6] = 0;}/* pcc1_string   position      element   3             t   4             type   5             p   6             ch   7             cm   8             th   9             tm   10            wh   12            wm*/void make_pcc1_string(unsigned char *string,int t,int p,int ch,int th,int wh,int cm,int tm,int wm,int type){/*  printf("PCC1 %d %d %d %d %d %d %d %d %d\n",	 t,p,ch,th,wh,cm,tm,wm,type);*/  string[3] = (char) t;  string[4] = (char) type;  string[5] = (char) p;  string[6] = (char) ch;  string[7] = (char) cm;  string[8] = (char) th;  string[9] = (char) tm;  byte2_to_char(&string[10],wh);  byte2_to_char(&string[12],wm);}/* pcc2_string   position      element   3..4          w   5             t   6             type   7             p   8             ch   9             cm   10            th   11            tm   12            wh   14            wm*/void make_pcc2_string(unsigned char *string,int w,int t,int p,int ch,int th,int wh,int cm,int tm,int wm,int type){/*  printf("PCC1 %d %d %d %d %d %d %d %d %d %d\n",	 w,t,p,ch,th,wh,cm,tm,wm,type);*/  byte2_to_char(&string[3],w);    string[5] = (char) t;  string[6] = (char) type;  string[7] = (char) p;  string[8] = (char) ch;  string[9] = (char) cm;  string[10] = (char) th;  string[11] = (char) tm;  byte2_to_char(&string[12],wh);  byte2_to_char(&string[14],wm);}/*make string for P(gap | wh,ch,th, p)  position    element  3           gap  4           ch  5           p  6           th  7..8      wh*/void make_gap_string(unsigned char *string,int gap,int ch,int wh,int th,int p){  string[3] = (char) gap;  string[4] = (char) ch;  string[5] = (char) p;  string[6] = (char) th;  byte2_to_char(&string[7],wh);}

⌨️ 快捷键说明

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