|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hu.birot.OTKit.otBuildingBlocks.Grammar hu.birot.OTKit.grammarExamples.StringGrammar
public class StringGrammar
A subclass of Grammar
playing with strings.
Used in a number of articles of the author since 2007.
Forms in a String Grammar belong to type Form(o,"string"),
where o is an array of integers of length StringGrammar.L
.
Each element of the array can have a value between
0 and StringGrammar.K
.
Constraints are named as (where letter
can be anything between 0
and StringGrammar.K
):
"No"+letter | assign 1 violation mark to each instance of letter. |
"Ni"+letter | assign 1 violation mark, if string begins with letter. |
"Nf"+letter | assign 1 violation mark, if string ends with letter. |
"Assimilate" | assign 1 violation mark to each adjacent character pair of different letters. |
"Dissimilate" | assign 1 violation mark to each adjacent character pair of the same letters. |
"Faithfulness" | pointwise faithfulness, see method Faithful() . |
Grammar
Field Summary | |
---|---|
int |
K
The size of the alphabet in this grammar. |
int |
L
The length of strings in this grammar. |
static IntegerViolation |
nulViol
Violation(0). |
static IntegerViolation |
oneViol
Violation(1). |
Fields inherited from class hu.birot.OTKit.otBuildingBlocks.Grammar |
---|
base, gen, hierarchy, topology, type, utter |
Constructor Summary | |
---|---|
StringGrammar(int alphabetsize,
int length,
java.lang.String h_type)
To construct a string grammar, you must add the alphabet's size and the length of each string. |
Method Summary | |
---|---|
Constraint |
Assimilate()
This class creates constraint "Assimilate", which punishes each pair of different neighboring characters. |
Constraint |
Dissimilate()
This class creates constraint "Dissimilate", which punishes each pair of similar neighboring characters. |
Constraint |
Faithful()
This class creates constraint "Faithful", which punishes each locus such that the uf is different from the sf. |
Constraint |
No_i(int letter)
This class creates a constraint assigning one violation mark to each occurrence of character letter in a string grammar. |
Constraint |
NoFinal_i(int letter)
This class creates a constraint assigning one violation mark to the surface form if it ends with character letter. |
Constraint |
NoInitial_i(int letter)
This class creates a constraint assigning one violation mark to the surface form if it begins with character letter. |
void |
setPragueHierarchy()
This method sets the K-values to those used in my 2007 paper (ACL workshop in Prague). |
Form |
StrForm(int[] array)
This method returns a Form based on the values in an array. |
static int |
StrFormGet(Form f,
int locus)
This static method returns the value at position locus of the Form f. |
Form |
StrFormSet(Form f,
int locus,
int value)
This method returns a Form that is similar to the Form, but the character in position locus is rewritten as value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int L
The length of strings in this grammar.
public final int K
The size of the alphabet in this grammar. Each element of the array representing a form can have the integer values 0 ... K-1.
public static final IntegerViolation nulViol
public static final IntegerViolation oneViol
Constructor Detail |
---|
public StringGrammar(int alphabetsize, int length, java.lang.String h_type)
To construct a string grammar, you must add the alphabet's size and the length of each string.
alphabetsize
- The size of the alphabet (0 ... alphabetsize-1).length
- The length of the strings.h_type
- Type of the Hierarchy (for instance, "ot" or "hg").Method Detail |
---|
public Form StrForm(int[] array)
public Form StrFormSet(Form f, int locus, int value)
This method returns a Form that is similar to the Form, but the character in position locus is rewritten as value. Obviously, 0 <= locus < StringGrammar.L and 0 <= value < StringGrammar.K must be satisfied. If f is not a Form of type "StringGrammar", the output is garbage.
f
- The Form based on which a new Form is created.locus
- The position at which the character to be rewritten.value
- The new value of the character at position locus.
public static int StrFormGet(Form f, int locus)
This static method returns the value at position locus of the Form f. If f is not of type "StringGrammar", then the output is garbage.
f
- Form which is being read.locus
- Position within Form f.
public Constraint No_i(int letter)
letter
- The character being punished.
public Constraint NoInitial_i(int letter)
letter
- The character being punished.
public Constraint NoFinal_i(int letter)
letter
- The character being punished.
public Constraint Assimilate()
public Constraint Dissimilate()
public Constraint Faithful()
This class creates constraint "Faithful", which punishes each locus such that the uf is different from the sf. Each locus is assigned a violation mark that is the distance of the character in uf at that locus and of the character in sf at that locus. That is, the expression
d(uf[j],sf[j]) = Math.min( (uf[j] - sf[j] + K) % K, (uf[j] - sf[j] + K) % K )is summed up for each locus j. Here, uf[j] and sf[j] denote the character at locus j in the underlying form string and in the surface form string respectively.
public void setPragueHierarchy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |