hu.birot.OTKit.dataType
Class MapForm

java.lang.Object
  extended by hu.birot.OTKit.dataType.MapForm

public class MapForm
extends java.lang.Object

Realizes a probabilistic mapping from Form to Form. In general, a Form from the domain of the mapping is mapped unto a number of Forms, each with some probability.

Examples: in the case of Gen, the domain is the set of underlying forms and the range of the mapping are the surface forms. In the case of a neighborhood structure, the mapping is from surface forms to surface forms. In the case of a Base, an empty Form maps to possible underlying forms. In the case utter, surface forms are mapped to overt forms. In certain cases the domain and the range of the mapping are disjunct sets, and in other cases they may be the same set.

Such a mapping (in its full-fledged version) can be seen as a (possibly infinite) weighted and directed graph with Forms as its nodes. From each Form in the domain of the MapForm a (possibly infinite) number of edges go to the Forms in the range of the MapForm. These edges leaving some Form are "well-sorted": there is always a first edge, and there is always a next edge subsequent to some previous edge, unless it is the last edge. The edges also have weights written on them.

Consequently, four operations can be done using a MapForm, corresponding to the four basic methods of this class. For any form1 in the domain of MapForm, one can return:

  1. all the forms in the range pointed to by edges leaving form1;

  2. the form in the range which the first edge leaving form1 points to;

  3. the form in the range which the edge subsequent to the one pointing to form_last points to (or a message saying that the last edge has been reached);

  4. the form in the range which a random edge leaving form1 points to.

The weights on the edges play a role in generating a random edge: First, normalize the weights so that they sum up to 1 (that is, divide them by their sum). Then, generate a random number r between 0 and 1. Finally, start enumerating the edges (beginning with the first edge and using the subsequent – successor – operation) and cumulatively sum up the (normalized) weights. Return the edge for which this cumulative sum is first greater than r.

The set of edges leaving a node can also be a transfinite set: in this case the subsequent/successor operation is complemented by the limit operation.

Whenever you construct a new MapForm, you should define all the four operations -- in theory. In practice, you usually need only some of them. For instance, specifying the topology (neighborhood relation) requires method MapForm.random for a random walk, and method MapForm.all for a gradient walk. Moreover, if a FormMap maps to an infinite set for a certain form in its range, specifying MapForm.all is even impossible.

This is the reason why the present class is not abstract. All its four methods are specified, even if they are useless (they throw exceptions). You can either override yourself the methods that you are going to use (that is probably the more efficient way to go), or borrow a MapForm from the class MapFormExamples.

A number of static final Forms complement this class, used to return "error messages". When you implement (formally speaking: when you override) the methods, make sure you follow the conventions regarding the use of these "error codes".

See Also:
MapFormExamples, BasicSteps

Field Summary
static Form InfiniteSet
          This form is returned by method MapForm.all(Form form1) if form1 maps to an infinite set.
static Form NoMapping
          This Form is returned by a MapForm if it does not contain any mapping from the input form.
static Form NoMoreForm
          This form is returned by method MapForm.next(Form form1, Form form2) if form2 is the last form to which form1 is mapped.
static Form NotInRange
          This form is returned by method MapForm.next(Form form1, Form form2) if form1 does not map to form2.
static Form RndTooHigh
          This form is returned by method MapForm.random(Form form1, double rnd) if rnd is too high (in practice, >1), and therefore no Form is returned.
 
Constructor Summary
MapForm()
           
 
Method Summary
 java.util.Vector<Form> all(Form form1)
          Return all the Forms to which MapForm maps from form1.
 Form first(Form form1)
          Return the first Form of those to which MapForm maps from form1.
 Form next(Form form1, Form form_last)
          Return the Form subsequent (successor) to form_last from among those to which MapForm maps from form1.
 Form random(Form form1, double rnd)
          Return a "random" Form from the set of the Forms to which MapForm maps from form1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NoMapping

public static final Form NoMapping
This Form is returned by a MapForm if it does not contain any mapping from the input form.


NoMoreForm

public static final Form NoMoreForm
This form is returned by method MapForm.next(Form form1, Form form2) if form2 is the last form to which form1 is mapped.

See Also:
next(Form, Form)

NotInRange

public static final Form NotInRange
This form is returned by method MapForm.next(Form form1, Form form2) if form1 does not map to form2.

See Also:
next(Form, Form)

RndTooHigh

public static final Form RndTooHigh
This form is returned by method MapForm.random(Form form1, double rnd) if rnd is too high (in practice, >1), and therefore no Form is returned.

See Also:
random(Form, double)

InfiniteSet

public static final Form InfiniteSet
This form is returned by method MapForm.all(Form form1) if form1 maps to an infinite set.

See Also:
all(Form)
Constructor Detail

MapForm

public MapForm()
Method Detail

first

public Form first(Form form1)

Return the first Form of those to which MapForm maps from form1.

MapForm maps form1 to a number of Forms, and this method returns the first one.

If form1 is not in the domain of MapForm, then the static Form MapForm.NoMapping is returned.

If this method is not overridden, it throws an exception. When you override it, make sure you follow the above convention.

Parameters:
form1 - The form in the domain of MapForm.
Returns:
The first form in the range of MapForm mapped to from form1.
See Also:
NoMapping

next

public Form next(Form form1,
                 Form form_last)

Return the Form subsequent (successor) to form_last from among those to which MapForm maps from form1.

MapForm maps form1 to a number of Forms, and this method returns the one that comes after form_last.

If form1 is not in the domain of MapForm, then the static Form MapForm.NoMapping is returned. If form1 does not map to form_last, then the static Form MapForm.NotInRange is returned. If form_last is the last Form to which form1 map, then the static Form MapForm.NoMoreForm is returned.

If this method is not overridden, it throws an exception. When you override it, make sure you follow the above conventions.

Parameters:
form1 - The form in the domain of MapForm.
form_last - A form in the range of MapForm.
Returns:
The form subsequent (successor) to form_last in the range of MapForm, mapped to from form1.
See Also:
NoMapping, NotInRange, NoMoreForm

random

public Form random(Form form1,
                   double rnd)

Return a "random" Form from the set of the Forms to which MapForm maps from form1.

MapForm maps form1 to a number of Forms, and this method returns a random one, based on the random number rnd.

If form1 is not in the domain of MapForm, then the static Form MapForm.NoMapping is returned. If rnd is too high (greater than 1), then the static Form MapForm.RndTooHigh is returned. If rnd is less than 0, then the result is the same as if rnd were equal to 0.

If this method is not overridden, it throws an exception. When you override it, make sure you follow the above conventions.

Parameters:
form1 - The form in the domain of MapForm.
rnd - Random value defining which form to return.
Returns:
Random form in the range of MapForm mapped to from form1.
See Also:
NoMapping, RndTooHigh

all

public java.util.Vector<Form> all(Form form1)

Return all the Forms to which MapForm maps from form1.

MapForm maps form1 to a number of Forms, and this method returns them as a Vector<Form> – supposing that this set is finite.

If form1 is not in the domain of MapForm, then a vector containing the static Form MapForm.NoMapping is returned. If form1 is mapped by MapForm to an infinite set, then a vector containing the static Form MapForm.InfiniteSet is returned.

If this method is not overridden, it throws an exception. When you override it, make sure you follow the above conventions.

Parameters:
form1 - The form in the domain of MapForm.
Returns:
A vector of Forms in the range of MapForm.
See Also:
NoMapping, InfiniteSet