/* Functions ------------------------- Rules Z_replace() s/Z//g M_rep_z() s/([EeoOiI])M/\1z/g y_insert() s/([aeiouAEIOU])([eiI])$/\1y\2/g M_pattern_replace() s/M([kKgG])/f\1/g s/M([cCjJ])/F\1/g s/M([tTdD])/N\1/g s/M([wWxX])/n\1/g s/M([pPbB])/m\1/g M_pattern_insert() calls replace() s/f([kKgG])/M\1/g s/F([cCjJ])/M\1/g s/N([tTdD])/M\1/g s/n([wWxX])/M\1/g s/m([pPbB])/M\1/g M_replace() s/M/z/g H_append() s/$/H/g a_replace() s/([kctwpKCTWPgjdxbGJDXBfFNnmyrlvsSRh])a$/\1/g M_rep_z_end() s/iyAM$/iyAz/ Q_replace() s/Q/q/g */ /** * FILE NAME : get_spell_variation.c */ /** Function: get_spellvariation * This function is used for identifying the second letter of Hindi alphabets. * Removes or replaces with the small letter in the input word. * Arguments:orig of char array,words of 2 dimensional array , * word_count of int type and return type is char type * Return : char , return morph word after spel variation is done */ #include #include #include #include "morph_logger.h" extern char *program_name; extern FILE *log_file; extern char *log_messg; #define FUNCTION "get_spell_variation()" #define RULE 10 #define LEN 100 #define BIGGER_LEN 300 int Z_replace(char orig[LEN],char words[RULE][LEN],int word_count) /*removes Z in the input word*/ { int loop1,loop2; char *str_Z; str_Z=(char *)malloc((strlen(orig)+1)*sizeof(char)); sprintf(log_messg, "INFO: going check word contains Z=|%s|", str_Z); PRINT_LOG(log_file,log_messg); for(loop1=0,loop2=0;loop1=2 && str_a[strlen(orig)-1]=='a') { ch=str_a[strlen(orig)-2]; check=index("kctwpKCTWPgjdxbGJDXBfFNnmyrlvsSRh",ch); if(check!=NULL) { str_a[strlen(orig)-1]='\0'; strcpy(words[word_count++],str_a); } } free(str_a); return word_count; } int y_insert(char orig[LEN],char words[RULE][LEN],int word_count) { char *str_y,*check,ch; str_y=(char *)malloc((strlen(orig)+2)*sizeof(char)); strcpy(str_y,orig); if(strlen(orig)>=2) { ch=str_y[strlen(orig)-2]; check=index("aeiouAEIOU",ch); if(check!=NULL) { ch=str_y[strlen(orig)-1]; check=index("eiI",ch); if(check!=NULL) { str_y[strlen(orig)-1]='y'; str_y[strlen(orig)]=ch; str_y[strlen(orig)+1]='\0'; strcpy(words[word_count++],str_y); } } } free(str_y); return word_count; /*returns the word size after replacing*/ } int M_rep_z(char orig[LEN],char words[RULE][LEN],int word_count) { int loop1; char *str_M_rep_z,*check,ch; str_M_rep_z=(char *)malloc((strlen(orig)+1)*sizeof(char)); strcpy(str_M_rep_z,orig); for(loop1=0;loop1=4) { check=&str_M_rep_z[strlen(orig)-4]; if(strstr(check,"iyAM")!=NULL) str_M_rep_z[strlen(orig)-1]='z'; } if(strcmp(orig,str_M_rep_z)!=0) strcpy(words[word_count++],str_M_rep_z); free(str_M_rep_z); return word_count; /*returns the word size after replacing*/ } int M_pattern_replace(char orig[LEN],char words[RULE][LEN],int word_count) { int loop1; char *str_rep_M,*check,ch; str_rep_M=(char *)malloc((strlen(orig)+1)*sizeof(char)); strcpy(str_rep_M,orig); for(loop1=0;loop1