marytts.util.data.text
Class LabelfileDoubleDataSource

java.lang.Object
  extended by marytts.util.data.BaseDoubleDataSource
      extended by marytts.util.data.text.TextReaderDoubleDataSource
          extended by marytts.util.data.text.LabelfileDoubleDataSource
All Implemented Interfaces:
DoubleDataSource

public class LabelfileDoubleDataSource
extends TextReaderDoubleDataSource

Author:
Marc Schröder

Field Summary
 
Fields inherited from class marytts.util.data.text.TextReaderDoubleDataSource
reader
 
Fields inherited from class marytts.util.data.BaseDoubleDataSource
dataLength, inputSource
 
Fields inherited from interface marytts.util.data.DoubleDataSource
NOT_SPECIFIED
 
Constructor Summary
LabelfileDoubleDataSource(java.io.File file)
          Read Double data from a Text file e.g.
LabelfileDoubleDataSource(java.io.Reader reader)
          Read Double data from a Text file containing labels.
 
Method Summary
 int getData(double[] target, int targetPos, int length)
          Try to get length doubles from this DoubleDataSource, and copy them into target, starting from targetPos.
 
Methods inherited from class marytts.util.data.text.TextReaderDoubleDataSource
hasMoreData
 
Methods inherited from class marytts.util.data.BaseDoubleDataSource
available, getAllData, getData, getData, getDataLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelfileDoubleDataSource

public LabelfileDoubleDataSource(java.io.File file)
                          throws java.io.FileNotFoundException
Read Double data from a Text file e.g. in EST format. Skip the header, then read one double per line, which is the first token in that line.

Parameters:
reader -
Throws:
java.io.FileNotFoundException

LabelfileDoubleDataSource

public LabelfileDoubleDataSource(java.io.Reader reader)
Read Double data from a Text file containing labels. Skip the header, then read one double per line, which is the first token in that line.

Parameters:
reader -
Method Detail

getData

public int getData(double[] target,
                   int targetPos,
                   int length)
Try to get length doubles from this DoubleDataSource, and copy them into target, starting from targetPos. This is the core method getting the data. Subclasses may want to override this method. If an exception occurs reading from the underlying reader, or converting data to double, the method will print a stack trace to standard error, but otherwise will silently stop and behave as if all data was read.

Specified by:
getData in interface DoubleDataSource
Overrides:
getData in class TextReaderDoubleDataSource
Parameters:
target - the double array to write into
targetPos - position in target where to start writing
length - the amount of data requested
Returns:
the amount of data actually delivered. If the returned value is less than length, only that many data items have been copied into target; further calls will return 0 and not copy anything.