java.lang.Object
com.aquima.interactions.spellengine.model.Speller
All Implemented Interfaces:
ISpeller, Serializable

public class Speller extends Object implements Serializable, ISpeller

Converts an integer to its textual representation.
Example:
4455 --> four thousand four hundred fifty five (english)
4455 --> vierenveertighonderd vijfenvijftig (dutch)

Everest b.v.
Irmen de Jong
2003-01-14

Converted from old C-program. (Copyright 1987, Scott Deerwester.)

extended with:

  • negative integers
  • some grammer fixes

Integrated and refactored for Aquima by Jon van Leuven

Original documentation:
number

Number is a program that counts in lots of languages. It was originally written during a sanity break while I was writing my PhD thesis. That version got left on a machine somewhere in upstate New York. This one was done while on leave in Grenoble, after realizing that I hadn't written a computer program in over two months.

Number is inspired, of course, from /usr/games/number, but it uses a series of grammars that define counting in different languages. The language that is used to write the grammars is described below, in evalrule(). If you write any new grammars, I'd greatly appreciate having them. Grammars aren't very hard to write, if you know how to count in something that isn't defined here. The longest grammar (french) only has 30 rules and 5 macros, and correctly pronounces any number less 1,000,000,000,000. The shortest is for cantonese, which has 14 rules.

A note on the output of number:

The characters that are output conform to the TIRA character representation standard. Essentially, strings in anything except the latin alphabet (what you're reading now) are preceded by an indication of the alphabet that they are part of. The exceptions to this are mandarin, cantonese and japanese. These three are written in pin-yin, roughly Wade Giles, and romanji, respectively. The only other thing special about this format is that accents and tone markings are given in [] brackets before the letter to which they are attached.

TIRA stands for Textual Information Retrieval and Analysis research group, and is a research group at the University of Chicago containing computer and information scientists, literary scholars and linguists. TIRA is working on a research environment for doing textual research. Watch this space.

Copyright 1987, Scott Deerwester.

This code may be freely distributed and copied, provided that a copy of this notice accompanies all copies and that no copy is sold for profit.

Since:
6.0
Author:
Irmen de Jong, Jon van Leuven
See Also:
  • Constructor Details

    • Speller

      protected Speller(SpellerDefinition definition)
      Construct a NumberSpeller from a definition.
      Parameters:
      definition - The speller definition that should be used.
  • Method Details

    • getName

      public String getName()
      Description copied from interface: ISpeller
      This method return the name of the speller.
      Specified by:
      getName in interface ISpeller
      Returns:
      the name of the speller (never null)
    • getDescription

      public String getDescription()
      Description copied from interface: ISpeller
      This method return the description of the speller.
      Specified by:
      getDescription in interface ISpeller
      Returns:
      the description of the speller, may be null
    • spell

      public String spell(long number)
      spell a long value amount.
      Specified by:
      spell in interface ISpeller
      Parameters:
      number - long value to spell
      Returns:
      The spelled value of the long value.
      Throws:
      SpellerException - Is thrown when spelling failed.
    • readLong

      protected static long readLong(String str, int index)