baseCode.io.reader
Class SparseDoubleMatrixReader

java.lang.Object
  extended bybaseCode.io.reader.AbstractNamedMatrixReader
      extended bybaseCode.io.reader.SparseDoubleMatrixReader

public class SparseDoubleMatrixReader
extends AbstractNamedMatrixReader


Copyright (c) 2004 Columbia University

Version:
$Id: SparseDoubleMatrixReader.java,v 1.4 2004/08/16 02:06:01 pavlidis Exp $
Author:
pavlidis

Field Summary
 
Fields inherited from class baseCode.io.reader.AbstractNamedMatrixReader
log
 
Constructor Summary
SparseDoubleMatrixReader()
           
 
Method Summary
 NamedMatrix read(java.io.InputStream stream)
           
 NamedMatrix read(java.io.InputStream stream, java.util.Set wantedRowNames)
          Read a sparse matrix that is expressed as an adjacency list in a tab-delimited file:
 NamedMatrix read(java.lang.String filename)
           
 NamedMatrix read(java.lang.String filename, java.util.Set wantedRowNames)
          Read a matrix from a file, subject to filtering criteria.
 NamedMatrix readJW(java.io.InputStream stream)
          Read a sparse matrix in "JW" (Jason Weston) format.
 NamedMatrix readOneRow(java.io.BufferedReader dis)
           
 
Methods inherited from class baseCode.io.reader.AbstractNamedMatrixReader
readHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseDoubleMatrixReader

public SparseDoubleMatrixReader()
Method Detail

read

public NamedMatrix read(java.lang.String filename)
                 throws java.io.IOException
Specified by:
read in class AbstractNamedMatrixReader
Parameters:
filename - data file to read from
Returns:
NamedMatrix object constructed from the data file
Throws:
java.io.IOException

read

public NamedMatrix read(java.io.InputStream stream)
                 throws java.io.IOException
Specified by:
read in class AbstractNamedMatrixReader
Parameters:
stream - InputStream stream to read from
Returns:
NamedMatrix object constructed from the data file
Throws:
java.io.IOException

read

public NamedMatrix read(java.lang.String filename,
                        java.util.Set wantedRowNames)
                 throws java.io.IOException
Read a matrix from a file, subject to filtering criteria.

Parameters:
filename - data file to read from
wantedRowNames - contains names of rows we want to get
Returns:
NamedMatrix object constructed from the data file
Throws:
java.io.IOException

readJW

public NamedMatrix readJW(java.io.InputStream stream)
                   throws java.io.IOException,
                          java.lang.IllegalAccessException,
                          java.lang.NoSuchFieldException
Read a sparse matrix in "JW" (Jason Weston) format. The format is like this:
          
               2          <--- number of items - the first line of the file only. NOTE - this line is often blank or not present.
               1 2        <--- items 1 has 2 edges
               1 2        <--- edge indices are to items 1 & 2
               0.1 100    <--- with the following weights
               2 2        <--- items 2 also has 2 edges
               1 2        <--- edge indices are also to items 1 & 2 (fully connected)
               100 0.1    <--- with the following weights
 

Note that the item numbering starts at 1. This is a requirement.

Note that this cannot handle very large matrices - the limit to rows x columns is the number Integer.MAX_VALUE. This is an implementation problem for colt's sparse matrix.

Parameters:
stream -
Returns:
@throws IOException
Throws:
java.io.IOException
java.lang.IllegalAccessException
java.lang.NoSuchFieldException

read

public NamedMatrix read(java.io.InputStream stream,
                        java.util.Set wantedRowNames)
                 throws java.io.IOException
Read a sparse matrix that is expressed as an adjacency list in a tab-delimited file:
               item1 item2 weight
               item1 item5 weight
 

By definition the resulting matrix is square and symmetric.

Note that the ordering of the items will be as they are encountered in the file.

Parameters:
stream - InputStream
wantedRowNames - Set
Returns:
NamedMatrix
Throws:
java.io.IOException

readOneRow

public NamedMatrix readOneRow(java.io.BufferedReader dis)
                       throws java.io.IOException
Specified by:
readOneRow in class AbstractNamedMatrixReader
Throws:
java.io.IOException


Copyright © 2003-2005 Columbia University. All Rights Reserved.