urdu-text-utils 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+
5
+ - Dictionary grows to ~650 entries: news and public-life vocabulary (the densest register in Urdu media), technology, education, health, colours, animals, extended family, food and place names.
6
+ - Rule fallback reads `ی` by position — `e` inside a word (`کھیل` → `khel`), `i` at the end (`پڑھی` → `parhi`) — and recognises the final `یں` plural ending (`سڑکیں` → `sarkein`, previously `sarkin`).
7
+ - `مارنا` transliterates as `maarna` so it no longer collapses into `مرنا` in the reverse direction.
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  - Expand the transliteration dictionary to ~450 entries: high-frequency vocabulary, oblique infinitives (`کرنے`, `رہنے`), English loanwords (`سکول`, `کمپیوٹر`) and common Roman spelling variants. The dictionary moved to `src/dictionary.ts`.
package/README.md CHANGED
@@ -155,7 +155,7 @@ Read this before putting it in front of users.
155
155
 
156
156
  Urdu script omits short vowels, so the mapping is genuinely ambiguous: `کتب` is `kitab` or `kutub` depending on context and no rule table can decide which. The reverse direction is worse, because Roman Urdu has no standard orthography (`hai` / `hay` / `he` all occur).
157
157
 
158
- These functions work in two layers: a dictionary of ~450 high-frequency words, English loanwords and oblique verb forms, then a rule fallback that handles aspirated digraphs, word-initial `و`/`ی` as consonants, word-final `ہ` as `-a`, and a schwa insertion so unseen words stay pronounceable. Dictionary hits are reliable; rule output is an approximation. Do not build anything irreversible on it. A real lexicon plus a statistical model is planned, not faked here.
158
+ These functions work in two layers: a dictionary of ~650 high-frequency words, English loanwords and oblique verb forms, then a rule fallback that handles aspirated digraphs, word-initial `و`/`ی` as consonants, word-final `ہ` as `-a`, `ی` by position (`کھیل` → `khel`, `پڑھی` → `parhi`, `سڑکیں` → `sarkein`), and a schwa insertion so unseen words stay pronounceable. Dictionary hits are reliable; rule output is an approximation. Do not build anything irreversible on it. A real lexicon plus a statistical model is planned, not faked here.
159
159
 
160
160
  ```ts
161
161
  romanize("آپ کیسے ہیں"); // "aap kaisay hain"
package/dist/index.cjs CHANGED
@@ -1061,6 +1061,201 @@ var WORD_DICTIONARY = {
1061
1061
  "\u0628\u06C1\u062A": "bohat",
1062
1062
  "\u0635\u0631\u0641": "sirf",
1063
1063
  "\u0648\u0627\u0642\u0639\u06CC": "waqai",
1064
+ // ---- more verbs ----
1065
+ "\u06A9\u06BE\u06CC\u0644\u0646\u0627": "khelna",
1066
+ "\u06A9\u06BE\u06CC\u0644\u062A\u0627": "khelta",
1067
+ "\u06C1\u0646\u0633\u0646\u0627": "hansna",
1068
+ "\u0631\u0648\u0646\u0627": "rona",
1069
+ "\u0688\u0631\u0646\u0627": "darna",
1070
+ "\u0628\u06BE\u0648\u0644\u0646\u0627": "bhoolna",
1071
+ "\u06CC\u0627\u062F": "yaad",
1072
+ "\u0633\u06CC\u06A9\u06BE\u0646\u0627": "seekhna",
1073
+ "\u0633\u06A9\u06BE\u0627\u0646\u0627": "sikhana",
1074
+ "\u067E\u06A9\u0627\u0646\u0627": "pakana",
1075
+ "\u062F\u06BE\u0648\u0646\u0627": "dhona",
1076
+ "\u067E\u06C1\u0646\u0646\u0627": "pehanna",
1077
+ "\u0627\u062A\u0627\u0631\u0646\u0627": "utarna",
1078
+ "\u0628\u06CC\u0686\u0646\u0627": "bechna",
1079
+ "\u062E\u0631\u06CC\u062F\u0646\u0627": "khareedna",
1080
+ "\u0628\u06BE\u06CC\u062C\u0646\u0627": "bhejna",
1081
+ "\u067E\u06C1\u0646\u0686\u0646\u0627": "pohanchna",
1082
+ "\u0646\u06A9\u0644\u0646\u0627": "nikalna",
1083
+ "\u06AF\u0631\u0646\u0627": "girna",
1084
+ "\u0627\u0679\u06BE\u0627\u0646\u0627": "uthana",
1085
+ "\u067E\u06A9\u0691\u0646\u0627": "pakarna",
1086
+ "\u0686\u06BE\u0648\u0691\u0646\u0627": "chhorna",
1087
+ "\u062A\u0648\u0691\u0646\u0627": "torna",
1088
+ "\u062C\u0648\u0691\u0646\u0627": "jorna",
1089
+ "\u06A9\u0627\u0679\u0646\u0627": "katna",
1090
+ // مارنا (to hit) and مرنا (to die) differ by one letter; keeping the long vowel
1091
+ // in "maarna" stops them collapsing into one reverse-direction target.
1092
+ "\u0645\u0627\u0631\u0646\u0627": "maarna",
1093
+ "\u0628\u0686\u0627\u0646\u0627": "bachana",
1094
+ "\u062C\u0644\u0627\u0646\u0627": "jalana",
1095
+ "\u0646\u0627\u0686\u0646\u0627": "nachna",
1096
+ "\u06AF\u0627\u0646\u0627": "gana",
1097
+ "\u0644\u0691\u0646\u0627": "larna",
1098
+ "\u062C\u06CC\u062A\u0646\u0627": "jeetna",
1099
+ "\u06C1\u0627\u0631\u0646\u0627": "haarna",
1100
+ "\u0686\u06BE\u067E\u0627\u0646\u0627": "chhupana",
1101
+ "\u0688\u06BE\u0648\u0646\u0688\u0646\u0627": "dhoondna",
1102
+ "\u0645\u0644\u0627\u0646\u0627": "milana",
1103
+ "\u0628\u062F\u0644\u0646\u0627": "badalna",
1104
+ "\u0631\u06A9\u0646\u0627": "rukna",
1105
+ "\u0627\u0691\u0646\u0627": "urna",
1106
+ "\u062A\u06CC\u0631\u0646\u0627": "tairna",
1107
+ // ---- adverbs and conjunctions ----
1108
+ "\u0641\u0648\u0631\u0627\u064B": "fauran",
1109
+ "\u062F\u0648\u0628\u0627\u0631\u06C1": "dobara",
1110
+ "\u06CC\u0642\u06CC\u0646\u0627\u064B": "yaqeenan",
1111
+ "\u062A\u0642\u0631\u06CC\u0628\u0627\u064B": "taqreeban",
1112
+ "\u0627\u0644\u0628\u062A\u06C1": "albatta",
1113
+ "\u0686\u0648\u0646\u06A9\u06C1": "chunkeh",
1114
+ "\u06A9\u06CC\u0648\u0646\u06A9\u06C1": "kyunkeh",
1115
+ "\u062A\u0627\u06A9\u06C1": "taakeh",
1116
+ "\u0648\u0631\u0646\u06C1": "warna",
1117
+ "\u0628\u0644\u06A9\u06C1": "balkeh",
1118
+ "\u062D\u0627\u0644\u0627\u0646\u06A9\u06C1": "halankeh",
1119
+ "\u0645\u062B\u0644\u0627\u064B": "maslan",
1120
+ "\u0628\u0639\u0636": "baaz",
1121
+ "\u062A\u0645\u0627\u0645": "tamam",
1122
+ "\u067E\u0648\u0631\u0627": "poora",
1123
+ "\u0622\u062F\u06BE\u0627": "aadha",
1124
+ "\u062F\u0648\u0646\u0648\u06BA": "donon",
1125
+ "\u062A\u06CC\u0646\u0648\u06BA": "teenon",
1126
+ "\u0633\u0627\u0631\u0627": "sara",
1127
+ "\u0628\u0627\u0642\u06CC": "baqi",
1128
+ // ---- news and public life, the densest vocabulary in Urdu media ----
1129
+ "\u0633\u06CC\u0627\u0633\u062A": "siyasat",
1130
+ "\u0627\u0644\u06CC\u06A9\u0634\u0646": "election",
1131
+ "\u0648\u0648\u0679": "vote",
1132
+ "\u067E\u0627\u0631\u0679\u06CC": "party",
1133
+ "\u0627\u0633\u0645\u0628\u0644\u06CC": "assembly",
1134
+ "\u0639\u062F\u0627\u0644\u062A": "adalat",
1135
+ "\u0642\u0627\u0646\u0648\u0646": "qanoon",
1136
+ "\u062C\u0631\u0645": "jurm",
1137
+ "\u0641\u0648\u062C\u06CC": "fauji",
1138
+ "\u062C\u0646\u06AF": "jang",
1139
+ "\u0627\u0645\u0646": "aman",
1140
+ "\u0645\u0639\u0627\u06C1\u062F\u06C1": "muahida",
1141
+ "\u0645\u0639\u06CC\u0634\u062A": "maeeshat",
1142
+ "\u062A\u062C\u0627\u0631\u062A": "tijarat",
1143
+ "\u0628\u062C\u0679": "budget",
1144
+ "\u062A\u0631\u0642\u06CC": "taraqqi",
1145
+ "\u0645\u0646\u0635\u0648\u0628\u06C1": "mansooba",
1146
+ "\u0627\u0639\u0644\u0627\u0646": "elaan",
1147
+ "\u0631\u067E\u0648\u0631\u0679": "report",
1148
+ "\u0628\u06CC\u0627\u0646": "bayan",
1149
+ "\u0627\u062C\u0644\u0627\u0633": "ijlas",
1150
+ "\u062F\u0648\u0631\u06C1": "dora",
1151
+ "\u0645\u0644\u0627\u0642\u0627\u062A": "mulaqat",
1152
+ "\u062A\u0642\u0631\u06CC\u0628": "taqreeb",
1153
+ "\u062A\u0642\u0631\u06CC\u0631": "taqreer",
1154
+ // ---- technology ----
1155
+ "\u0688\u06CC\u0679\u0627": "data",
1156
+ "\u0627\u06CC\u067E": "app",
1157
+ "\u067E\u0631\u0648\u06AF\u0631\u0627\u0645": "program",
1158
+ "\u0633\u0633\u0679\u0645": "system",
1159
+ "\u0635\u0627\u0631\u0641": "sarif",
1160
+ "\u0641\u0627\u0626\u0644": "file",
1161
+ "\u0679\u06CC\u06A9\u0646\u0627\u0644\u0648\u062C\u06CC": "technology",
1162
+ // ---- education ----
1163
+ "\u062C\u0645\u0627\u0639\u062A": "jamaat",
1164
+ "\u06A9\u0644\u0627\u0633": "class",
1165
+ "\u067E\u0631\u0686\u06C1": "parcha",
1166
+ "\u0646\u0645\u0628\u0631": "number",
1167
+ "\u0688\u06AF\u0631\u06CC": "degree",
1168
+ "\u0644\u0627\u0626\u0628\u0631\u06CC\u0631\u06CC": "library",
1169
+ "\u062A\u062D\u0642\u06CC\u0642": "tehqeeq",
1170
+ "\u0645\u0642\u0627\u0644\u06C1": "maqala",
1171
+ // ---- health ----
1172
+ "\u0628\u062E\u0627\u0631": "bukhar",
1173
+ "\u062F\u0631\u062F": "dard",
1174
+ "\u0632\u062E\u0645": "zakhm",
1175
+ "\u0639\u0644\u0627\u062C": "ilaj",
1176
+ "\u062E\u0648\u0646": "khoon",
1177
+ "\u06C1\u0688\u06CC": "haddi",
1178
+ "\u067E\u06CC\u0679": "pet",
1179
+ "\u06AF\u0644\u0627": "gala",
1180
+ // ---- colours ----
1181
+ "\u0633\u0641\u06CC\u062F": "safaid",
1182
+ "\u06A9\u0627\u0644\u0627": "kala",
1183
+ "\u0633\u0631\u062E": "surkh",
1184
+ "\u0646\u06CC\u0644\u0627": "neela",
1185
+ "\u06C1\u0631\u0627": "hara",
1186
+ "\u067E\u06CC\u0644\u0627": "peela",
1187
+ "\u0628\u06BE\u0648\u0631\u0627": "bhura",
1188
+ "\u06AF\u0644\u0627\u0628\u06CC": "gulabi",
1189
+ "\u0633\u0646\u06C1\u0631\u06CC": "sunehri",
1190
+ // ---- animals ----
1191
+ "\u06A9\u062A\u0627": "kutta",
1192
+ "\u0628\u0644\u06CC": "billi",
1193
+ "\u06AF\u06BE\u0648\u0691\u0627": "ghora",
1194
+ "\u06AF\u0627\u0626\u06D2": "gaye",
1195
+ "\u0628\u06A9\u0631\u06CC": "bakri",
1196
+ "\u0628\u06BE\u06CC\u0646\u0633": "bhains",
1197
+ "\u0634\u06CC\u0631": "sheer",
1198
+ "\u06C1\u0627\u062A\u06BE\u06CC": "hathi",
1199
+ "\u0627\u0648\u0646\u0679": "oont",
1200
+ "\u0628\u0646\u062F\u0631": "bandar",
1201
+ "\u0686\u0648\u06C1\u0627": "chooha",
1202
+ "\u067E\u0631\u0646\u062F\u06C1": "parinda",
1203
+ "\u06A9\u0648\u0627": "kawa",
1204
+ "\u0637\u0648\u0637\u0627": "tota",
1205
+ "\u0633\u0627\u0646\u067E": "saanp",
1206
+ // ---- extended family ----
1207
+ "\u0686\u0686\u0627": "chacha",
1208
+ "\u0645\u0627\u0645\u0648\u06BA": "mamoon",
1209
+ "\u062E\u0627\u0644\u06C1": "khala",
1210
+ "\u067E\u06BE\u0648\u067E\u06BE\u06CC": "phupi",
1211
+ "\u062F\u0627\u062F\u0627": "dada",
1212
+ "\u062F\u0627\u062F\u06CC": "dadi",
1213
+ "\u0646\u0627\u0646\u0627": "nana",
1214
+ "\u0646\u0627\u0646\u06CC": "nani",
1215
+ "\u0631\u0634\u062A\u06C1": "rishta",
1216
+ "\u062E\u0627\u0646\u062F\u0627\u0646": "khandan",
1217
+ "\u0645\u06C1\u0645\u0627\u0646": "mehman",
1218
+ // ---- food ----
1219
+ "\u06A9\u06BE\u06CC\u0631": "kheer",
1220
+ "\u062D\u0644\u0648\u06C1": "halwa",
1221
+ "\u0628\u0631\u06CC\u0627\u0646\u06CC": "biryani",
1222
+ "\u06A9\u0628\u0627\u0628": "kabab",
1223
+ "\u0633\u0627\u0644\u0646": "salan",
1224
+ "\u062F\u0627\u0644": "daal",
1225
+ "\u0622\u0679\u0627": "aata",
1226
+ "\u0645\u06A9\u06BE\u0646": "makhan",
1227
+ "\u062F\u06C1\u06CC": "dahi",
1228
+ "\u0634\u06C1\u062F": "shehad",
1229
+ "\u0645\u0631\u0686": "mirch",
1230
+ "\u06C1\u0644\u062F\u06CC": "haldi",
1231
+ "\u0644\u06C1\u0633\u0646": "lehsun",
1232
+ "\u067E\u06CC\u0627\u0632": "pyaz",
1233
+ "\u0679\u0645\u0627\u0679\u0631": "tamatar",
1234
+ "\u0622\u0644\u0648": "aloo",
1235
+ "\u06AF\u0627\u062C\u0631": "gajar",
1236
+ "\u062A\u0631\u0628\u0648\u0632": "tarbooz",
1237
+ "\u0627\u0646\u0627\u0631": "anar",
1238
+ "\u06A9\u06BE\u062C\u0648\u0631": "khajoor",
1239
+ "\u0628\u0627\u062F\u0627\u0645": "badam",
1240
+ // ---- places on the map ----
1241
+ "\u06A9\u0631\u0627\u0686\u06CC": "karachi",
1242
+ "\u0644\u0627\u06C1\u0648\u0631": "lahore",
1243
+ "\u067E\u0634\u0627\u0648\u0631": "peshawar",
1244
+ "\u06A9\u0648\u0626\u0679\u06C1": "quetta",
1245
+ "\u0645\u0644\u062A\u0627\u0646": "multan",
1246
+ "\u0631\u0627\u0648\u0644\u067E\u0646\u0688\u06CC": "rawalpindi",
1247
+ "\u0633\u06CC\u0627\u0644\u06A9\u0648\u0679": "sialkot",
1248
+ "\u0628\u06BE\u0627\u0631\u062A": "bharat",
1249
+ "\u06C1\u0646\u062F\u0648\u0633\u062A\u0627\u0646": "hindustan",
1250
+ "\u0686\u06CC\u0646": "cheen",
1251
+ "\u0627\u0645\u0631\u06CC\u06A9\u06C1": "amreeka",
1252
+ "\u0628\u0631\u0637\u0627\u0646\u06CC\u06C1": "bartania",
1253
+ "\u0627\u06CC\u0631\u0627\u0646": "iran",
1254
+ "\u0627\u0641\u063A\u0627\u0646\u0633\u062A\u0627\u0646": "afghanistan",
1255
+ "\u06A9\u0634\u0645\u06CC\u0631": "kashmir",
1256
+ "\u067E\u0646\u062C\u0627\u0628": "punjab",
1257
+ "\u0633\u0646\u062F\u06BE": "sindh",
1258
+ "\u0628\u0644\u0648\u0686\u0633\u062A\u0627\u0646": "balochistan",
1064
1259
  // ---- names that appear constantly in Urdu content ----
1065
1260
  "\u0645\u062D\u0645\u062F": "muhammad",
1066
1261
  "\u0627\u062D\u0645\u062F": "ahmed",
@@ -1231,6 +1426,15 @@ function romanizeWord(word) {
1231
1426
  pieces.push({ text: "a", vowel: true });
1232
1427
  continue;
1233
1428
  }
1429
+ if (ch === "\u06CC" && chars[i + 1] === "\u06BA" && i + 1 === chars.length - 1) {
1430
+ pieces.push({ text: "ein", vowel: true });
1431
+ i++;
1432
+ continue;
1433
+ }
1434
+ if (ch === "\u06CC" && !last) {
1435
+ pieces.push({ text: "e", vowel: true });
1436
+ continue;
1437
+ }
1234
1438
  pieces.push({ text: LETTERS[ch] ?? ch, vowel: VOWEL_LETTERS.has(ch) });
1235
1439
  }
1236
1440
  if (pieces.length > 2 && !pieces[0].vowel && !pieces[1].vowel) {