コード例 #1
0
ファイル: mklab.cpp プロジェクト: ikiissel/synthts_vr
CFSArray<CFSWString> do_utterances(CFSWString s) {
    CFSWString res = empty_str;
    CFSArray<CFSWString> res_array;

    if (s.GetLength() == 1)
        res_array.AddItem(s);
    else
        for (INTPTR i = 0; i < s.GetLength(); i++) {
            CFSWString c = s.GetAt(i);
            CFSWString pc = res.GetAt(res.GetLength() - 1);
            CFSWString nc = s.GetAt(i + 1);
            CFSWString nnc = s.GetAt(i + 2);

            if (is_ending(c) && is_whitespace(nc) && is_upper(nnc)) {
                res.Trim();
                res_array.AddItem(res);
                res = empty_str;
            } else
                if (is_tab(c)) {
                if (res.GetLength() > 0) {
                    res.Trim();
                    res_array.AddItem(res);
                    res = empty_str;
                }
            } else
                res += c;
        }
    res.Trim();
    
    if (res.GetLength() > 0) {
        while (is_ending(res.GetAt(res.GetLength() - 1))) {
            res.Delete(res.GetLength() - 1, 1);
        }
        
        res_array.AddItem(res);
    }

    for (INTPTR i=0; i < res_array.GetSize(); i++) {
        if (is_ending(res_array[i].GetAt(res_array[i].GetLength()-1))) 
            res_array[i].Delete(  res_array[i].GetLength()-1, 1   );

    }
    
    return res_array;
}
コード例 #2
0
ファイル: syls.cpp プロジェクト: glensc/synthts_et
CFSWString the_shift(CFSWString s) {
    /*
            On mingi võimalus, et lihtsustus tuleb teha kahes astmes. LQ-ta ja LQ-ga (vt shift_pattern). Kõik 
            seotud sellega, et pole	vältenihutusreeglitest lõpuni aru saanud. Eksisteerib Mihkla versioon ja 
            ametlik versioon. Tänud	Mihklale, kes kala asemel annab tattninale õnge, see õpetab ujuma.
            Maadlesin õngega pikalt.
     */

    CFSWString res;
    CFSWString code;
    INTPTR pos;
    INTPTR i = 0;
    INTPTR x;

    while (s.GetLength() > 0) {
        CFSWString c = s.GetAt(0);
        s.Delete(0, 1);
        if (is_uvowel(c)) {
            c = c.ToLower();
            code += shift_pattern(c);
            res += c;
            pos = i;
        } else
            if (c == d && code.GetLength() > 0) {
            res += c;
            code += c;
            CFSWString t_code = code;
            t_code += shift_pattern(s.GetAt(0));

            x = pattern_lookup(t_code); //orig üle silbipiiri
            if (x > -1) {
                x += pos;
                if (x > res.GetLength()) { // kui kargab järgmisse silpi
                    x = x - res.GetLength();
                    s.Insert(x, colon);
                } else
                    res.Insert(x, colon);
                i++;
            } else {
                t_code = simplify_pattern(t_code);
                x = pattern_lookup(t_code); //liht üle silbipiiri
                if (x > -1) {
                    x += pos;
                    if (x > res.GetLength()) { // kui kargab järgmisse silpi
                        x = x - res.GetLength();
                        s.Insert(x, colon);
                    } else
                        res.Insert(x, colon);
                    i++;
                } else {
                    x = pattern_lookup(code); //orig 
                    if (x > -1) {
                        x += pos;
                        res.Insert(x, colon);
                        i++;
                    } else {
                        code = simplify_pattern(code);
                        x = pattern_lookup(code); //liht
                        if (x > -1) {
                            x += pos;
                            res.Insert(x, colon);
                            i++;
                        }
                    }
                }
            }

            code = empty_str;
        } else {
            res += c;
            if (code.GetLength() > 0) {
                code += shift_pattern(c);
            }
        }
        i++;
    } //while

    // sõna lõpus
    if (code.GetLength() > 0) {
        code += L"#";
        //imelik koht ainult "lonksu" pärast
        if ((code.Left(3) == L"VLQ") && ((code.GetAt(3) == L's') || (code.GetAt(3) == L'h') || (code.GetAt(3) == L'v') || (code.GetAt(3) == L'j'))) {
            code = L"VLQC#";
        }
        INTPTR x = pattern_lookup(code);
        if (x > -1) {
            x += pos;
            res.Insert(x, colon);
        } else {
            code = simplify_pattern(code);
            x = pattern_lookup(code);
            if (x > -1) {
                x += pos;
                res.Insert(x, colon);
            }
        }
        code = empty_str;
    }
    return res;
}