Package morfologik.speller
Class HMatrix
java.lang.Object
morfologik.speller.HMatrix
Keeps track of already computed values of edit distance.
Remarks: To save space, the matrix is kept in a vector.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) int
private int[]
private int
-
Constructor Summary
ConstructorsConstructorDescriptionHMatrix
(int distance, int maxLength) Allocates memory and initializes matrix (constructor). -
Method Summary
-
Field Details
-
p
private int[] p -
rowLength
private int rowLength -
columnHeight
int columnHeight -
editDistance
int editDistance
-
-
Constructor Details
-
HMatrix
public HMatrix(int distance, int maxLength) Allocates memory and initializes matrix (constructor).- Parameters:
distance
- (int) max edit distance allowed for candidates;maxLength
- (int) max length of words. Remarks: See Oflazer. To save space, the matrix is stored as a vector. To save time, additional rows and columns are added. They are initialized to their distance in the matrix, so that no bound checking is necessary during access.
-
-
Method Details
-
get
public int get(int i, int j) Provide an item of hMatrix indexed by indices.- Parameters:
i
- - (int) row number;j
- - (int) column number.- Returns:
- Item
H[i][j]
. Remarks: H matrix is really simulated. What is needed is only2 * edit_distance + 1
wide band around the diagonal. In fact this diagonal has been pushed up to the upper border of the matrix. The matrix in the vector looks likes this:+---------------------+ 0 |#####################| j=i-e-1 1 | | j=i-e : : e+1 | | j=i-1 +---------------------+ e+2 | | j=i +---------------------+ e+3 | | j=i+1 : : 2e+2| | j=i+e 2e+3|#####################| j=i+e+1 +---------------------+
-
set
public void set(int i, int j, int val) Set an item in hMatrix. No checking for i & j is done. They must be correct.- Parameters:
i
- - (int) row number;j
- - (int) column number;val
- - (int) value to put there.
-