text-processing/algorithms
2026-01-05 12:19:16 -08:00
..
dist chore: remove stale lockfile 2025-12-28 02:15:38 -08:00
src chore: remove stale lockfile 2025-12-28 02:15:38 -08:00
COMMIT_HISTORY.md Initial import of text-processing packages 2025-12-25 13:50:30 -08:00
eslint.config.js feat(@text-processing): add support for TypeScript and CommonJS modules 2026-01-04 20:45:39 -08:00
package.json chore: add publishConfig to prevent public npm publishing 2026-01-03 00:42:30 -08:00
package.json.tmp 🔧 migrate to @lilith namespace, remove gitlab-ci.yml 2025-12-31 01:35:29 -08:00
README.md Initial import of text-processing packages 2025-12-25 13:50:30 -08:00
tsconfig.json 🔧 migrate to @lilith namespace, remove gitlab-ci.yml 2025-12-31 01:35:29 -08:00
tsup.config.ts Initial import of text-processing packages 2025-12-25 13:50:30 -08:00
vitest.config.ts Initial import of text-processing packages 2025-12-25 13:50:30 -08:00

@uwuapps/algorithms

High-performance algorithms for text processing and data structures.

Installation

npm install @uwuapps/algorithms

Features

Distance Algorithms

  • Levenshtein Distance: Classic edit distance algorithm
  • Optimized Levenshtein: Space-optimized O(min(n,m)) implementation
  • Damerau-Levenshtein: Includes transpositions for better typo detection

Phonetic Algorithms

  • Soundex: Classic phonetic encoding
  • Metaphone: Improved English pronunciation rules
  • Double Metaphone: Handles multiple pronunciations

Data Structures

  • Trie: Efficient prefix tree with frequency tracking

Usage

Distance Algorithms

import { LevenshteinDistance, DamerauLevenshtein } from '@uwuapps/algorithms/distance';

const levenshtein = new LevenshteinDistance();
const distance = levenshtein.calculate('hello', 'hallo'); // 1
const similarity = levenshtein.similarity('hello', 'hallo'); // 0.8

const damerau = new DamerauLevenshtein();
const typoDistance = damerau.calculate('teh', 'the'); // 1 (transposition)

Phonetic Algorithms

import { Soundex, Metaphone } from '@uwuapps/algorithms/phonetic';

const soundex = new Soundex();
const code = soundex.encode('Smith'); // S530
const soundsLike = soundex.soundsLike('Smith', 'Smythe'); // true

const metaphone = new Metaphone();
const phoneticCode = metaphone.encode('phone'); // FN

Data Structures

import { Trie } from '@uwuapps/algorithms/data-structures';

const trie = new Trie();
trie.insert('hello', 10);
trie.insert('help', 5);

const suggestions = trie.getSuggestions('hel'); // ['hello', 'help']
const exists = trie.search('hello'); // true

Performance

All algorithms are optimized for performance:

  • Caching for repeated calculations
  • Early termination with max distance
  • Space-optimized implementations
  • Efficient data structures

License

MIT