cdactvm commited on
Commit
20ccde2
·
verified ·
1 Parent(s): 9befa46

Upload 4 files

Browse files
Files changed (4) hide show
  1. Text2List.py +86 -0
  2. convert2list.py +55 -0
  3. replaceWords.py +133 -0
  4. text2int.py +102 -0
Text2List.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[4]:
5
+
6
+
7
+ def text_to_list():
8
+ text_list = [
9
+ # Malayalam script for English numbers (11-19)
10
+ 'എലവൻ', 'ട്വെൽവ്', 'തിര്റെൻ', 'ഫോർടീൻ', 'ഫിഫ്റ്റീൻ', 'സിക്സ്റ്റീൻ', 'സിവൻറീൻ', 'എട്ടീൻ', 'നൈൻറീൻ',
11
+ # Malayalam numbers (11-19)
12
+ 'പതിനൊന്ന്', 'പന്ത്രണ്ട്', 'പതിന്മൂന്ന്', 'പതിന്നാല്', 'പതിനഞ്ച്', 'പതിനാറ്', 'പതിനേഴ്', 'പതിനെട്ട്', 'പത്തൊമ്പത്',
13
+
14
+ # Malayalam script for English multiples of ten (20, 30, ..., 90)
15
+ 'ട്വെന്റി', 'തിര്റ്റി', 'ഫോർറ്റി', 'ഫിഫ്റ്റി', 'സിക്സ്റ്റി', 'സിവൻ്റി', 'എൺപതു', 'നൈന്റ്റി',
16
+ # Malayalam multiples of ten (20, 30, ..., 90)
17
+ 'ഇരുപത്', 'മുപ്പത്', 'നാല്പത്', 'ഐമ്പത്', 'അറുപത്', 'എഴുപത്', 'എൺപത്', 'തൊണ്ണൂறு',
18
+
19
+ # Malayalam script for English combinations of 21-29
20
+ 'ട്വെന്റി ഒൺ', 'ട്വെന്റി ടു', 'ട്വെന്റി ത്രീ', 'ട്വെന്റി ഫോർ', 'ട്വെന്റി ഫൈവ്', 'ട്വെന്റി സിക്സ്', 'ട്വെന്റി സെവൻ', 'ട്വെന്റി എട്ട്', 'ട്വെന്റി നൈൻ',
21
+ # Malayalam combinations of 21-29
22
+ 'ഇരുപത്തി ഒന്ന്', 'ഇരുപത്തി രണ്ട്', 'ഇരുപത്തി മൂന്ന്', 'ഇരുപത്തി നാല്', 'ഇരുപത്തി അഞ്ചു', 'ഇരുപത്തി ആറ്', 'ഇരുപത്തി ഏഴ്', 'ഇരുപത്തി എട്ട്', 'ഇരുപത്തി ഒമ്പത്',
23
+ 'ഇരുപത്തിഒന്ന്','ഇരുപത്തിരണ്ട്','ഇരുപത്തിമൂന്ന്','രുപത്തരണ്ട്','ഇരുപത്തിഞ്ച്','ഇരുപത്തിആറ്','ഇരുപത്തിഎട്ട്','ഇരുപത്തിഒമ്പത്','ഇരുപത്തിഒമ്പത്',
24
+
25
+ # Malayalam script for English combinations of 31-39
26
+ 'തിർറ്റി ഒൺ', 'തിർറ്റി ടു', 'തിർറ്റി ത്രീ', 'തിർറ്റി ഫോർ', 'തിർറ്റി ഫൈവ്', 'തിർറ്റി സിക്സ്', 'തിർറ്റി സെവൻ', 'തിർറ്റി എട്ട്', 'തിർറ്റി നൈൻ',
27
+ # Malayalam combinations of 31-39
28
+ 'മുപ്പത് ഒന്ന്', 'മുപ്പത് രണ്ട്', 'മുപ്പത് മൂന്ന്', 'മുപ്പത് നാല്', 'മുപ്പത് അഞ്ചു', 'മുപ്പത് ആറ്', 'മുപ്പത് ഏഴ്', 'മുപ്പത് എട്ട്', 'മുപ്പത് ഒമ്പത്',
29
+ 'മുപ്പത്തിഒന്ന്','മുപ്പത്തിരണ്ട്','മുപ്പത്തിമൂന്ന്','മുപ്പത്തിനാല്','മുപ്പത്തിചഞ്ച്','മുപ്പത്തിആറ്','മുപ്പത്തിയെഴ്','മുപ്പത്തിഏട്ട്','മുപ്പത്തിഒമ്പത്',
30
+
31
+ # Malayalam script for English combinations of 41-49
32
+ 'ഫോർറ്റി ഒൺ', 'ഫോർറ്റി ടു', 'ഫോർറ്റി ത്രീ', 'ഫോർറ്റി ഫോർ', 'ഫോർറ്റി ഫൈവ്', 'ഫോർറ്റി സിക്സ്', 'ഫോർറ്റി സെവൻ', 'ഫോർറ്റി എട്ട്', 'ഫോർറ്റി നൈൻ',
33
+ # Malayalam combinations of 41-49
34
+ 'നാല്പത് ഒന്ന്', 'നാല്പത് രണ്ട്', 'നാല്പത് മൂന്ന്', 'നാല്പത് നാല്', 'നാല്പത് അഞ്ച്', 'നാല്പത് ആറ്', 'നാല്പത് ഏഴ്', 'നാല്പത് എട്ട്', 'നാല്പത് ഒമ്പത്',
35
+ 'നാല്പത്തിഒന്ന്','നാല്പത്തിരണ്ട്','നാല്പത്തിമൂന്ന്','നാല്പത്തിനാല്','നാല്പത്തിഅഞ്ച്','നാല്പത്തിആറ്','നാല്പത്തിയെഴ്','നാല്പത്തിഏട്ട്','നാല്പത്തിഒമ്പത്',
36
+
37
+ # Malayalam script for English combinations of 51-59
38
+ 'ഫിഫ്റ്റി ഒൺ', 'ഫിഫ്റ്റി ടു', 'ഫിഫ്റ്റി ത്രീ', 'ഫിഫ്റ്റി ഫോർ', 'ഫിഫ്റ്റി ഫൈവ്', 'ഫിഫ്റ്റി സിക്സ്', 'ഫിഫ്റ്റി സെവൻ', 'ഫിഫ്റ്റി എട്ട്', 'ഫിഫ്റ്റി നൈൻ',
39
+ # Malayalam combinations of 51-59
40
+ 'ഐമ്പത് ഒന്ന്', 'ഐമ്പത് രണ്ട്', 'ഐമ്പത് മൂന്ന്', 'ഐമ്പത് നാല്', 'ഐമ്പത് അഞ്ചു', 'ഐമ്പത് ആറ്', 'ഐമ്പത് ഏഴ്', 'ഐമ്പത് എട്ട്', 'ഐമ്പത് ഒമ്പത്',
41
+ 'ഐമ്പത്തിഒന്ന്','ഐമ്പത്തിരണ്ട്','ഐമ്പത്തിമൂന്ന്','ഐമ്പത്തിനാല്','ഐമ്പത്തിഅഞ്ച്','ഐമ്പത്തിആറ്','ഐമ്പത്തിയെഴ്','ഐമ്പത്തിഏട്ട്','ഐമ്പത്തിഒമ്പത്',
42
+
43
+ # Malayalam script for English combinations of 61-69
44
+ 'സിക്സ്റ്റി ഒൺ', 'സിക്സ്റ്റി ടു', 'സിക്സ്റ്റി ത്രീ', 'സിക്സ്റ്റി ഫോർ', 'സിക്സ്റ്റി ഫൈവ്', 'സിക്സ്റ്റി സിക്സ്', 'സിക്സ്റ്റി സെവൻ', 'സിക്സ്റ്റി എട്ട്', 'സിക്സ്റ്റി നൈൻ',
45
+ # Malayalam combinations of 61-69
46
+ 'അറുപത് ഒന്ന്', 'അറുപത് രണ്ട്', 'അറുപത് മൂന്ന്', 'അറുപത് നാല്', 'അറുപത് അഞ്ചു', 'അറുപത് ആറ്', 'അറുപത് ഏഴ്', 'അറുപത് എട്ട്', 'അറുപത് ഒമ്പത്',
47
+ 'അറുപത്തിഒന്ന്','അറുപത്തിരണ്ട്','അറുപത്തിമൂന്ന്','അറുപത്തിനാല്','അറുപത്തിഅഞ്ച്','അറുപത്തിആറ്','അറുപത്തിയെഴ്','അറുപത്തിഏട്ട്','അറുപത്തിഒമ്പത്',
48
+
49
+ # Malayalam script for English combinations of 71-79
50
+ 'സിവൻ്റി ഒൺ', 'സിവൻ്റി ടു', 'സിവൻ്റി ത്രീ', 'സിവൻ്റി ഫോർ', 'സിവൻ്റി ഫൈവ്', 'സിവൻ്റി സിക്സ്', 'സിവൻ്റി സെവൻ', 'സിവൻ്റി എട്ട്', 'സിവൻ്റി നൈൻ',
51
+ # Malayalam combinations of 71-79
52
+ 'എഴുപത് ഒന്ന്', 'എഴുപത് രണ്ട്', 'എഴുപത് മൂന്ന്', 'എഴുപത് നാല്', 'എഴുപത് അഞ്ചു', 'എഴുപത് ആറ്', 'എഴുപത് ഏഴ്', 'എഴുപത് എട്ട്', 'എഴുപത് ഒമ്പത്',
53
+ 'എഴുപത്തിഒന്ന്','എഴുപത്തിരണ്ട്','എഴുപത്തിമൂന്ന്','എഴുപത്തിനാല്','എഴുപത്തിഅഞ്ച്','എഴുപത്തിആറ്','എഴുപത്തിയെഴ്','എഴുപത്തിഏട്ട്','എഴുപത്തിഒമ്പത്',
54
+
55
+ # Malayalam script for English combinations of 81-89
56
+ 'എയ്ഡ് ഒൺ', 'എയ്ഡ് ടു', 'എയ്ഡ് ത്രീ', 'എയ്ഡ് ഫോർ', 'എയ്ഡ് ഫൈവ്', 'എയ്ഡ് സിക്സ്', 'എയ്ഡ് സെവൻ', 'എയ്ഡ് എട്ട്', 'എയ്ഡ് നൈൻ',
57
+ # Malayalam combinations of 81-89
58
+ 'എൺപത് ഒന്ന്', 'എൺപത് രണ്ട്', 'എൺപത് മൂന്ന്', 'എൺപത് നാല്', 'എൺപത് അഞ്ച്', 'എൺപത് ആറ്', 'എൺപത് ഏഴ്', 'എൺപത് എട്ട്', 'എൺപത് ഒമ്പത്',
59
+ 'എൺപത്തിഒന്ന്','എൺപത്തിരണ്ട്','എൺപത്തിമൂന്ന്','എൺപത്തിനാല്','എൺപത്തിഅഞ്ച്','എൺപത്തിആറ്','എൺപത്തിയെഴ്','എൺപത്തിഏട്ട്','എൺപത്തിഒമ്പത്',
60
+
61
+ # Malayalam script for English combinations of 91-99
62
+ 'നൈന്റ്റി ഒൺ', 'നൈന്റ്റി ടു', 'നൈന്റ്റി ത്രീ', 'നൈന്റ്റി ഫോർ', 'നൈന്റ്റി ഫൈവ്', 'നൈന്റ്റി സിക്സ്', 'നൈന്റ്റി സെവൻ', 'നൈന്റ്റി എട്ട്', 'നൈ���്റ്റി നൈൻ',
63
+ # Malayalam combinations of 91-99
64
+ 'തൊണ്ണൂറ് ഒന്ന്', 'തൊണ്ണൂറ് രണ്ട്', 'തൊണ്ണൂറ് മൂന്ന്', 'തൊണ്ണൂറ് നാല്', 'തൊണ്ണൂറ് അഞ്ചു', 'തൊണ്ണൂറ് ആറ്', 'തൊണ്ണൂറ് ഏഴ്', 'തൊണ്ണൂറ് എട്ട്', 'തൊണ്ണൂറ് ഒമ്പത്',
65
+ 'തൊണ്ണൂറ്റിഒന്ന്','തൊണ്ണൂറ്റിരണ്ട്','തൊണ്ണൂറ്റിമൂന്ന്','തൊണ്ണൂറ്റിനാല്','തൊണ്ണൂറ്റിഅഞ്ച്','തൊണ്ണൂറ്റിആറ്','തൊണ്ണൂറ്റിയെഴ്','തൊണ്ണൂറ്റിഏട്ട്','തൊണ്ണൂറ്റിഒമ്പത്',
66
+
67
+ # Malayalam script for English numbers (0-10)
68
+ 'സീറോ', 'വൺ', 'ടു', 'ത്രീ', 'ഫോർ', 'ഫൈവ്', 'സിക്സ്', 'സിവൻ', 'എട്ട്', 'നൈൻ', 'ടെൻ',
69
+ # Malayalam numbers (0-10)
70
+ 'പൂജ്യം', 'ഒന്ന്', 'രണ്ട്', 'മൂന്ന്', 'നാല്', 'അഞ്ച്', 'ആറ്', 'ഏഴ്', 'എട്ട്', 'ഒമ്പത്', 'പത്ത്',
71
+
72
+ # Malayalam script for 100
73
+ 'ഹണ്ട്രഡ്',
74
+ # Malayalam for 100
75
+ 'നൂறு',
76
+ # Malayalam for 1000
77
+ 'ആയിരം'
78
+ ]
79
+ return text_list
80
+
81
+
82
+ # In[ ]:
83
+
84
+
85
+
86
+
convert2list.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[2]:
5
+
6
+
7
+ # import nbimporter
8
+ import nbimporter
9
+ from Text2List import text_to_list
10
+ def convert_to_list(text, text_list):
11
+ matched_words = []
12
+ unmatched_text = '' # To accumulate unmatched characters
13
+
14
+ # Sort text_list by length in descending order to prioritize longest matches first
15
+ text_list_sorted = sorted(text_list, key=len, reverse=True)
16
+
17
+ while text:
18
+ matched = False
19
+ for word in text_list_sorted:
20
+ if text.startswith(word):
21
+ # Add any accumulated unmatched text before appending the matched word
22
+ if unmatched_text:
23
+ matched_words.append(unmatched_text)
24
+ unmatched_text = '' # Reset unmatched text accumulator
25
+
26
+ matched_words.append(word)
27
+ text = text[len(word):] # Remove the matched part from text
28
+ matched = True
29
+ break
30
+
31
+ if not matched:
32
+ # Accumulate unmatched characters
33
+ unmatched_text += text[0]
34
+ text = text[1:]
35
+
36
+ # If there's any remaining unmatched text, add it to the result
37
+ if unmatched_text:
38
+ matched_words.append(unmatched_text)
39
+
40
+ # Join matched words and unmatched text with a space
41
+ result = ' '.join(matched_words)
42
+ return result
43
+
44
+ # text = "जीरोएकदोतीनचारपांचछहसातआठनौदसजीरोएकदोतीनचारपांच"
45
+
46
+ # if __name__=="__main__":
47
+ # converted=convert_to_list(text, text_to_list())
48
+ # print(converted)
49
+
50
+
51
+ # In[ ]:
52
+
53
+
54
+
55
+
replaceWords.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[9]:
5
+
6
+
7
+ import re
8
+ malayalam_numbers = {
9
+ 'one': ['ഒന്ന്', 'ഒന്നു', 'വൺ'],
10
+ 'two': ['രണ്ട്', 'രണ്ടും', 'ടൂ'],
11
+ 'three': ['മൂന്ന്', 'മുന്ന്', 'ത്രീ'],
12
+ 'four': ['നാല്', 'നാലു', 'ഫോർ'],
13
+ 'five': ['അഞ്ച്', 'അഞ്ചു', 'ഫൈവ്'],
14
+ 'six': ['ആറ്', 'ആறு', 'സിക്സ്'],
15
+ 'seven': ['ഏഴ്', 'എഴു', 'സെവൻ'],
16
+ 'eight': ['എട്ട്', 'എട്ട്', 'എയ്‌റ്റ്'],
17
+ 'nine': ['ഒമ്പത്', 'ഒമ്പതു', 'നൈൻ'],
18
+ 'ten': ['പത്ത്', 'പത്തുപാട്', 'ടെൻ'],
19
+
20
+ 'eleven': ['പതിനൊന്ന്', 'പതിനൊന്നും', 'എലവൻ'],
21
+ 'twelve': ['പന്നിരണ്ട്', 'പന്നിരണ്ടും', 'ട്വെൽവ്'],
22
+ 'thirteen': ['പതിന്മൂന്ന്', 'പതിന്മുന്ന്', 'തർതീൻ'],
23
+ 'fourteen': ['പതിനാല്', 'പതിനാലു', 'ഫോർടheen'],
24
+ 'fifteen': ['പതിനഞ്ച്', 'പതിനഞ്ചു', 'ഫിഫ്റ്റീൻ'],
25
+ 'sixteen': ['പതിനാറ്', 'പതിനാറു', 'സിക്സ്റ്റീൻ'],
26
+ 'seventeen': ['പതിനേഴ്', 'പതിനേഴ്', 'സെവന്റീൻ'],
27
+ 'eighteen': ['പതിനെട്ട്', 'പതിനെട്ടു', 'എറ്റിൻ'],
28
+ 'nineteen': ['പതൊമ്പത്', 'പത്തൊമ്പതു', 'നൈന്റീൻ'],
29
+
30
+ 'twenty': ['ഇരുപത്', 'ഇരുപത്തൊ', 'ട്വെന്റി'],
31
+ 'twenty one': ['ഇരുപത് ഒന്ന്', 'ഇരുപതൊന്ന്', 'ട്വെന്റി വൺ'],
32
+ 'twenty two': ['ഇരുപത് രണ്ട്', 'ഇരുപതുള്ള്', 'ട്വെന്റി ടൂ'],
33
+ 'twenty three': ['ഇരുപത് മൂന്ന്', 'ഇരുപത്തുമൂന്ന്', 'ട്വെന്റി ത്രീ'],
34
+ 'twenty four': ['ഇരുപത് നാല്', 'ഇരുപത്തുനാല്', 'ട്വെന്റി ഫോർ'],
35
+ 'twenty five': ['ഇരുപത് അഞ്ച്', 'ഇരുപത്തുഐന്ന്', 'ട്വെന്റി ഫൈവ്'],
36
+ 'twenty six': ['ഇരുപത് ആറ്', 'ഇരുപത്തുആറ്', 'ട്വെന്റി സിക്സ്'],
37
+ 'twenty seven': ['ഇരുപത് ഏഴ്', 'ഇരുപത്തുഏഴ്', 'ട്വെന്റി സെവൻ'],
38
+ 'twenty eight': ['ഇരുപത് എട്ട്', 'ഇരുപത്തുഎട്ട്', 'ട്വെന്റി എയ്‌റ്റ്'],
39
+ 'twenty nine': ['ഇരുപത് ഒമ്പത്', 'ഇരുപത്തൊമ്പത്', 'ട്വെന്റി നൈൻ'],
40
+
41
+ 'thirty': ['മുപ്പത്', 'മുപ്പത്തൊ', 'തർട്ടി'],
42
+ 'thirty one': ['മുപ്പത് ഒന്ന്', 'മുപ്പത്തൊന്ന്', 'തർട്ടി വൺ'],
43
+ 'thirty two': ['മുപ്പത് രണ്ട്', 'മുപ്പത്തുള്ള്', 'തർട്ടി ടൂ'],
44
+ 'thirty three': ['മുപ്പത് മൂന്ന്', 'മുപ്പത്തുമൂന്ന്', 'തർട്ടി ത്രീ'],
45
+ 'thirty four': ['മുപ്പത് നാല്', 'മുപ്പത്തുനാൽ', 'തർട്ടി ഫോർ'],
46
+ 'thirty five': ['മുപ്പത് അഞ്ച്', 'മുപ്പത്തുഐന്ന്', 'തർട്ടി ഫൈവ്'],
47
+ 'thirty six': ['മുപ്പത് ആറ്', 'മുപ്പത്തുആറ്', 'തർട്ടി സിക്സ്'],
48
+ 'thirty seven': ['മുപ്പത് ഏഴ്', 'മുപ്പത്തുഏഴ്', 'തർട്ടി സെവൻ'],
49
+ 'thirty eight': ['മുപ്പത് എട്ട്', 'മുപ്പത്തുഎട്ട്', 'തർട്ടി എയ്‌റ്റ്'],
50
+ 'thirty nine': ['മുപ്പത് ഒമ്പത്', 'മുപ്പത്തൊമ്പത്', 'തർട്ടി നൈൻ'],
51
+
52
+ 'forty': ['നാല്പത്', 'നാല്പത്തൊ', 'ഫോർട്ടി'],
53
+ 'forty one': ['നാല്പത് ഒന്ന്', 'നാല്പത്തൊന്ന്', 'ഫോർട്ടി വൺ'],
54
+ 'forty two': ['നാല്പത് രണ്ട്', 'നാല്പത്തുള്ള്', 'ഫോർട്ടി ടൂ'],
55
+ 'forty three': ['നാല്പത് മൂന്ന്', 'നാല്പത്തുമൂന്ന്', 'ഫോർട്ടി ത്രീ'],
56
+ 'forty four': ['നാല്പത് നാല്', 'നാല്പത്തുനാൽ', 'ഫോർട്ടി ഫോർ'],
57
+ 'forty five': ['നാല്പത് അഞ്ച്', 'നാല്പത്തുഐന്ന്', 'ഫോർട്ടി ഫൈവ്'],
58
+ 'forty six': ['നാല്പത് ആറ്', 'നാല്പത്തുആറ്', 'ഫോർട്ടി സിക്സ്'],
59
+ 'forty seven': ['നാല്പത് ഏഴ്', 'നാല്പത്തുഏഴ്', 'ഫോർട്ടി സെവൻ'],
60
+ 'forty eight': ['നാല്പത് എട്ട്', 'നാല്പത്തുഎട്ട്', 'ഫോർട്ടി എയ്‌റ്റ്'],
61
+ 'forty nine': ['നാല്പത് ഒമ്പത്', 'നാല്പത്തൊമ്പത്', 'ഫോർട്ടി നൈൻ'],
62
+
63
+ 'fifty': ['അമ്പത്', 'അമ്പത്തൊ', 'ഫിഫ്റ്റി'],
64
+ 'fifty one': ['അമ്പത് ഒന്ന്', 'അമ്പത്തൊന്ന്', 'ഫിഫ്റ്റി വൺ'],
65
+ 'fifty two': ['അമ്പത് രണ്ട്', 'അമ്പത്തുള്ള്', 'ഫിഫ്റ്റി ടൂ'],
66
+ 'fifty three': ['അമ്പത് മൂന്ന്', 'അമ്പത്തുമൂന്ന്', 'ഫിഫ്റ്റി ത്രീ'],
67
+ 'fifty four': ['അമ്പത് നാല്', 'അമ്പത്തുനാൽ', 'ഫിഫ്റ്റി ഫോർ'],
68
+ 'fifty five': ['അമ്പത് അഞ്ചു', 'അമ്പത്തുഐന്ന്', 'ഫിഫ്റ്റി ഫൈവ്'],
69
+ 'fifty six': ['അമ്പത് ആറ്', 'അമ്പത്തുആറ്', 'ഫിഫ്റ്റി സിക്സ്'],
70
+ 'fifty seven': ['അമ്പത് ഏഴ്', 'അമ്പത്തുഏഴ്', 'ഫിഫ്റ്റി സെവൻ'],
71
+ 'fifty eight': ['അമ്പത് എട്ട്', 'അമ്പത്തുഎട്ട്', 'ഫിഫ്റ്റി എയ്‌റ്റ്'],
72
+ 'fifty nine': ['അമ്പത് ഒമ്പത്', 'അമ്പത്തൊമ്പത്', 'ഫിഫ്റ്റി നൈൻ'],
73
+
74
+ 'sixty': ['അറുപത്', 'അറുപത്തൊ', 'സിക്സ്റ്റി'],
75
+ 'sixty one': ['അറുപത് ഒന്ന്', 'അറുപത് ഒന്നു', 'സിക്സ്റ്റി വൺ'],
76
+ 'sixty two': ['അറുപത് രണ്ട്', 'അറുപത് രണ്ട്', 'സിക്സ്റ്റി ടൂ'],
77
+ 'sixty three': ['അറുപത് മൂന്ന്', 'അറുപത് മൂന്ന്', 'സിക്സ്റ്റി ത്രീ'],
78
+ 'sixty four': ['അറുപത് നാല്', 'അറുപത് നാല്', 'സിക്സ്റ്റി ഫോർ'],
79
+ 'sixty five': ['അറുപത് അഞ്ച്', 'അറുപത് അഞ്ചു', 'സിക്സ്റ്റി ഫൈവ്'],
80
+ 'sixty six': ['അറുപത് ആറ്', 'അറുപത് ആരു', 'സിക്സ്റ്റി സിക്സ്'],
81
+ 'sixty seven': ['അറുപത് ഏഴ്', 'അറുപത് ഏഴ്', 'സിക്സ്റ്റി സെവൻ'],
82
+ 'sixty eight': ['അറുപത് എട്ട്', 'അറുപത് എട്ട്', 'സിക്സ്റ്റി എയ്‌റ്റ്'],
83
+ 'sixty nine': ['അറുപത് ഒമ്പത്', 'അറുപത് ഒമ്പതു', 'സിക്സ്റ്റി നൈൻ'],
84
+
85
+ 'seventy': ['എഴുപത്', 'എഴുപത്തൊ', 'സെവന്റി'],
86
+ 'seventy one': ['എഴുപത് ഒന്ന്', 'എഴുപത് ഒന്നു', 'സെവന്റി വൺ'],
87
+ 'seventy two': ['എഴുപത് രണ്ട്', 'എഴുപത് രണ്ട്', 'സെവന്റി ടൂ'],
88
+ 'seventy three': ['എഴുപത് മൂന്ന്', 'എഴുപത് മൂന്ന്', 'സെവന്റി ത്രീ'],
89
+ 'seventy four': ['എഴുപത് നാല്', 'എഴുപത് നാല്', 'സെവന്റി ഫോർ'],
90
+ 'seventy five': ['എഴുപത് അഞ്ച്', 'എഴുപത് അഞ്ചു', 'സെവന്റി ഫൈവ്'],
91
+ 'seventy six': ['എഴുപത് ആറ്', 'എഴുപത് ആരു', 'സെവന്റി സിക്സ്'],
92
+ 'seventy seven': ['എഴുപത് ഏഴ്', 'എഴുപത് ഏഴ്', 'സെവന്റി സെവൻ'],
93
+ 'seventy eight': ['എഴുപത് എട്ട്', 'എഴുപത് എട്ട്', 'സെവന്റി എയ്‌റ്റ്'],
94
+ 'seventy nine': ['എഴുപത് ഒമ്പത്', 'എഴുപത് ഒമ്പതു', 'സെവന്റി നൈൻ'],
95
+
96
+ 'eighty': ['എൺപത്', 'എൺപത്തൊ', 'എയ്റ്റി'],
97
+ 'eighty one': ['എൺപത് ഒന്ന്', 'എൺപത് ഒന്നു', 'എയ്റ്റി വൺ'],
98
+ 'eighty two': ['എൺപത് രണ്ട്', 'എൺപ��് രണ്ട്', 'എയ്റ്റി ടൂ'],
99
+ 'eighty three': ['എൺപത് മൂന്ന്', 'എൺപത് മൂന്ന്', 'എയ്റ്റി ത്രീ'],
100
+ 'eighty four': ['എൺപത് നാല്', 'എൺപത് നാല്', 'എയ്റ്റി ഫോർ'],
101
+ 'eighty five': ['എൺപത് അഞ്ച്', 'എൺപത് അഞ്ചു', 'എയ്റ്റി ഫൈവ്'],
102
+ 'eighty six': ['എൺപത് ആറ്', 'എൺപത് ആറ്', 'എയ്റ്റി സിക്സ്'],
103
+ 'eighty seven': ['എൺപത് ഏഴ്', 'എൺപത് ഏഴ്', 'എയ്റ്റി സെവൻ'],
104
+ 'eighty eight': ['എൺപത് എട്ട്', 'എൺപത് എട്ട്', 'എയ്റ്റി എയ്‌റ്റ്'],
105
+ 'eighty nine': ['എൺപത് ഒമ്പത്', 'എൺപത് ഒമ്പതു', 'എയ്റ്റി നൈൻ'],
106
+
107
+ 'ninety': ['തൊണ്ണൂറി', 'തൊണ്ണൂറി', 'നൈന്റ്റി'],
108
+ 'ninety one': ['തൊണ്ണൂറി ഒന്ന്', 'തൊണ്ണൂറി ഒന്നു', 'നൈന്റ്റി വൺ'],
109
+ 'ninety two': ['തൊണ്ണൂറി രണ്ട്', 'തൊണ്ണൂറി രണ്ട്', 'നൈന്റ്റി ടൂ'],
110
+ 'ninety three': ['തൊണ്ണൂറി മൂന്ന്', 'തൊണ്ണൂറി മൂന്ന്', 'നൈന്റ്റി ത്രീ'],
111
+ 'ninety four': ['തൊണ്ണൂറി четыре', 'തൊണ്ണൂറി', 'നൈന്റ്റി ഫോർ'],
112
+ 'ninety five': ['തൊണ്ണൂറി five', 'തൊണ്ണൂറി', 'നൈന്റ്റി 5'],
113
+
114
+ 'hundred': ['നൂറ്', 'നൂറ്', 'ഹണ്ട്രഡ്']
115
+ }
116
+
117
+ words = sentence.split() # Split the sentence by spaces
118
+
119
+ # Replace words using the mapping
120
+ for i, word in enumerate(words):
121
+ for replacement, patterns in replacement_map.items():
122
+ if word in patterns:
123
+ words[i] = replacement # Replace the word if it's fully matched
124
+
125
+ # Join the processed words back into a sentence
126
+ return ' '.join(words)
127
+
128
+
129
+ # In[ ]:
130
+
131
+
132
+
133
+
text2int.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # In[3]:
5
+
6
+
7
+ import nbimporter
8
+ from isNumber import is_number # Remove or replace this if unnecessary
9
+
10
+ def text_to_int(textnum, numwords={}):
11
+ # Define units, tens, and scales including "lac"
12
+ units = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
13
+ 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',
14
+ 'sixteen', 'seventeen', 'eighteen', 'nineteen']
15
+ tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
16
+ scales = ['hundred', 'thousand', 'lac', 'million', 'billion', 'trillion'] # "lac" added
17
+ ordinal_words = {'first': 1, 'second': 2, 'third': 3, 'fifth': 5, 'eighth': 8, 'ninth': 9, 'twelfth': 12}
18
+ ordinal_endings = [('ieth', 'y'), ('th', '')]
19
+
20
+ if not numwords:
21
+ numwords['and'] = (1, 0) # Handle "one hundred and twenty"
22
+
23
+ # Add units, tens, and scales to numwords
24
+ for idx, word in enumerate(units):
25
+ numwords[word] = (1, idx)
26
+ for idx, word in enumerate(tens):
27
+ numwords[word] = (1, idx * 10)
28
+
29
+ for idx, word in enumerate(scales):
30
+ numwords[word] = (10 ** (5 if word == 'lac' else idx * 3 or 2), 0) # Handle "lac" as 10^5
31
+
32
+ # Remove hyphens and normalize input
33
+ textnum = textnum.replace('-', ' ')
34
+
35
+ current = result = 0
36
+ curstring = ''
37
+ onnumber = False
38
+ lastunit = False
39
+ lastscale = False
40
+
41
+ def is_numword(x):
42
+ return is_number(x) or x in numwords
43
+
44
+ def from_numword(x):
45
+ if is_number(x):
46
+ return 0, int(x.replace(',', ''))
47
+ return numwords[x]
48
+
49
+ for word in textnum.split():
50
+ if word in ordinal_words:
51
+ scale, increment = (1, ordinal_words[word])
52
+ current = current * scale + increment
53
+ if scale > 100:
54
+ result += current
55
+ current = 0
56
+ onnumber = True
57
+ lastunit = False
58
+ lastscale = False
59
+ else:
60
+ for ending, replacement in ordinal_endings:
61
+ if word.endswith(ending):
62
+ word = f"{word[:-len(ending)]}{replacement}"
63
+
64
+ if not is_numword(word) or (word == 'and' and not lastscale):
65
+ if onnumber:
66
+ curstring += repr(result + current) + " "
67
+ curstring += word + " "
68
+ result = current = 0
69
+ onnumber = False
70
+ lastunit = False
71
+ lastscale = False
72
+ else:
73
+ scale, increment = from_numword(word)
74
+ onnumber = True
75
+
76
+ if lastunit and word not in scales:
77
+ curstring += repr(result + current) + " "
78
+ result = current = 0
79
+
80
+ if scale > 1:
81
+ current = max(1, current)
82
+
83
+ current = current * scale + increment
84
+
85
+ if scale >= 100:
86
+ result += current
87
+ current = 0
88
+
89
+ lastscale = word in scales
90
+ lastunit = word in units
91
+
92
+ if onnumber:
93
+ curstring += repr(result + current)
94
+
95
+ return curstring.strip()
96
+
97
+
98
+ # In[ ]:
99
+
100
+
101
+
102
+