diff options
Diffstat (limited to 'addressbook/backend/ebook/e-card.c')
-rw-r--r-- | addressbook/backend/ebook/e-card.c | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c index 835cc8195a..1b3ef694b6 100644 --- a/addressbook/backend/ebook/e-card.c +++ b/addressbook/backend/ebook/e-card.c @@ -1621,150 +1621,6 @@ e_card_name_from_string(const char *full_name) return name; } - -/* This *so* doesn't belong here... at least not implemented in a - sucky way like this. But by getting it in here now, I can fix it - up w/o adding a new feature when we are in feature freeze. :-) */ - -/* This is very Anglocentric. Maybe it should be by locale? */ -static gchar *name_synonyms[][2] = { - { "Jon", "John" }, /* Ah, the hacker's perogative */ - { "Jon", "Jonathan" }, - { "Daniel", "Dan" }, - { "Joseph", "Joe" }, - { "Robert", "Rob" }, - { "Robert", "Bob" }, - { "Richard", "Rich" }, - { "Richard", "Dick" }, - { "William", "Will" }, - { "William", "Bill" }, - { "Anthony", "Tony" }, - { "Steven", "Steve" }, - { "Michael", "Mike" }, - { "Douglas", "Doug" }, - { "Sidney", "Sid" }, - { "Eric", "Erik" }, - { "Chris", "Christopher" }, - { "Chris", "Christine" }, - { "Chris", "Christy" }, - { "Elizabeth", "Liz" }, - { "Jeff", "Geoff" }, - { "Jeff", "Jeffrey" }, - { "Jeff", "Geoffrey" }, - { "Jim", "James" }, - { "Abigal", "Abby" }, - { "Amanda", "Amy" }, - { "Amanda", "Manda" }, - { "Di", "Diana" }, - { "Di", "Diane" }, - { "Maxine", "Max" }, - { "Rebecca", "Becca" }, - { "Rebecca", "Becky" }, - { "Jennifer", "Jen" }, - { "Jennifer", "Jenny" }, - /* We could go on and on... */ - { NULL, NULL } -}; - -static gboolean -name_fragment_match (const gchar *a, const gchar *b) -{ - gint i; - gboolean nickname_match = FALSE; - - if (!g_strcasecmp (a, b)) - return TRUE; - - /* Check for nicknames. Yes, the linear search blows. */ - for (i=0; name_synonyms[i][0]; ++i) { - if (!g_strcasecmp (name_synonyms[i][1], a)) { - a = name_synonyms[i][0]; - nickname_match = TRUE; - break; - } - } - - for (i=0; name_synonyms[i][0]; ++i) { - if (!g_strcasecmp (name_synonyms[i][1], b)) { - b = name_synonyms[i][0]; - nickname_match = TRUE; - break; - } - } - - return nickname_match && !g_strcasecmp (a, b); -} - -gboolean -e_card_name_match_string (const ECardName *name, const gchar *str) -{ - gchar *name_str; - gchar **strv, **namev; - gint i, j, match_count; - - g_return_val_if_fail (name != NULL, FALSE); - g_return_val_if_fail (str != NULL, FALSE); - - strv = g_strsplit (str, " ", 0); - for (i=0; strv[i]; ++i) - g_strstrip (strv[i]); - - name_str = e_card_name_to_string (name); - namev = g_strsplit (name_str, " ", 0); - for (i=0; namev[i]; ++i) - g_strstrip (namev[i]); - - match_count = 0; - i = j = 0; - - while (strv[i] && namev[j]) { - gint k; - gboolean first_match = FALSE, second_match = FALSE; - - for (k=0; strv[i + k]; ++k) { - if (name_fragment_match (strv[i + k], namev[j])) { - first_match = TRUE; - break; - } - } - - if (!first_match) { - for (k=0; namev[j + k]; ++k) { - if (name_fragment_match (strv[i], namev[j + k])) { - second_match = TRUE; - break; - } - } - } - - if (! (first_match || second_match)) - break; - - ++match_count; - - if (first_match) { - i += k + 1; - ++j; - } else { - ++i; - j += k + 1; - } - } - - /* This rule could be made more precise. - As it is, it will say that "Joe Smith" will match the name - "Joe Allen Smith" (which is good), but "de Icaza" will match - either "Miguel de Icaza" as well as Miguel's shiftless - brother "Roger de Icaza". In this sort of a case, the match - threshold should go up to 3. */ - - g_strfreev (strv); - g_strfreev (namev); - g_free (name_str); - - return match_count >= 2; -} - ECardArbitrary * e_card_arbitrary_new(void) { |