示例#1
0
CFSWString DealWithText(CFSWString text) {
    /* Proovin kogu sõnniku minema loopida */
    CFSWString res;
    text.Trim();
    text.Replace(L"\n\n", L"\n", 1);
    text.Replace(L"‘", L"'", 1);
    text.Replace(L"`", L"'", 1);
    text.Replace(L"´", L"'", 1);
    text.Replace(L"’", L"'", 1);

    for (INTPTR i = 0; i < text.GetLength(); i++) {
        CFSWString c = text.GetAt(i);
        CFSWString pc = res.GetAt(res.GetLength() - 1);
        CFSWString nc = text.GetAt(i + 1);
        if (c == L"'") {
            if (is_vowel(pc)) 
                res += L"q";
            else
                res += c;
        }
        else
        if (is_char(c)) res += c;
        else
            if (is_digit(c)) res += c;
        else
            if (is_hyphen(c) && is_char(pc) && is_char(nc)) res += sp;
        else
            if (is_symbol(c)) res += c;
        else
            if (is_colon(c) && !is_colon(pc)) res += c;
        else
            if (is_bbracket(c) && !is_bbracket(pc)) res += c;
        else
            if (is_ebracket(c) && is_ending(nc)) res += L"";
        else
            if (is_ebracket(c) && !is_ebracket(pc)) res += c;
        else
            if (is_comma(c) && !is_comma(pc)) res += c;
        else
            if (is_fchar(c)) res += replace_fchar(c);
        else
            if (is_space(c) && !is_whitespace(pc)) res += c;
        else
            if (is_break(c) && !is_break(pc)) { 
                
                res += c;   
            } //kahtlane
        else
            if (is_tab(c) && !is_whitespace(pc)) res += c;
        else            
            if (is_ending(c) && !is_ending(pc) && !is_whitespace(pc)) res += c;

    }
    res.Trim();        
    return res;

}
示例#2
0
void do_syls(word_struct &w) {
    CFSArray<syl_struct> sv, sv_temp;
    syl_struct ss;
    CFSArray<CFSWString> temp_arr, c_words;
    ss.phone_c = 0, ss.word_p = 0, ss.phr_p = 0, ss.utt_p = 0;
    w.syl_c = 0;
    INTPTR word_p = 1;

    explode(w.mi.m_szRoot, L"_", c_words);

    for (INTPTR cw = 0; cw < c_words.GetSize(); cw++) {
        
        CFSWString s = c_words[cw];
        s.Replace(L"y", L"õ", 1);
        s = palat_vru(s);
        
        s = word_to_syls(s);
        explode(s, d, temp_arr);
        ss.stress = 0;
        sv_temp.Cleanup();
        for (INTPTR i = 0; i < temp_arr.GetSize(); i++) {
            ss.syl = temp_arr[i];
            ss.stress = 0; // rõhu algväärtus
            ss.word_p = word_p++;
            sv_temp.AddItem(ss);
        }

        add_stress2(sv_temp, cw);
        for (INTPTR i = 0; i < sv_temp.GetSize(); i++)
            sv.AddItem(sv_temp[i]);
    }

    w.syl_vector = sv;

}