Coder Social home page Coder Social logo

doersino / spell Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 2.32 MB

Haskell implementation of Peter Norvig's spelling corrector.

Home Page: https://excessivelyadequate.com/posts/spell.html

License: MIT License

Haskell 100.00%
haskell spell-check spelling cabal-package peter-norvig

spell's Introduction

Spelling Corrector in Haskell

Build Status

Haskell implementation (outlined in a blog post) of the simple spelling corrector spell.py by Peter Norvig, which he describes in detail in the excellent essay "How to Write a Spelling Corrector". Any credit should go to him!

Setup

git clone https://github.com/doersino/spell.git
cd spell
cabal sandbox init
cabal install

If you prefer using Stack, run stack install instead of that Cabal nonsense.

Usage

For taking a first look, run cabal repl or stack ghci. Some examples:

*Spell> correction "scandinaiva"
"scandinavia"
*Spell> correction "inndeed"
"indeed"
*Spell> correction "photograf"
"photograph"

Notes

  • Performance is somewhat lacking. If you manage to significantly improve performance or reduce dependencies without major structural modifications (or just add more unit tests), please don't hesitate before filing an issue or sending a pull request.
  • Haskell is lazy, so it won't parse the big.txt file until you call correction. As a result, the first correction might take a few seconds -- subsequent ones will be faster.
  • If you want, you can use this Cabal package as a dependency in your project (of course, there are better spell checkers). Since it's not on Hackage, run cabal sandbox add-source <path to local clone of spell package> in your project directory before adding spell to the build-depends list in your .cabal file.
  • In case you modify or replace big.txt: the changes may not take effect until you re-run cabal install. That's because it's listed in the data-files field of spell.cabal, enabling Cabal to provide an absolute path to big.txt at runtime, which is helpful if you want to use the spell package as a library or from any path on your system.
  • If you want to be able to run the included Hspec unit tests, replace the cabal install step above with cabal install --enable-tests. Run the tests by means of cabal test or, for incremental and more colorful output, cabal exec -- runhaskell -isrc -itest test/Spec.hs. If you're using Stack, simply run stack test.
  • Run cabal haddock or stack haddock to generate documentation.

spell's People

Contributors

doersino avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.