?? 1 標題提取.cpp
字號:
//功能:提取 語料庫的標題
//輸入:199801.txt語料庫
//輸出dic_try1.txt 標題集
//思路:
//根據篇章信息(19980104-04-001-001)確定當前讀入行是否是標題(-001是標題)
// 如果是標題,顯示(修改顯示標志位 print=1)
// 不是(print=0)
#include <stdio.h>
void main()
{
FILE *fp;FILE *fpw;
fp=fopen("199801.txt","r");//讀入文件
fpw=fopen("dic_try1.txt","w");//寫入文件
if (fp==NULL)
{ printf("cannot open thi file\n");}
if (fpw==NULL)
{ printf("cannot open thi file\n");}
int status=0;//0 處理排版信息 1 處理詞
int pb_p=0;
int print=0;
int i=1;
unsigned int temp[20];//篇章信息 19位
while(!feof(fp))
{
unsigned int c1 =fgetc(fp);//printf("%x\n",c1);
if(c1==-1){continue;}//處理文件結尾符作為字符顯示的問題
//處理回車,同時說明了 篇章信息和文章內容的結束
if(c1==10){
if(print==1)
{fputc(c1,fpw);print=0;}
pb_p=0;
continue;
}
//處理空格
if(c1==32){
if(print==1)fputc(c1,fpw);
continue;
}
//ascii碼(1 篇章信息 2 標注信息)
if(c1<161){
//修改 打印標題 標志位
if (c1>=48 && c1<=57 || c1==45) //是篇章信息
{
pb_p=(pb_p++)%19;
if(c1!=temp[15] && pb_p==15 ){print=1;}
temp[pb_p]=c1;
if(pb_p==19 && print==1)
{
for( i=1;i<20;i++)
fputc(temp[i],fpw);
}
}
else{//標注信息
}
}
//是一個GBK (文章內容)
else{
if(print==1)fputc(c1,fpw);
unsigned int c2 =fgetc(fp);
if(print==1)fputc(c2,fpw);
}
}
fclose(fpw);
fclose(fp);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -