Skip to content

Commit

Permalink
Numeric Number added
Browse files Browse the repository at this point in the history
  • Loading branch information
Deoy12 authored Oct 27, 2019
1 parent f8ac5eb commit b4ceed5
Showing 1 changed file with 198 additions and 3 deletions.
201 changes: 198 additions & 3 deletions Textalk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,109 @@

def sum_of(s):
def parsestr(s):
for key in d.keys():
if key in s:
if type(d[key]) == str:
s = s.replace(key, d[key])
else:
s = s.replace(key, d[key](s))
return s

d ={'equals' : '=','equal': '=', 'plus':'+', 'minus':'-', 'over' : '/', 'divided by':'/', 'greater than' : '>','less than':'<', 'percentage':'%', 'percent':'%', \
'multiplied' :'*', 'multiply':'*', 'multiplied by' :'*', 'multiply by':'*', 'sum of' : sum_of, \
'eleven': '11',
'twelve': '12',
'thirteen': '13',
'fourteen': '14',
'fifteen': '15',
'sixteen': '16',
'seventeen': '17',
'eighteen': '18',
'nineteen': '19',
'twenty': '20',
'twenty one': '21',
'twenty two': '22',
'twenty three': '23',
'twenty four': '24',
'twenty five': '25',
'twenty six': '26',
'twenty seven': '27',
'twenty eight': '28',
'twenty nine': '29',
'thirty': '30',
'thirty one': '31',
'thirty two': '32',
'thirty three': '33',
'thirty four': '34',
'thirty five': '35',
'thirty six': '36',
'thirty seven': '37',
'thirty eight': '38',
'thirty nine': '39',
'forty': '40',
'forty one': '41',
'forty two': '42',
'forty three': '43',
'forty four': '44',
'forty five': '45',
'forty six': '46',
'forty seven': '47',
'forty eight': '48',
'forty nine': '49',
'fifty': '50',
'fifty one': '51',
'fifty two': '52',
'fifty three': '53',
'fifty four': '54',
'fifty five': '55',
'fifty six': '56',
'fifty seven': '57',
'fifty eight': '58',
'fifty nine': '59',
'sixty': '60',
'sixty one': '61',
'sixty two': '62',
'sixty three': '63',
'sixty four': '64',
'sixty five': '65',
'sixty six': '66',
'sixty seven': '67',
'sixty eight': '68',
'sixty nine': '69',
'seventy': '70',
'seventy one': '71',
'seventy two': '72',
'seventy three': '73',
'seventy four': '74',
'seventy five': '75',
'seventy six': '76',
'seventy seven': '77',
'seventy eight': '78',
'seventy nine': '79',
'eighty': '80',
'eighty one': '81',
'eighty two': '82',
'eighty three': '83',
'eighty four': '84',
'eighty five': '85',
'eighty six': '86',
'eighty seven': '87',
'eighty eight': '88',
'eighty nine': '89',
'ninety': '90',
'ninety one': '91',
'ninety two': '92',
'ninety three': '93',
'ninety four': '94',
'ninety five': '95',
'ninety six': '96',
'ninety seven': '97',
'ninety eight': '98',
'ninety nine': '99',
'one hundred': '100','one': '1','two': '2','three': '3','four': '4','five': '5','six': '6','seven': '7','eight': '8','nine': '9','ten': '10'}

s = 'seventy one plus three'
new_s = parsestr(s)
print(new_s)

def parsestr(s):
for key in d.keys():
Expand All @@ -9,9 +113,100 @@ def parsestr(s):
else:
s = s.replace(key, d[key](s))
return s

d ={'equals' : '=','equal': '=', 'plus':'+', 'minus':'-', 'over' : '/', 'divided by':'/', 'greater than' : '>','less than':'<', 'percentage':'%', 'percent':'%', \
'multiplied' :'*', 'multiply':'*', 'multiplied by' :'*', 'multiply by':'*', 'sum of' : sum_of}
'multiplied' :'*', 'multiply':'*', 'multiplied by' :'*', 'multiply by':'*', 'sum of' : sum_of, \
'eleven': '11',
'twelve': '12',
'thirteen': '13',
'fourteen': '14',
'fifteen': '15',
'sixteen': '16',
'seventeen': '17',
'eighteen': '18',
'nineteen': '19',
'twenty': '20',
'twenty one': '21',
'twenty two': '22',
'twenty three': '23',
'twenty four': '24',
'twenty five': '25',
'twenty six': '26',
'twenty seven': '27',
'twenty eight': '28',
'twenty nine': '29',
'thirty': '30',
'thirty one': '31',
'thirty two': '32',
'thirty three': '33',
'thirty four': '34',
'thirty five': '35',
'thirty six': '36',
'thirty seven': '37',
'thirty eight': '38',
'thirty nine': '39',
'forty': '40',
'forty one': '41',
'forty two': '42',
'forty three': '43',
'forty four': '44',
'forty five': '45',
'forty six': '46',
'forty seven': '47',
'forty eight': '48',
'forty nine': '49',
'fifty': '50',
'fifty one': '51',
'fifty two': '52',
'fifty three': '53',
'fifty four': '54',
'fifty five': '55',
'fifty six': '56',
'fifty seven': '57',
'fifty eight': '58',
'fifty nine': '59',
'sixty': '60',
'sixty one': '61',
'sixty two': '62',
'sixty three': '63',
'sixty four': '64',
'sixty five': '65',
'sixty six': '66',
'sixty seven': '67',
'sixty eight': '68',
'sixty nine': '69',
'seventy': '70',
'seventy one': '71',
'seventy two': '72',
'seventy three': '73',
'seventy four': '74',
'seventy five': '75',
'seventy six': '76',
'seventy seven': '77',
'seventy eight': '78',
'seventy nine': '79',
'eighty': '80',
'eighty one': '81',
'eighty two': '82',
'eighty three': '83',
'eighty four': '84',
'eighty five': '85',
'eighty six': '86',
'eighty seven': '87',
'eighty eight': '88',
'eighty nine': '89',
'ninety': '90',
'ninety one': '91',
'ninety two': '92',
'ninety three': '93',
'ninety four': '94',
'ninety five': '95',
'ninety six': '96',
'ninety seven': '97',
'ninety eight': '98',
'ninety nine': '99',
'one hundred': '100','one': '1','two': '2','three': '3','four': '4','five': '5','six': '6','seven': '7','eight': '8','nine': '9','ten': '10'}

s = 'sum of two and three.'
s = 'seventy one plus three'
new_s = parsestr(s)
print(new_s)

0 comments on commit b4ceed5

Please sign in to comment.