pt.tumba.spell
Class Aspell

java.lang.Object
  extended by pt.tumba.spell.Aspell

public final class Aspell
extends java.lang.Object

This is a wrapper around the command aspell (version .33.7.1-alpha) with its output reformated so that it can be compared with that of JaSpell.

Author:
Bruno Martins

Field Summary
private  java.io.BufferedReader aspellErrorStream
          The standard error for the aspell command.
private  java.io.PrintStream aspellInputStream
          The standard input for the aspell command.
private  java.io.BufferedReader aspellOutputStream
          The standard output for the aspell command.
private  java.lang.Process process
          The process running the aspell command.
 
Constructor Summary
Aspell()
          Sole constructor for aspell.
 
Method Summary
 void cleanup()
          Cleanup the process running aspell.
private  java.lang.String[] convertFromAspell(java.lang.String pTerm, java.lang.String pSuggestions)
          Converts the result from the aspell spelling checker into a String array with the possible suggestions.
 java.lang.String[] find(java.lang.String pTerm)
          Find spelling corrections for a given misspelled word.
 java.lang.String findMostSimilar(java.lang.String pTerm)
          Find the best spelling correction for a given misspelled word.
 java.util.List findMostSimilarList(java.lang.String pTerm)
          Find spelling corrections for a given misspelled word.
static void main(java.lang.String[] argv)
          Main method .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

process

private java.lang.Process process
The process running the aspell command.


aspellOutputStream

private java.io.BufferedReader aspellOutputStream
The standard output for the aspell command.


aspellInputStream

private java.io.PrintStream aspellInputStream
The standard input for the aspell command.


aspellErrorStream

private java.io.BufferedReader aspellErrorStream
The standard error for the aspell command.

Constructor Detail

Aspell

public Aspell()
       throws java.io.IOException
Sole constructor for aspell.

Throws:
java.io.IOException - A problem occured while creating the backgroud process running aspell.
Method Detail

find

public java.lang.String[] find(java.lang.String pTerm)
Find spelling corrections for a given misspelled word.

Parameters:
pTerm - The word to correct.
Returns:
An array of possible corrections.

findMostSimilar

public java.lang.String findMostSimilar(java.lang.String pTerm)
Find the best spelling correction for a given misspelled word.

Parameters:
pTerm - The word to correct.
Returns:
The best possible correction.

findMostSimilarList

public java.util.List findMostSimilarList(java.lang.String pTerm)
Find spelling corrections for a given misspelled word.

Parameters:
pTerm - The word to correct.
Returns:
A List with the possible corrections.

cleanup

public void cleanup()
Cleanup the process running aspell.


convertFromAspell

private java.lang.String[] convertFromAspell(java.lang.String pTerm,
                                             java.lang.String pSuggestions)
Converts the result from the aspell spelling checker into a String array with the possible suggestions.

Parameters:
pTerm - The correctly spelled word.
pSuggestions - A String with the suggestions in aspell format.
Returns:
An array with the suggestions.

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Main method .

Parameters:
argv - The command line input, tokenized.
Throws:
java.lang.Exception