// compare.c #include <stdio.h> #include <string.h> #include <glib.h> #include…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
// compare.c
#include <stdio.h> #include <string.h> #include <glib.h> #include "compare.h"
// Удалённое повторное определение структуры
// Массив звуковых соответствий из вашего первого сообщения const SoundCorrespondence correspondences[] = { {"p", "b"}, {"p", "f"}, {"b", "f"}, {"t", "d"}, {"t", "θ"}, {"t", "ð"}, {"k", "g"}, {"k", "h"}, {"k", "x"}, {"s", "z"}, {"s", "ʃ"}, {"s", "ʒ"}, {"m", "n"}, {"m", "ŋ"}, {"n", "ŋ"}, {"r", "l"}, {"w", "v"}, {"w", "β"}, {"j", "ʝ"}, {"j", "dʒ"}, {"e", "i"}, {"e", "ɛ"}, {"o", "u"}, {"o", "ɔ"}, {"æ", "a"}, {"æ", "ɑ"}, {"θ", "f"}, {"θ", "h"}, {"d", "ð"}, {"d", "z"}, {"k", "tʃ"}, {"k", "ʃ"}, {"g", "ʒ"}, {"g", "dʒ"}, {"p", "pf"}, {"p", "f"}, {"t", "ts"}, {"t", "s"}, {"b", "v"}, {"b", "w"}, {"h", "ʔ"}, {"l", "ɾ"}, {"l", "r"} };
// Количество звуковых соответствий const int num_correspondences = sizeof(correspondences) / sizeof(SoundCorrespondence);
// Функция для разбивки слова на звуки (предполагается посимвольная разбивка) GArray* split_word_into_sounds(const gchar *word) { GArray *sounds = g_array_new(FALSE, FALSE, sizeof(gchar *)); const gchar *p = word;
codewhile (*p) { gunichar c = g_utf8_get_char(p); int char_len = g_unichar_to_utf8(c, NULL); gchar *sound = g_utf8_substring(p, 0, 1); g_array_append_val(sounds, sound); p = g_utf8_next_char(p); } return sounds;}
// Функция для освобождения памяти массива звуков void free_sounds_array(GArray *sounds) { for (guint i = 0; i < sounds->len; i++) { gchar *sound = g_array_index(sounds, gchar *, i); g_free(sound); } g_array_free(sounds, TRUE); }
// Функция для поиска звуковых соответствий между двумя словами GArray* find_sound_correspondences(const gchar *word1, const gchar *word2) { GArray *result = g_array_new(FALSE, FALSE, sizeof(SoundCorrespondence));
code - Assistant