dart_phonetics 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

Dart Phonetics #

Build Status Pub package Dartdoc reference Project license

A collection of phonetic algorithms for Dart and Flutter. These algorithms help find words or names that sound similar by generating an encoding that can be compared or indexed for fuzzy searching.

Algorithms Implemented #

  • Soundex - A highly configurable implementation of the Soundex algorithm. There are better algorithms available, but this algorithm is classic, and is required when analyzing American surnames in genealogy or census data.
  • Refined Soundex - The refined soundex is a variation that is better for applications such as spell checking. It uses a mapping that aims to be more precise and does not truncate to 4 characters by default.
  • NYSIIS - An implementation of the New York State Identification and Intelligence System as documented by the USDA SRS system design report. The modified version of the algorithm is best suited for encoding names.
  • Double Metaphone - The metaphone series of algorithms apply "expert rules" based on inconsistencies in the English language in attempt to acheive greater precision (fewer results that are closer in phonetic sound).

Work In Progress #

This project is a work in progress that is being developed because I need these algorithms for another project. I'll spend time implementing more phonetic algorithms depending on demand, need, or community interest.

Please consider sponsoring me if you are using this library, need help, or if you want to discuss specific algorithms or need a special encoding algorithm implemented.

Other Implementations #

The Wikipedia Phonetic Algorithm page provides a good basic background. There are several other libraries (written in other languages) that may be useful for reference to those interested in exploring various Phonetic Encoding algorithms for various purposes. These references are also useful because of the test cases they contain (which capture edge cases that are useful to analyze and compare).

0.2.0 #

  • NYSIIS implemented (original and modified).
  • Misc fixes and improvements.

0.1.0 #

  • Double Metaphone implemented.
  • Configurable Soundex implemented.
  • Refined Soundex implemented.


import 'package:dart_phonetics/dart_phonetics.dart';

void _printResult(PhoneticEncoder encoder, String input) {
  final encoding = encoder.encode(input);
      '${encoder?.runtimeType?.toString()} - "$input"\n  primary = ${encoding?.primary}\n  alternate = ${encoding?.alternates}\n');

void main() {
  final inputString = 'Cardillo-Ashcroft';

  final soundex = Soundex.americanEncoder;
  _printResult(soundex, inputString);

  final customSoundex = Soundex.fromMapping(Soundex.americanMapping,
      maxLength: null, paddingEnabled: false, ignoreHW: false);
  _printResult(customSoundex, inputString);

  final refinedSoundex = RefinedSoundex.defaultEncoder;
  _printResult(refinedSoundex, inputString);

  final nysiisOriginal = Nysiis.originalEncoder;
  _printResult(nysiisOriginal, inputString);

  final nysiisModified =
      Nysiis.withOptions(maxLength: null, enableModified: true);
  _printResult(nysiisModified, inputString);

  final doubleMetaphone = DoubleMetaphone.withMaxLength(12);
  _printResult(doubleMetaphone, inputString);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dart_phonetics: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dart_phonetics/dart_phonetics.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
charcode ^1.1.2 1.1.3
Dev dependencies
pedantic ^1.8.0+1
test ^1.9.4