void convert_three_digit_group(int type, const std::string& n, std::string& tequiv, std::string& tinflection) { int i = n.length()-1; tequiv = tinflection = ""; if (i == -1) return; if (i > 2 || !isdigit(n[i])) { tequiv = "#"; return;} tequiv = units[type][dix(n[i])]; tinflection = make_tinfl(type, n[i], UNITS); if (i > 0) { if (n[i-1] == '1') { tequiv = teens[type][dix(n[i])]; tinflection = make_tinfl(type, n[i], TEENS); } else if (n[i] == '0') { tequiv = ""; tinflection = ""; } --i; if (n[i] != '0' && n[i] != '1') { prepend(tequiv, tens[type][dix(n[i])], type); prepend(tinflection, make_tinfl(type, n[i], TENS), type); } if (i > 0) { --i; if (n[i] == '0') { if (type == BEFORE_NOUN) tinflection = "0"; return; } static const int lonehundred[N_FORMS] = { CARDINAL, CARDINAL, CARDINAL_G, CARDINAL, CARDINAL, CARDINAL, BEFORE_NOUN }; int nt = tequiv.length()>0 ? lonehundred[type] : type; prepend(tequiv, hundreds[nt][dix(n[i])], nt); if (nt == CARDINAL && type != CARDINAL) prepend(tinflection, "0", nt); else prepend(tinflection, make_tinfl(nt, n[i], HUNDREDS), nt); } } if (type == BEFORE_NOUN) tinflection = "0"; }
const std::string make_tinfl(int type, char digit, int rank) { static const char* unitsI[2][10] = { {"R:5", "0", "LG:z", "LG:z", "LG:z", "LG:r", "LG:r", "LG:r", "LG:r", "LG:r"}, {"P", "LP-P", "LP-P", "LP-P", "LP-P", "LP-P", "LP-P", "LP-P", "LP-P", "LP-P"}, }; static const char* icode[ORDINAL+1] = {"LG:r", "LP-P"}; static const char* (*names[4])[10] = {units, teens, tens, hundreds}; int d = dix(digit); switch (type) { case CARDINAL: case ORDINAL: if (rank == UNITS) return unitsI[type][d]; else return icode[type]; case CARDINAL_G: return "0"; case ORDINAL_F: case ORDINAL_NPL: case ORDINAL_GPL: return std::string(names[rank][ORDINAL][d]) + "_LP-P"; case BEFORE_NOUN: return ""; default: return "#"; }; }
void cent(char *str, int j) { if(str[j] == '1') my_putstr("cent"); if(str[j] == '2') my_putstr("deux cent"); if(str[j] == '3') my_putstr("trois cent"); if(str[j] == '4') my_putstr("quatre cent"); if(str[j] == '5') my_putstr("cinq cent"); if(str[j] == '6') my_putstr("six cent"); if(str[j] == '7') my_putstr("sept cent"); if(str[j] == '8') my_putstr("huit cent"); if(str[j] == '9') my_putstr("neuf cent"); dix(str[j]); }