urdu-text-utils 0.1.7 → 0.1.9

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/dist/index.d.cts CHANGED
@@ -398,4 +398,89 @@ declare function formatUrduDate(date: Date | string | number, pattern?: string,
398
398
  */
399
399
  declare function timeAgoUrdu(date: Date | string | number, relativeTo?: Date | string | number, options?: TimeAgoOptions): string;
400
400
 
401
- export { type DigitStyle, type FormatUrduDateOptions, type IsUrduOptions, type NormalizeOptions, type SearchOptions, type SearchResult, type SlugOptions, type SortOptions, type SplitSentenceOptions, type TimeAgoOptions, URDU_MONTHS_GREGORIAN, URDU_MONTHS_HIJRI, URDU_STOP_WORDS, URDU_WEEKDAYS, type UrduStats, analyzeUrdu, compareUrdu, convertNumbers, countSentences, countWords, editDistance, filterStopWords, foldUrdu, formatUrduDate, getUrduMonthName, getUrduWeekdayName, hasUrduSpecificLetters, highlightUrdu, isStopWord, isUrdu, normalizeUrdu, numberToUrduWords, parseUrduNumber, removeDiacritics, removeStopWords, romanToUrdu, romanize, searchUrdu, searchUrduRanked, sortUrdu, splitSentences, splitWords, timeAgoUrdu, toArabicIndicDigits, toEnglishDigits, toUrduDigits, urduRatio, urduSlug };
401
+ /**
402
+ * Canonical Urdu prefixes (سابقے) ordered by descending length.
403
+ */
404
+ declare const URDU_PREFIXES: readonly ["غیر", "خود", "اہل", "بے", "نا", "لا", "بد", "کم", "ان", "ہم", "با", "پُر"];
405
+ /**
406
+ * Canonical Urdu suffixes (لاحقے) ordered by descending length.
407
+ */
408
+ declare const URDU_SUFFIXES: readonly ["یںگے", "ینگے", "ےگا", "ےگی", "ینگی", "داری", "گاری", "کاری", "سازی", "بازی", "مندی", "ترین", "ستان", "خانہ", "نامہ", "جات", "گان", "دار", "گار", "کار", "ساز", "باز", "مند", "ناک", "وار", "دان", "زار", "یت", "پن", "ائی", "تر", "یاں", "ئیں", "ؤں", "یوں", "وں", "یں", "ات", "ہا", "ین", "تیں", "تا", "تی", "تے", "نا"];
409
+ interface StemmerOptions {
410
+ /**
411
+ * Whether to strip canonical Urdu prefixes (e.g. بے-, نا-, غیر-, لا-).
412
+ * @default true
413
+ */
414
+ stripPrefixes?: boolean;
415
+ /**
416
+ * Whether to strip canonical Urdu suffixes (e.g. -وں, -یں, -یاں, -دار, -تے).
417
+ * @default true
418
+ */
419
+ stripSuffixes?: boolean;
420
+ /**
421
+ * Minimum character length of the remaining root word.
422
+ * Prevents over-stemming of short roots.
423
+ * @default 2
424
+ */
425
+ minStemLength?: number;
426
+ /**
427
+ * Custom list of prefixes to strip in addition to or in place of defaults.
428
+ */
429
+ customPrefixes?: string[];
430
+ /**
431
+ * Custom list of suffixes to strip in addition to or in place of defaults.
432
+ */
433
+ customSuffixes?: string[];
434
+ /**
435
+ * Map of exact exception words to their canonical stems.
436
+ */
437
+ exceptions?: Record<string, string>;
438
+ }
439
+ interface AffixBreakdown {
440
+ /** The stripped prefix, if any */
441
+ prefix?: string;
442
+ /** The stemmed base root */
443
+ stem: string;
444
+ /** The stripped suffix, if any */
445
+ suffix?: string;
446
+ }
447
+ /**
448
+ * Analyzes an Urdu word and extracts its prefix, stem, and suffix.
449
+ *
450
+ * @example
451
+ * getAffixes("بےوقوف")
452
+ * // { prefix: "بے", stem: "وقوف" }
453
+ *
454
+ * getAffixes("کتابیں")
455
+ * // { stem: "کتاب", suffix: "یں" }
456
+ *
457
+ * getAffixes("نااہلی")
458
+ * // { prefix: "نا", stem: "اہل", suffix: "ی" }
459
+ */
460
+ declare function getAffixes(input: string, options?: StemmerOptions): AffixBreakdown;
461
+ /**
462
+ * Reduces an Urdu word to its morphological root/stem by stripping common prefixes,
463
+ * plurals, tense inflections, and adjectival/nominal suffixes.
464
+ *
465
+ * @example
466
+ * stemUrdu("کتابیں") // "کتاب"
467
+ * stemUrdu("لڑکیاں") // "لڑکی"
468
+ * stemUrdu("دعاؤں") // "دعا"
469
+ * stemUrdu("بےوقوف") // "وقوف"
470
+ * stemUrdu("نااہل") // "اہل"
471
+ * stemUrdu("خوبصورت ترین") // "خوبصورت"
472
+ */
473
+ declare function stemUrdu(word: string, options?: StemmerOptions): string;
474
+ /**
475
+ * Stems all words within a block of Urdu text while preserving punctuation,
476
+ * whitespaces, and document formatting.
477
+ *
478
+ * Ideal for search engine indexing, TF-IDF scoring, and AI/LLM embeddings preprocessing.
479
+ *
480
+ * @example
481
+ * stemUrduText("طلباء کتابیں پڑھتے ہیں اور کہانیاں سنتے ہیں۔")
482
+ * // "طلباء کتاب پڑھ ہیں اور کہانی سن ہیں۔"
483
+ */
484
+ declare function stemUrduText(text: string, options?: StemmerOptions): string;
485
+
486
+ export { type AffixBreakdown, type DigitStyle, type FormatUrduDateOptions, type IsUrduOptions, type NormalizeOptions, type SearchOptions, type SearchResult, type SlugOptions, type SortOptions, type SplitSentenceOptions, type StemmerOptions, type TimeAgoOptions, URDU_MONTHS_GREGORIAN, URDU_MONTHS_HIJRI, URDU_PREFIXES, URDU_STOP_WORDS, URDU_SUFFIXES, URDU_WEEKDAYS, type UrduStats, analyzeUrdu, compareUrdu, convertNumbers, countSentences, countWords, editDistance, filterStopWords, foldUrdu, formatUrduDate, getAffixes, getUrduMonthName, getUrduWeekdayName, hasUrduSpecificLetters, highlightUrdu, isStopWord, isUrdu, normalizeUrdu, numberToUrduWords, parseUrduNumber, removeDiacritics, removeStopWords, romanToUrdu, romanize, searchUrdu, searchUrduRanked, sortUrdu, splitSentences, splitWords, stemUrdu, stemUrduText, timeAgoUrdu, toArabicIndicDigits, toEnglishDigits, toUrduDigits, urduRatio, urduSlug };
package/dist/index.d.ts CHANGED
@@ -398,4 +398,89 @@ declare function formatUrduDate(date: Date | string | number, pattern?: string,
398
398
  */
399
399
  declare function timeAgoUrdu(date: Date | string | number, relativeTo?: Date | string | number, options?: TimeAgoOptions): string;
400
400
 
401
- export { type DigitStyle, type FormatUrduDateOptions, type IsUrduOptions, type NormalizeOptions, type SearchOptions, type SearchResult, type SlugOptions, type SortOptions, type SplitSentenceOptions, type TimeAgoOptions, URDU_MONTHS_GREGORIAN, URDU_MONTHS_HIJRI, URDU_STOP_WORDS, URDU_WEEKDAYS, type UrduStats, analyzeUrdu, compareUrdu, convertNumbers, countSentences, countWords, editDistance, filterStopWords, foldUrdu, formatUrduDate, getUrduMonthName, getUrduWeekdayName, hasUrduSpecificLetters, highlightUrdu, isStopWord, isUrdu, normalizeUrdu, numberToUrduWords, parseUrduNumber, removeDiacritics, removeStopWords, romanToUrdu, romanize, searchUrdu, searchUrduRanked, sortUrdu, splitSentences, splitWords, timeAgoUrdu, toArabicIndicDigits, toEnglishDigits, toUrduDigits, urduRatio, urduSlug };
401
+ /**
402
+ * Canonical Urdu prefixes (سابقے) ordered by descending length.
403
+ */
404
+ declare const URDU_PREFIXES: readonly ["غیر", "خود", "اہل", "بے", "نا", "لا", "بد", "کم", "ان", "ہم", "با", "پُر"];
405
+ /**
406
+ * Canonical Urdu suffixes (لاحقے) ordered by descending length.
407
+ */
408
+ declare const URDU_SUFFIXES: readonly ["یںگے", "ینگے", "ےگا", "ےگی", "ینگی", "داری", "گاری", "کاری", "سازی", "بازی", "مندی", "ترین", "ستان", "خانہ", "نامہ", "جات", "گان", "دار", "گار", "کار", "ساز", "باز", "مند", "ناک", "وار", "دان", "زار", "یت", "پن", "ائی", "تر", "یاں", "ئیں", "ؤں", "یوں", "وں", "یں", "ات", "ہا", "ین", "تیں", "تا", "تی", "تے", "نا"];
409
+ interface StemmerOptions {
410
+ /**
411
+ * Whether to strip canonical Urdu prefixes (e.g. بے-, نا-, غیر-, لا-).
412
+ * @default true
413
+ */
414
+ stripPrefixes?: boolean;
415
+ /**
416
+ * Whether to strip canonical Urdu suffixes (e.g. -وں, -یں, -یاں, -دار, -تے).
417
+ * @default true
418
+ */
419
+ stripSuffixes?: boolean;
420
+ /**
421
+ * Minimum character length of the remaining root word.
422
+ * Prevents over-stemming of short roots.
423
+ * @default 2
424
+ */
425
+ minStemLength?: number;
426
+ /**
427
+ * Custom list of prefixes to strip in addition to or in place of defaults.
428
+ */
429
+ customPrefixes?: string[];
430
+ /**
431
+ * Custom list of suffixes to strip in addition to or in place of defaults.
432
+ */
433
+ customSuffixes?: string[];
434
+ /**
435
+ * Map of exact exception words to their canonical stems.
436
+ */
437
+ exceptions?: Record<string, string>;
438
+ }
439
+ interface AffixBreakdown {
440
+ /** The stripped prefix, if any */
441
+ prefix?: string;
442
+ /** The stemmed base root */
443
+ stem: string;
444
+ /** The stripped suffix, if any */
445
+ suffix?: string;
446
+ }
447
+ /**
448
+ * Analyzes an Urdu word and extracts its prefix, stem, and suffix.
449
+ *
450
+ * @example
451
+ * getAffixes("بےوقوف")
452
+ * // { prefix: "بے", stem: "وقوف" }
453
+ *
454
+ * getAffixes("کتابیں")
455
+ * // { stem: "کتاب", suffix: "یں" }
456
+ *
457
+ * getAffixes("نااہلی")
458
+ * // { prefix: "نا", stem: "اہل", suffix: "ی" }
459
+ */
460
+ declare function getAffixes(input: string, options?: StemmerOptions): AffixBreakdown;
461
+ /**
462
+ * Reduces an Urdu word to its morphological root/stem by stripping common prefixes,
463
+ * plurals, tense inflections, and adjectival/nominal suffixes.
464
+ *
465
+ * @example
466
+ * stemUrdu("کتابیں") // "کتاب"
467
+ * stemUrdu("لڑکیاں") // "لڑکی"
468
+ * stemUrdu("دعاؤں") // "دعا"
469
+ * stemUrdu("بےوقوف") // "وقوف"
470
+ * stemUrdu("نااہل") // "اہل"
471
+ * stemUrdu("خوبصورت ترین") // "خوبصورت"
472
+ */
473
+ declare function stemUrdu(word: string, options?: StemmerOptions): string;
474
+ /**
475
+ * Stems all words within a block of Urdu text while preserving punctuation,
476
+ * whitespaces, and document formatting.
477
+ *
478
+ * Ideal for search engine indexing, TF-IDF scoring, and AI/LLM embeddings preprocessing.
479
+ *
480
+ * @example
481
+ * stemUrduText("طلباء کتابیں پڑھتے ہیں اور کہانیاں سنتے ہیں۔")
482
+ * // "طلباء کتاب پڑھ ہیں اور کہانی سن ہیں۔"
483
+ */
484
+ declare function stemUrduText(text: string, options?: StemmerOptions): string;
485
+
486
+ export { type AffixBreakdown, type DigitStyle, type FormatUrduDateOptions, type IsUrduOptions, type NormalizeOptions, type SearchOptions, type SearchResult, type SlugOptions, type SortOptions, type SplitSentenceOptions, type StemmerOptions, type TimeAgoOptions, URDU_MONTHS_GREGORIAN, URDU_MONTHS_HIJRI, URDU_PREFIXES, URDU_STOP_WORDS, URDU_SUFFIXES, URDU_WEEKDAYS, type UrduStats, analyzeUrdu, compareUrdu, convertNumbers, countSentences, countWords, editDistance, filterStopWords, foldUrdu, formatUrduDate, getAffixes, getUrduMonthName, getUrduWeekdayName, hasUrduSpecificLetters, highlightUrdu, isStopWord, isUrdu, normalizeUrdu, numberToUrduWords, parseUrduNumber, removeDiacritics, removeStopWords, romanToUrdu, romanize, searchUrdu, searchUrduRanked, sortUrdu, splitSentences, splitWords, stemUrdu, stemUrduText, timeAgoUrdu, toArabicIndicDigits, toEnglishDigits, toUrduDigits, urduRatio, urduSlug };