Class Alphabet

java.lang.Object
  extended byAlphabet

public class Alphabet
extends java.lang.Object

This class implements the alphabet. Internally, for automata, grammars or transducers, the alphabet is always a set of consecutive integers beginning with 0.


Constructor Summary
Alphabet(boolean[] isLetter)
          Creates an alphabet from a boolean array isLetter
Alphabet(char[] chars)
          Creates an alphabet consisting in a set given in an array of characters.
Alphabet(char letter, int n)
          Creates an alphabet of size n beginning at character letter
Alphabet(int n)
          Creates an alphabet of size n beginning at character a.
Alphabet(java.util.Set charSet)
          Creates an alphabet consisting in a set of characters.
 
Method Summary
static void addToCharSet(java.lang.String line, boolean[] isLetter)
           
 short convert(Alphabet a, short i)
          Converts the short integer i to its value in the alphabet a.
static Alphabet english()
          The english alphabet.
static Alphabet french()
          The french alphabet.
static Alphabet fromExpression(java.lang.String exp)
          Returns the alphabet composed of the letters appearing in the expression exp (used to create an alphabet from a regular expression).
static Alphabet fromFile(java.lang.String name)
          Returns the alphabet composed of all the characters appearing in the file name.
 boolean isIn(char c)
          Returns true if the character c is in the alphabet.
static void main(java.lang.String[] args)
           
 java.util.Set toChar(java.util.Set s)
          Converts to characters the elements of the set of Short s.
 short toShort(char c)
          Translates the character c to a short integer using the array charToShort.
 short[] toShort(java.lang.String w)
          Translates the String w to Short using the method toShort().
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Alphabet

public Alphabet(char letter,
                int n)
Creates an alphabet of size n beginning at character letter


Alphabet

public Alphabet(boolean[] isLetter)
Creates an alphabet from a boolean array isLetter


Alphabet

public Alphabet(int n)
Creates an alphabet of size n beginning at character a.


Alphabet

public Alphabet(java.util.Set charSet)
Creates an alphabet consisting in a set of characters.


Alphabet

public Alphabet(char[] chars)
Creates an alphabet consisting in a set given in an array of characters.

Method Detail

french

public static Alphabet french()
The french alphabet.


english

public static Alphabet english()
The english alphabet.


fromFile

public static Alphabet fromFile(java.lang.String name)
                         throws java.lang.Exception
Returns the alphabet composed of all the characters appearing in the file name.

Throws:
java.lang.Exception

fromExpression

public static Alphabet fromExpression(java.lang.String exp)
Returns the alphabet composed of the letters appearing in the expression exp (used to create an alphabet from a regular expression).


addToCharSet

public static void addToCharSet(java.lang.String line,
                                boolean[] isLetter)

toShort

public short toShort(char c)
Translates the character c to a short integer using the array charToShort.


toShort

public short[] toShort(java.lang.String w)
Translates the String w to Short using the method toShort().


toChar

public java.util.Set toChar(java.util.Set s)
Converts to characters the elements of the set of Short s.


isIn

public boolean isIn(char c)
Returns true if the character c is in the alphabet.


convert

public short convert(Alphabet a,
                     short i)
Converts the short integer i to its value in the alphabet a.


toString

public java.lang.String toString()

main

public static void main(java.lang.String[] args)