File size: 2,473 Bytes
3b58a97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
# coding: utf-8

# In[1]:


# # Function to process "double" followed by a number
# def process_doubles(sentence):
#     tokens = sentence.split()
#     result = []
#     i = 0
#     while i < len(tokens):
#         if tokens[i] == "double":
#             if i + 1 < len(tokens):
#                 result.append(tokens[i + 1])
#                 result.append(tokens[i + 1])
#                 i += 2
#             else:
#                 result.append(tokens[i])
#                 i += 1
#         else:
#             result.append(tokens[i])
#             i += 1
#     return ' '.join(result)


# In[ ]:


# import re

# def process_doubles(sentence):
#     # Use regex to split 'डबल' followed by numbers/words without space (e.g., "डबलवन" -> "डबल वन")
#     sentence = re.sub(r'(डबल)(\S+)', r'\1 \2', sentence)
    
#     tokens = sentence.split()
#     result = []
#     i = 0
    
#     while i < len(tokens):
#         if tokens[i] == "डबल":
#             if i + 1 < len(tokens):
#                 result.append(tokens[i + 1])  # Append the next word/number
#                 result.append(tokens[i + 1])  # Append the next word/number again to duplicate
#                 i += 2  # Skip over the next word since it's already processed
#             else:
#                 result.append(tokens[i])
#                 i += 1
#         else:
#             result.append(tokens[i])
#             i += 1

#     return ' '.join(result)


# In[2]:


# Function to process "double" and "triple" followed by a number

def process_multiples(sentence):
    tokens = sentence.split()
    result = []
    i = 0
    while i < len(tokens):
        if tokens[i] == "double":
            if i + 1 < len(tokens):
                result.append(tokens[i + 1])
                result.append(tokens[i + 1])
                i += 2
            else:
                result.append(tokens[i])
                i += 1
        elif tokens[i] == "triple":
            if i + 1 < len(tokens):
                result.append(tokens[i + 1])
                result.append(tokens[i + 1])
                result.append(tokens[i + 1])
                i += 2
            else:
                result.append(tokens[i])
                i += 1
        else:
            result.append(tokens[i])
            i += 1
    return ' '.join(result)


# In[ ]: