Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## things.data.language
Class WordDictionary

    java.lang.Object
      things.data.language.WordDictionary

All Implemented Interfaces:
  Translator

    public class WordDictionary

extends java.lang.Object
implements Translator

Create a word dictionary. Regardless of what you load, there will always be at least one word per word size in characters from 1 character to the max size characters.

THIS PACKAGE WAS ABANDONED IN FAVOR OF ANOTHER PROJECT

Version:
  1.0

  Version History

      EPG - Initial -10 MAY 06

Author:
  Erich P. Gatejen

Field Summary
`static int[]` | `defaultFrequencyChart` The default size frequency chart for random selection.
`static int[]` | `firstnameFrequencyChart` The first name size frequency chart for random selection.
`static int[]` | `lastnameFrequencyChart` The last name size frequency chart for random selection.
`static int` | `MAXSIZE` Maximum supported word size.

Constructor Summary
`WordDictionary(java.io.InputStream wordSource)` A ready to do stream from which WS delimited words can be found.

Method Summary
`java.lang.String` | `get()` Get a word of random size.
`java.lang.String` | `get(int size)` Get a word of specified size.
`java.lang.String` | `getMax(int max)` Get a word of random size up to the specified maximum.
`java.lang.String` | `getMax(int max, int[] chart)` Get a word of random size up to the specified maximum.
`void` | `refreshMemory()` Refresh what we've remembered.
`void` | `setFrequencyChart(int[] chart)` Set the frequency chart.
`java.lang.String` | `translate(java.lang.String word)` Translate a word.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MAXSIZE

    public static final int MAXSIZE

  Maximum supported word size.

  See Also:
    Constant Field Values

### defaultFrequencyChart

    public static int[] defaultFrequencyChart

  The default size frequency chart for random selection. IT is geared towards English.

### firstnameFrequencyChart

    public static int[] firstnameFrequencyChart

  The first name size frequency chart for random selection. It is geared towards English.

### lastnameFrequencyChart

    public static int[] lastnameFrequencyChart

  The last name size frequency chart for random selection. It is geared towards English.

Constructor Detail

### WordDictionary

    public WordDictionary(java.io.InputStream wordSource)
                   throws java.lang.Throwable

  A ready to do stream from which WS delimited words can be found. Buffer it if necessary. This is memory hungry, since we'll be converting a hashset to a array for every word size.

  Parameters:
    `wordSource` - a stream to the word source.
  Throws:
    `java.lang.Throwable` - for any failure.

Method Detail

### refreshMemory

    public void refreshMemory()

  Refresh what we've remembered.

### get

    public java.lang.String get()
                         throws java.lang.Throwable

  Get a word of random size.

  Returns:
    the word
  Throws:
    `java.lang.Throwable`

### getMax

    public java.lang.String getMax(int max)
                            throws java.lang.Throwable

  Get a word of random size up to the specified maximum. It still cannot be bigger than MAXSIZE. It will use the configured frequency chart for picking the size.

  Parameters:
    `max` - max size.
  Returns:
    the word
  Throws:
    `java.lang.Throwable`

### getMax

    public java.lang.String getMax(int max,
                                   int[] chart)
                            throws java.lang.Throwable

  Get a word of random size up to the specified maximum. It still cannot be bigger than MAXSIZE. It will use the passed frequency chart for picking the size.

  Parameters:
    `max` - max possible size.
    `chart` - use this frequency chart instead of the configured.
  Returns:
    the word
  Throws:
    `java.lang.Throwable`

### get

    public java.lang.String get(int size)
                         throws java.lang.Throwable

  Get a word of specified size. It still cannot be bigger than MAXSIZE.

  Parameters:
    `size` - if less than one, it'll return an empty string. If there is no words of the specified size, it returns an empty string.
  Returns:
    the word
  Throws:
    `java.lang.Throwable`

### translate

    public java.lang.String translate(java.lang.String word)
                               throws java.lang.Throwable

  Translate a word. It will be the same size unless it exceeds a maximum size (as defined by the implementation) in which case the translated word of the maximum size.

  Specified by:
    `translate` in interface `Translator`
  Parameters:
    `word` - The word to translate.
  Returns:
    the translated word or null if passed null.
  Throws:
    `java.lang.Throwable`

### setFrequencyChart

    public void setFrequencyChart(int[] chart)
                           throws java.lang.Throwable

  Set the frequency chart. There is a default geared to English if you don't set it.

  Parameters:
    `chart` - It must be exactly 100 entries. The size will be chosen randomly from one of the hundred.
  Throws:
    `java.lang.Throwable` - if null or not 100 entries.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Things.