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

📄 2 提取-08-标题.cpp

📁 1998年1月份人民日报语料中体育类文章的识别
💻 CPP
字号:
//对文件做预处理
//1.从mr.txt读入
//2.mr1.txt作为读出
//预处理解决问题:19980101-01-001-001/m 子串会被删除
#include <stdio.h>
void main()
{//	char *i;
	FILE *fp;FILE *fpw;
	fp=fopen("199801.txt","r");//读入文件
	fpw=fopen("dic_try1.txt","w");//写入文件
	int flag=0;//字符状态标志 1:处理1998类问题,0:不是
	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 print_wz=0;
//	int print_pz=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 && flag==1){flag=0;}//如果是1998后面的空格;
//处理空格	
		if(c1==32){		
					if(print==1)fputc(c1,fpw);
					continue;
		}
//ascii码(1 篇章信息 2 标注信息)
		if(c1<161){
					
				//修改 打印标题 标志位
					
 				//	if (pb_p==15){temp=c1;print=1;}
					if (c1>=48 && c1<=57 || c1==45)  //是篇章信息printf("get 1");if(pb_p==0)
					{//	fputc(c1,fpw);
						pb_p=(pb_p++)%19;
						if(c1!=temp[15] && pb_p==15 ){print=1;}//printf("%d,%c\n",pb_p,c1);
													
						temp[pb_p]=c1;  //printf("%d,%c\n",pb_p,temp[pb_p]); 
						//	if(pb_p==0 && print==1)fputc(temp[i],fpw);
						if(temp[11]=='8' && temp[10]=='0'){}
						else{print=0;}
							if(pb_p==19 && print==1){
								for( i=1;i<20;i++)
									fputc(temp[i],fpw);
									//printf("%d,%c\n",i,temp[i]);
							
						}	/**/
					}
					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 + -