Berikut ini adalah program C yang berguna untuk melakukan seleksi secara otomatis terhadap abstrak paper yang ada di suatu folder "Files". Hasil seleksi akan otomatis masuk ke dalam txt baru yang bernama "Result.txt". Dan juga program ini akan menghitung jumlah kata dan ada tidaknya keyword di dalam abstrak tersebut dan semua itu tergantung oleh tema dari abstrak itu sendiri. Berikut adalah listing programnya :
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <conio.h>
int main(void) {
int args = 0;
char lokasi[64] = "Files\\";
DIR *directory;
struct dirent *ep;
directory = opendir(lokasi);
FILE *fp,*dt;
char str1[80];
char Skey1[10]="visual";
char Skey2[10]="tradition";
char Skey3[10]="animals";
char Skey4[10]="relations";
int Itheme;
int Istats=0;
int Iword=1;
int Imin;
if (directory != NULL)
{
while (args != 2)
{
ep = readdir(directory);
args++;
}
args = 1;
while (ep = readdir(directory))
{
system("cls");
char lokasi[64] = "Files\\";
int Istats=0;
int Iword=1;
fp = fopen(strcat(lokasi, ep->d_name),"r");
printf("***Abstract checker program***");
printf("\n**Junior Lie-SMTI06-53411891**");
printf("\nThe file name is [%s] ",ep->d_name);
printf("\nEnter the theme : ");
printf("\n1. Arts ");
printf("\n2. Humanities ");
printf("\n3. Science");
printf("\n4. SocialScience\n");
scanf("%d",&Itheme);
if(Itheme==1){Imin=150;}
else if(Itheme==2){Imin=250;}
else if(Itheme==3){Imin=220;}
else if(Itheme==4){Imin=200;}
dt = fopen("Reply.txt", "a");
rewind(fp);
while (!feof(fp))
{
fscanf(fp, "%s",str1);
Iword++;
if(Itheme==1){if((strstr(str1,Skey1))!=NULL){Istats=1;}}
else if(Itheme==2){if((strstr(str1,Skey2))!=NULL){Istats=1;}}
else if(Itheme==3){if((strstr(str1,Skey3))!=NULL){Istats=1;}}
else if(Itheme==4){if((strstr(str1,Skey4))!=NULL){Istats=1;}}
}
printf("\nWords : %d",Iword);
printf("\nMinimum words : %d",Imin);
if(Itheme==1){printf("\nThe keyword for this theme is \"%s\"",Skey1);}
else if(Itheme==2){printf("\nThe keyword for this theme is \"%s\"",Skey2);}
else if(Itheme==3){printf("\nThe keyword for this theme is \"%s\"",Skey3);}
else if(Itheme==4){printf("\nThe keyword for this theme is \"%s\"",Skey4);}
printf("\nThe file was successfully checked. Check Reply.txt for the result\n");
fclose(fp);
if (Iword < Imin){
fprintf(dt,"\n%s - Sorry we have rejected your abstract, as the number of words that are not eligible \n",ep->d_name);
}
else if(Istats==0){
fprintf(dt,"\n%s - Sorry we have rejected your abstract, because it does not contain the keyword \n",ep->d_name);
}
else{
fprintf(dt,"\n%s - Congratulations! We have approved your abstract !",ep->d_name);
}
fclose(dt);
args++;
getch();}
closedir(directory);
}
else
{
printf("Directory not found!");
}
}
No comments:
Post a Comment