00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "ffstring.h"
00031 #include "ffregex.h"
00032 #include "ffpriv_consonant_gradation.h"
00033
00034
00035 ffint32 ffpriv_consonant_gradation(ffstring* word, ffuint32 direction, ffuint32 type)
00036 {
00037 ffint32 err;
00038 ffstring t;
00039
00040 if ( direction == 1 && type == 1 ) {
00041 if ( ffregex_match_ci("^.*(kk|pp|tt)[aeiouyåäöÅÄÖ]$", word) ) {
00042 err = ffstring_tail(word, 2, &t);
00043 if ( err ) { return err; }
00044 err = ffstring_rfe_ff(word, 3, &t);
00045 ffstring_delete(&t);
00046 return err;
00047 }
00048
00049 if ( ffregex_match_ci("^.*[nlr]t[aeiouyåäöÅÄÖ]$", word) ) {
00050 return -!ffregex_replace_ci("(.)t(.)$", "${1}${1}${2}", word);
00051 }
00052
00053 if ( ffregex_match_ci("^.*[aeiouyåäöÅÄÖ]t[aeiouyåäöÅÄÖ]$", word) ) {
00054 return -!ffregex_replace_ci("t(.)$", "d${1}", word);
00055 }
00056
00057 if ( ffregex_match_ci("^.*mp[aeiouyåäöÅÄÖ]$", word) ) {
00058 return -!ffregex_replace_ci("p(.)$", "m${1}", word);
00059 }
00060
00061 if ( ffregex_match_ci("^.*[lr]p[aeiouyåäöÅÄÖ]$", word) ) {
00062 return -!ffregex_replace_ci("p(.)$", "v${1}", word);
00063 }
00064
00065 if ( ffregex_match_ci("^.*[aeiouyåäöÅÄÖ]p[aeiouyåäöÅÄÖ]$", word) ) {
00066 return -!ffregex_replace_ci("p(.)$", "v${1}", word);
00067 }
00068
00069 if ( ffregex_match_ci("^.*[lr]k[aeiouyåäöÅÄÖ]$", word) ) {
00070 return -!ffregex_replace_ci("k(.)$", "${1}", word);
00071 }
00072
00073 if ( ffregex_match_ci("^.*nk[aeiouyåäöÅÄÖ]$", word) ) {
00074 return -!ffregex_replace_ci("k(.)$", "g${1}", word);
00075 }
00076
00077 if ( ffregex_match_ci("^.*ht[aeiouyåäöÅÄÖ]$", word) ) {
00078 return -!ffregex_replace_ci("t(.)$", "d${1}", word);
00079 }
00080
00081 if ( ffregex_match_ci("^.[uy]k[uy]$", word) ) {
00082 return -!ffregex_replace_ci("k(.)$", "v${1}", word);
00083 }
00084
00085 if ( ffregex_match_ci("^([aeiouyåäöÅÄÖ]|[^aeiouyåäöÅÄÖ][aeiouyåäöÅÄÖ]+)k[aeiouyåäöÅÄÖ]$", word) ) {
00086 return -!ffregex_replace_ci("k(.)$", "${1}", word);
00087 }
00088
00089 }
00090
00091
00092
00093 return 0;
00094 }
00095