Is there any way to do this to determine this:
Сколько будет три плюс 2? Is it possible to make 3 of three?
PS Instead of "three" there can be "3", "ten", "10", in short, any number.
Is there any way to do this to determine this:
Сколько будет три плюс 2? Is it possible to make 3 of three?
PS Instead of "three" there can be "3", "ten", "10", in short, any number.
I will offer a code that I use myself, but it does not work with endings like a тысяча and семь тысяч variability of the Russian language, however. Was taken from English SO
def text2int(textnum, numwords={}): if not numwords: units = [ "ноль", "один", "два", "три", "четыре", "пять", "шесть", "семь", "восемь", "девять", "десять", "одиннадцать", "двенадцать", "тринадцать", "четырнадцать", "пятнадцать", "шестнадцать", "семнадцать", "восемнадцать", "девятнадцать", ] tens = ["", "", "двадцать", "тридцать", "сорок", "пятьдесят", "шестьдесят", "семьдесят", "восемьдесят", "девяносто"] scales = ["сто", "тысяч", "миллион", "миллиард", "триллион"] numwords["и"] = (1, 0) for idx, word in enumerate(units): numwords[word] = (1, idx) for idx, word in enumerate(tens): numwords[word] = (1, idx * 10) for idx, word in enumerate(scales): numwords[word] = (10 ** (idx * 3 or 2), 0) current = result = 0 for word in textnum.split(): if word not in numwords: raise Exception("Неверное слово: " + word) scale, increment = numwords[word] current = current * scale + increment if scale > 100: result += current current = 0 return result + current print text2int("семьдесят тысяч пятьдесят три") >>>70053 Source: https://ru.stackoverflow.com/questions/806931/
All Articles
сто двадцать пять минус восемьдесят два- what answer should be?125 - 82;100, 25 - 80, 2;100, 20, 5, -82... - slippyk