001/** 002 * Copyright (c) 2011, The University of Southampton and the individual contributors. 003 * All rights reserved. 004 * 005 * Redistribution and use in source and binary forms, with or without modification, 006 * are permitted provided that the following conditions are met: 007 * 008 * * Redistributions of source code must retain the above copyright notice, 009 * this list of conditions and the following disclaimer. 010 * 011 * * Redistributions in binary form must reproduce the above copyright notice, 012 * this list of conditions and the following disclaimer in the documentation 013 * and/or other materials provided with the distribution. 014 * 015 * * Neither the name of the University of Southampton nor the names of its 016 * contributors may be used to endorse or promote products derived from this 017 * software without specific prior written permission. 018 * 019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 022 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 023 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 026 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030package org.openimaj.hadoop.tools.twitter.token.outputmode.sparsecsv.matlabio; 031 032import java.io.IOException; 033import java.util.Map; 034 035import com.jmatio.io.MatFileReader; 036import com.jmatio.types.MLArray; 037import com.jmatio.types.MLCell; 038 039public class MatlabIO { 040 public static void main(String[] args) throws IOException { 041 // MLCell cell = new MLCell("data", new int[]{100000,1}); 042 // Random r = new Random(); 043 // for (int i = 0; i < 100000; i++) { 044 // MLCell inner = new MLCell(null, new int[]{2,1}); 045 // inner.set(new MLChar(null,"Dummy String" + r.nextDouble()), 0, 0); 046 // MLDouble d = new MLDouble(null, new double[][]{new 047 // double[]{r.nextDouble()}}); 048 // inner.set(d, 1, 0); 049 // cell.set(inner, i,0); 050 // } 051 // ArrayList<MLArray> arr = new ArrayList<MLArray>(); 052 // arr.add(cell); 053 // new MatFileWriter( "mat_file.mat", arr); 054 final MatFileReader reader = new MatFileReader("/Users/ss/Development/python/storm-spams/XYs.mat"); 055 final Map<String, MLArray> content = reader.getContent(); 056 final MLCell cell = (MLCell) content.get("XYs"); 057 System.out.println(cell.get(0, 0)); 058 System.out.println(cell.get(0, 1)); 059 } 060}