spell_checker 0.1.2+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

spell_checker #

A simple spell checker implementation in Dart. For now it only finds the single words from a given dictionary. Algorithm is different than Peter Norvig's implementation (http://norvig.com/spell-correct.html). This implementation is more complicated but probably much faster (finds several thousands matches in a second). It uses dynamic decoding over a simple trie generated from the dictionary. System finds words with a distance to the input. Deletions, insertions, substitutions and transpositions are supported.

import 'package:dart_spell/dart_spell.dart';

...
// optional distance parameter. Default is 1.0
var checker = new SingleWordSpellChecker(distance:1.0);

var dictionary = ["apple", "apples", "pear", "ear"];
checker.addWords(dictionary);	

List<Result> matches = checker.find("apple");
print(matches);

Output:
[apple:0.0, apples:1.0]

##TODO

  • Add less substitution penalty for near keys in keyboard layout.
  • Add language model support so that it gives more logical suggestions.
  • Add multi word spell suggestion with space and out of vocabulary word handling.

0.1.2+2 #

Add example, comments, format to improve health

0.1.2+1 #

Change map to splaymap to avoid final sort

0.1.2 #

Remove comparable from Result

0.1.1+8 #

Update to effective dart and format with dartfmt

0.1.1+7 #

Make addChar private

0.1.1+6 #

Update addChar function header

0.1.1+5 #

Make root private to Search, make addChar iterative instead of recursive

0.1.1+4 #

Swap out List for Iterable in addWords

0.1.1+3 #

Remove uses of new to match modern dart

0.1.1+2 #

Remove unncessary hashing/index code

0.1.1+1 #

Dart 2.0 clean-up

0.1.1 #

Dart 1.0 clean-up.

0.1.0 #

Initial release

example/example.dart

import 'package:spell_checker/spell_checker.dart';

void main() {
  final checker = SingleWordSpellChecker(distance: 1.0);
  checker.addWords(['apple', 'apply', 'applesauce', 'applause', 'pear']);
  final str = 'aple';
  final findList = checker.find(str);
  print(findList);
}

Use this package as a library

1. Depend on it

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


dependencies:
  spell_checker: ^0.1.2+2

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:spell_checker/spell_checker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
16
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14

Health suggestions

Format lib/utilities.dart.

Run dartfmt to format lib/utilities.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
effective_dart ^1.2.1
list_english_words ^0.1.1
test ^1.14.2