|
I'm trying to add a similarity calculating function -- currently there is a really insane version of it in "utils.c" in the "gtranslator_utils_calculate_similarity" function. What do you all say to this? Especially I fear this causes many problems with multibyte learn buffering.. Hmm. This kind of function is needed to get the new pref to specify a minimum matching percentage for the auto translation working in a sane way. Here is the important code snippet: if(!a || !b || !nautilus_strcmp(a, "") || !nautilus_strcmp(b, ""))
{
return 0.0;
}
/*
* Calculate the similarity value a single char is representing.
*/
/ (strlen(a) - 1));
/*
* Now we do check the characters of the two given strings..
* Voodoo, Magic!
*/
while(a[i] && b[i] && a[i]!='\0' && b[i]!='\0')
{
if(a[i]==b[i])
{
similarity+=one_char_percentage;
}
else if(tolower(a[i])==tolower(b[i]))
{
similarity+=(one_char_percentage / 2);
}
i++;
}
|