どのようにこの句読点correcter作品:: :句読補正機能?私は、この行があれば
hi.how are u?i'm good;ok bye.
をcorrecterが私にこのラインを与える必要があります:
hi. How are u? I'm good; ok bye.
どのようにこの仕事:{任意の後 最初。または、または。または? }それはスペースを入れ、それの後に文字を大文字にする必要がありますか?
Cで
UPDATE
#include<stdio.h>
#include<string.h>
#define LINE_LEN 300
void strip(char *);
char toCap(char);
char toSml(char);
int main(int argc, char *argv[]){
char line[LINE_LEN];
int counter = 0;
int line_length;
int i;
char outline[LINE_LEN];
if(argv[1] == NULL){ //check if the file exists or not
printf("ERROR: FILE NOT FOUND!\n");
return -1;
}
FILE *inp;
FILE *output;
inp = fopen(argv[1],"r");
output = fopen("Clear_Data.txt","w");
while(fgets(line,LINE_LEN,inp) != NULL){
strip(line);
line_length = strlen(line);
for(i = 0; i < line_length ; i++)
line[i] = toSml(line[i]);
for(i = 0; i < line_length ; i++){
if(line[i] == '.' || line[i] == ',' || line[i] == ';' || line[i] == '?'){
if(line[i+1] == ' ')
outline[i+2] = toCap(line[i+2]);
else{
outline[i+1] = ' ';
outline[i+2] = toCap(line[i+1]);
}
continue;
}
else
outline[i] = line[i];
}
fprintf(output,"%s",outline);
}
fclose(inp);
fclose(output);
return 0;
}
void strip(char *str){ //remove extra whitespaces in a string
int r = 0; //next character to be read
int w = 0; // next character to be written
while(str[r]){
if (str[r] == ' ' || iscntrl(str[r])){
if (w > 0 && str[w-1] != ' ')
str[w++] = ' ';
}
else
str[w++] = str[r];
r++;
}
str[w] = 0;
if(str[strlen(str) - 1] == ' ')
str[strlen(str) - 1] = 0;
printf("%s\n",str);
}
char toCap(char c){
return (c - 32);
}
char toSml(char c){
return (c + 32);
}
が、これは今、どんな助けを動作しないでしょう?
質問が終了したら、再度投稿するだけでなく、改善する必要があります。 – ypnos
私はちょうど私の質問を追加します。 –
より明確な説明をしてください。はい、句読記号の後ろにスペースがあり、それの後に文字を大文字にする必要があります。それはあなたが尋ねたいものですか? –