cdactvm commited on
Commit
aa64d25
·
verified ·
1 Parent(s): f49c883

Delete processDoubles.ipynb

Browse files
Files changed (1) hide show
  1. processDoubles.ipynb +0 -85
processDoubles.ipynb DELETED
@@ -1,85 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 2,
6
- "id": "5912ba94-833f-4662-8b8c-f201b5dde892",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "# # Function to process \"double\" followed by a number\n",
11
- "# def process_doubles(sentence):\n",
12
- "# tokens = sentence.split()\n",
13
- "# result = []\n",
14
- "# i = 0\n",
15
- "# while i < len(tokens):\n",
16
- "# if tokens[i] == \"डबल\":\n",
17
- "# if i + 1 < len(tokens):\n",
18
- "# result.append(tokens[i + 1])\n",
19
- "# result.append(tokens[i + 1])\n",
20
- "# i += 2\n",
21
- "# else:\n",
22
- "# result.append(tokens[i])\n",
23
- "# i += 1\n",
24
- "# else:\n",
25
- "# result.append(tokens[i])\n",
26
- "# i += 1\n",
27
- "# return ' '.join(result)\n"
28
- ]
29
- },
30
- {
31
- "cell_type": "code",
32
- "execution_count": null,
33
- "id": "7d7065ce-94c9-4cda-a398-71dac90a67ba",
34
- "metadata": {},
35
- "outputs": [],
36
- "source": [
37
- "import re\n",
38
- "\n",
39
- "def process_doubles(sentence):\n",
40
- " # Use regex to split 'डबल' followed by numbers/words without space (e.g., \"डबलवन\" -> \"डबल वन\")\n",
41
- " sentence = re.sub(r'(डबल)(\\S+)', r'\\1 \\2', sentence)\n",
42
- " \n",
43
- " tokens = sentence.split()\n",
44
- " result = []\n",
45
- " i = 0\n",
46
- " \n",
47
- " while i < len(tokens):\n",
48
- " if tokens[i] == \"डबल\":\n",
49
- " if i + 1 < len(tokens):\n",
50
- " result.append(tokens[i + 1]) # Append the next word/number\n",
51
- " result.append(tokens[i + 1]) # Append the next word/number again to duplicate\n",
52
- " i += 2 # Skip over the next word since it's already processed\n",
53
- " else:\n",
54
- " result.append(tokens[i])\n",
55
- " i += 1\n",
56
- " else:\n",
57
- " result.append(tokens[i])\n",
58
- " i += 1\n",
59
- "\n",
60
- " return ' '.join(result)\n"
61
- ]
62
- }
63
- ],
64
- "metadata": {
65
- "kernelspec": {
66
- "display_name": "Python 3 (ipykernel)",
67
- "language": "python",
68
- "name": "python3"
69
- },
70
- "language_info": {
71
- "codemirror_mode": {
72
- "name": "ipython",
73
- "version": 3
74
- },
75
- "file_extension": ".py",
76
- "mimetype": "text/x-python",
77
- "name": "python",
78
- "nbconvert_exporter": "python",
79
- "pygments_lexer": "ipython3",
80
- "version": "3.11.7"
81
- }
82
- },
83
- "nbformat": 4,
84
- "nbformat_minor": 5
85
- }