| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Jazzy example source code file (

This example Jazzy source code file ( is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Jazzy tags/keywords

bufferedreader, file, file, filereader, io, iterator, spellchecker, spellchecker, spellcheckexample2, spellcheckexample2, spellchecklistener, spelldictionaryhashmap, string, string, stringwordtokenizer, util

The Jazzy source code

Jazzy - a Java library for Spell Checking
Copyright (C) 2001 Mindaugas Idzelis
Full text of license can be found in LICENSE.txt

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
package com.swabunga.spell.examples;

import com.swabunga.spell.engine.SpellDictionary;
import com.swabunga.spell.engine.SpellDictionaryHashMap;
import com.swabunga.spell.event.SpellCheckEvent;
import com.swabunga.spell.event.SpellCheckListener;
import com.swabunga.spell.event.SpellChecker;
import com.swabunga.spell.event.StringWordTokenizer;

import java.util.Iterator;
import java.util.List;

/** This class shows an example of how to use the spell checking capability.
 * @author Jason Height (
public class SpellCheckExample2 implements SpellCheckListener {

  private static String dictFile = "dict/english.0";
  private SpellChecker spellCheck = null;

  public SpellCheckExample2(String phoneticFileName) {
    try {

      BufferedReader in = new BufferedReader(new FileReader("example2.txt"));
      File phonetic = null;
      if (phoneticFileName != null)
        phonetic = new File(phoneticFileName);

      SpellDictionary dictionary = new SpellDictionaryHashMap(new File(dictFile), phonetic);
      spellCheck = new SpellChecker(dictionary);

      while (true) {
        String line = in.readLine();

        if (line == null || line.length() == -1)

        spellCheck.checkSpelling(new StringWordTokenizer(line));

    } catch (Exception e) {

  public void spellingError(SpellCheckEvent event) {
    List suggestions = event.getSuggestions();
    if (suggestions.size() > 0) {
      System.out.println("MISSPELT WORD: " + event.getInvalidWord());
      for (Iterator suggestedWord = suggestions.iterator(); suggestedWord.hasNext();) {
        System.out.println("\tSuggested Word: " +;
    } else {
      System.out.println("MISSPELT WORD: " + event.getInvalidWord());
      System.out.println("\tNo suggestions");


  public static void main(String[] args) {

    System.out.println("Running spell check against DoubleMeta");
    new SpellCheckExample2(null);

    System.out.println("\n\nRunning spell check against GenericTransformator");
    new SpellCheckExample2("dict/phonet.en");

Other Jazzy examples (source code examples)

Here is a short list of links related to this Jazzy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.