smile.data.parser
Class SparseDatasetParser
- java.lang.Object
-
- smile.data.parser.SparseDatasetParser
-
public class SparseDatasetParser extends java.lang.ObjectParser for spare dataset in coordinate triple tuple list format. Coordinate file stores a list of (row, column, value) tuples:instanceID attributeID value instanceID attributeID value instanceID attributeID value instanceID attributeID value ... instanceID attributeID value instanceID attributeID value instanceID attributeID value
Ideally, the entries are sorted (by row index, then column index) to improve random access times. This format is good for incremental matrix construction.Optionally, there may be 2 header lines
D // The number of instances W // The number of attributes
or 3 header linesD // The number of instances W // The number of attributes N // The total number of nonzero items in the dataset.
These header lines will be ignored.
-
-
Constructor Summary
Constructors Constructor and Description SparseDatasetParser()Constructor.SparseDatasetParser(int arrayIndexOrigin)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description SparseDatasetparse(java.io.File file)Parse a sparse dataset from given file.SparseDatasetparse(java.io.InputStream stream)Parse a sparse dataset from an input stream.SparseDatasetparse(java.lang.String path)Parse a sparse dataset from given file.SparseDatasetparse(java.lang.String name, java.io.File file)Parse a sparse dataset from given file.SparseDatasetparse(java.lang.String name, java.io.InputStream stream)Parse a sparse dataset from an input stream.SparseDatasetparse(java.lang.String name, java.lang.String path)Parse a sparse dataset from given file.SparseDatasetparse(java.lang.String name, java.net.URI uri)Parse a sparse dataset from given URI.SparseDatasetparse(java.net.URI uri)Parse a sparse dataset from given URI.
-
-
-
Constructor Detail
-
SparseDatasetParser
public SparseDatasetParser()
Constructor.
-
SparseDatasetParser
public SparseDatasetParser(int arrayIndexOrigin)
Constructor.- Parameters:
arrayIndexOrigin- the starting index of array. By default, it is 0 as in C/C++ and Java. But it could be 1 to parse data produced by other programming language such as Fortran.
-
-
Method Detail
-
parse
public SparseDataset parse(java.net.URI uri) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from given URI.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public SparseDataset parse(java.lang.String name, java.net.URI uri) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from given URI.- Parameters:
uri- the URI of data source.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public SparseDataset parse(java.lang.String path) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from given file.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public SparseDataset parse(java.lang.String name, java.lang.String path) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from given file.- Parameters:
path- the file path of data source.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public SparseDataset parse(java.io.File file) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from given file.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public SparseDataset parse(java.lang.String name, java.io.File file) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from given file.- Parameters:
file- the file of data source.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public SparseDataset parse(java.io.InputStream stream) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from an input stream.- Parameters:
stream- the input stream of data.- Throws:
java.io.IOExceptionjava.text.ParseException
-
parse
public SparseDataset parse(java.lang.String name, java.io.InputStream stream) throws java.io.IOException, java.text.ParseException
Parse a sparse dataset from an input stream.- Parameters:
name- the name of dataset.stream- the input stream of data.- Throws:
java.io.IOExceptionjava.text.ParseException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG