Skip to content

hfst/hfst-ospell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

85edd77 · Feb 20, 2024
Apr 23, 2014
Sep 30, 2015
Jun 4, 2015
Jan 10, 2017
Sep 29, 2022
Apr 13, 2016
Jan 10, 2017
Mar 30, 2017
Oct 6, 2022
Apr 23, 2014
Oct 15, 2018
Oct 15, 2018
Apr 23, 2014
Feb 3, 2011
Oct 4, 2022
Oct 15, 2018
Mar 9, 2023
Jun 16, 2023
Oct 18, 2017
Oct 18, 2017
Oct 18, 2017
Jul 5, 2012
Feb 3, 2011
Feb 20, 2024
Apr 23, 2014
Feb 17, 2024
Jul 3, 2022
May 25, 2020
May 25, 2020
Nov 29, 2016
May 21, 2013
Oct 18, 2017
Oct 18, 2017
Oct 18, 2017
Oct 18, 2017
Oct 18, 2017
Oct 18, 2017
Oct 4, 2022
Nov 25, 2021
Nov 5, 2021
Jan 30, 2022
Oct 18, 2017
Oct 4, 2022
May 26, 2016
Jun 19, 2014

Repository files navigation

Hfst-ospell library and toy commandline tester

This is a minimal hfst optimized lookup format based spell checker library and a demonstrational implementation of command line based spell checker. The library is licenced under Apache licence version 2, other licences can be obtained from University of Helsinki.

Build Status

Dependencies

  • libxml++2
  • libarchive

Debian packages for dependencies

  • libxml++2-dev
  • libarchive-dev

Usage

Usage in external programs:

#include <ospell.h>

and compile your project with:

$(pkg-config --cflags hfstospell)

and link with:

$(pkg-config --libs hfstospell)

Programming examples

The library lives in a namespace called hfst_ospell. Pass (weighted!) Transducer pointers to the Speller constructor, eg.:

FILE * error_source = fopen(error_filename, "r");
FILE * lexicon_file = fopen(lexicon_filename, "r");
hfst_ospell::Transducer * error;
hfst_ospell::Transducer * lexicon;
try {
    error = new hfst_ospell::Transducer(error_source);
    lexicon = new hfst_ospell::Transducer(lexicon_file);
} catch (hfst_ospell::TransducerParsingException& e) {
        /* problem with transducer file, usually completely
        different type of file - there's no magic number
        in the header to check for this */
    }
hfst_ospell::Speller * speller;
try {
    speller = new hfst_ospell::Speller(error, lexicon);
} catch (hfst_ospell::AlphabetTranslationException& e) {
    /* problem with translating between the two alphabets */
}

And use the functions:

// returns true if line is found in lexicon
bool hfst_ospell::Speller::check(char * line);

// CorrectionQueue is a priority queue, sorted by weight
hfst_ospell::CorrectionQueue hfst_ospell::Speller::correct(char * line);

to communicate with it. See main.cc for a concrete usage example.

Command-line tool

Main.cc provides a demo utility with the following help message:

Usage: hfst-ospell [OPTIONS] ERRORSOURCE LEXICON
Run a composition of ERRORSOURCE and LEXICON on standard input and
print corrected output

  -h, --help                  Print this help message
  -V, --version               Print version information
  -v, --verbose               Be verbose
  -q, --quiet                 Don't be verbose (default)
  -s, --silent                Same as quiet


Report bugs to hfst-bugs@ling.helsinki.fi

Use in real-world applications

The HFST based spellers can be used in real applications with help of voikko. Voikko in turn can be used with enchant, libreoffice, and firefox.