fozziethebeat/S-Space — pull request #23 by fozziethebeat (2012-08-30 07:12:37+00:00)
Title: Hal fix

This update fixes [Issue 22][1], where HyperspaceAnalogueToLanguage was computing the wrong weights for previous tokens in the sliding window and in some corner cases, left out a dimension in the final sspace.

This fix also includes some refactoring of the class:
- It now uses a basis mapping
- Use of system properties is deprecated, key parameters are now passed in through a constructor and validated before any major processing takes place
- Duplicate code regions are factored out into re-used functions
- Javadoc has been updated to reflect above changes.

Further more, an attempt was made to use a GrowingSparseMatrix to accumulate the local counts, this involved the following added bits of code:
- SparseDoubleVectors have an instanceCopy function which returns the same type and the same dimension boundary. Views either return an instance copy of the decorated vector or they throw unsupported operation exceptions the decorated vector isn't a sparse double vector. This approach was done in contrast to using the global function in Vectors in order to reduce the amount of reflection used and let individual classes decide the best means of creating a new copied instance.
- GrowingSparseMatrix now takes in an empty sparse double vector and uses that initial vector to populate new rows in the matrix. This gives greater flexibility as GrowingSparseMatrix can now use either the logarithmic time CompactSparseVector or the constant time SparseHashDoubleVector simply by using a different parameter to the constructor.
* The use of the GrowingSparseMatrix in HAL was not included as Sparse Matrices still lack a means of iterating over the non-empty rows, iterating over all rows would produce a large increase in time complexity for processDocument.