org.allenai.nlpstack.parse.poly.fsm
This generates a list of labeled feature vectors from a gold parse tree (for training).
This generates a list of labeled feature vectors from a gold parse tree (for training). The gold parse tree is reduced to its representation as a list of 2*n transitions, then a TrainingVector is produced for each transition (in order).
Note that this function is implemented using tail-recursion.
the sculpture to generate feature vectors from
a list of training vectors
Returns the set of tasks associated with the training vectors in this source.
Returns the set of tasks associated with the training vectors in this source.
In a perhaps over-careful attempt to avoid having all the non-uniqued tasks being stored in memory simultaneously, this was originally implemented as:
format: OFF lazy val tasks: Iterable[ClassificationTask] = taskHelper(Set(), getVectorIterator) tailrec private def taskHelper( resultSoFar: Set[ClassificationTask], vectorIter: Iterator[FSMTrainingVector] ): Set[ClassificationTask] = {
if (!vectorIter.hasNext) { resultSoFar } else { taskHelper(resultSoFar + vectorIter.next().task, vectorIter) } } format: ON