contents index next

19. fsa_java: JAVA Code Generation

This module provides predicates to create JAVA code on the basis of a finite automaton. There are certain restrictions to the input automaton. The automaton must be:

The compiler performs the following operation to ensure that the above conditions hold:

recognizers:     m(expand_predicates(Sig* & fa(Fa0)))

string to string transducers:     t_minimize(expand_predicates(Sig* o fa(Fa0) o Sig*))

string to weight transducers:     w_minimize(expand_predicates(Sig* o fa(Fa0))

where Sig is equivalent to the union of all one-letter atoms, and Fa0 is the input automaton.

The JAVA program will define a class (named in accordance with the given output file name) which inherits from Applet. The class defines the method:

static void main(String argv[])

The instance itself is an applet in which you can write strings which are checked against the automaton.

either starts a graphical user interface in which you can input strings (if the option -w is the single option), or reads lines from standard input and writes the result of applying the automaton to standard output.

public void gui();

starts a graphical user interface in which you can input strings.

public DFA automaton();

returns the automaton part of the applet. This DFA class in turn defines the following methods:

public boolean Recognizer();
public boolean Transducer();
public boolean WeightedRecognizer();
public boolean WeightedTransducer();

As well as:

public void filter ()

reads lines from standard input and displays the result of running each line through the automaton to standard output.

public boolean accepts ( String in )
public String transduces ( String in )
public Integer weighs ( String in )

The `main' method is provided only if the global variable java_with_main is set to on.

The representation of a finite-automaton in JAVA is similar to the technique explained on page 43 (table 4.2) of Jan Daciuk's dissertation `Incremental Construction of Finite-State Automata and Transducers and their use in the Natural Language Processing'. Politechnika Gdanska, 1998, except that instead of the number of transitions we have a boolean flag indicating for each line whether that line is the last transition for the current state.

19.1. List of Predicates

This section lists the predicates defined by this module.

19.1.1. fsa_java(+FileIn,+FileOut)

A JAVA program is written to FileOut for the recognizer read from FileIn. The JAVA program will read lines from standard input and report for each line whether the string is accepted or not.

19.1.2. fsa_java_t(+FileIn,+FileOut)

A JAVA program is written to FileOut for the string-to-string transducer read from FileIn. The JAVA program will read lines from standard input and report for each line the transduction.

19.1.3. fsa_java_w(+FileIn,+FileOut)

A JAVA program is written to FileOut for the string-to-weight transducer read from FileIn. The JAVA program will read lines from standard input and report for each line the transduction.

contents index next