package ca.pfv.spmf.algorithms.sequentialpatterns.goKrimp;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
/**
* This file reads data with different formats for the GoKrimp algorithm.
*
*
* Copyright (c) 2014 Hoang Thanh Lam (TU Eindhoven and IBM Research)
* Toon Calders (Université Libre de Bruxelles), Fabian Moerchen (Amazon.com inc)
* and Dmitriy Fradkin (Siemens Corporate Research)
*
*
* This file is part of the SPMF DATA MINING SOFTWARE
* (http://www.philippe-fournier-viger.com/spmf).
*
*
* SPMF is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
*
* SPMF is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License along with
* SPMF. If not, see .
*
* @see AlgoGoKrimp
* @see Event
* @see MyPattern
* @see SignTest
* @author Hoang Thanh Lam (TU Eindhoven and IBM Research)
*/
public class DataReader {
AlgoGoKrimp readData(String databasename, String labelfilename){
AlgoGoKrimp gk=new AlgoGoKrimp();
gk.labels=readLabel(labelfilename);
gk.data=new ArrayList();
try{
DataInputStream in;
FileInputStream fstream = new FileInputStream(databasename);
in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
int size=0;
while((strLine = br.readLine()) != null){
String[] temp;
String delimiter = " ";
temp = strLine.split(delimiter);
ArrayList s=new ArrayList();
gk.data.add(s);
int ts=0,prev=0;
size++;
for(int i=0;i s=new ArrayList();
gk.data.add(s);
int ts=0,prev=0;
for(int i=0;i readLabel(String dataname){
HashMap labels= new HashMap();
File file = new File(dataname);
if(file.exists()){ //the label file with such name does not exist
return labels;
}
try{
DataInputStream in;
FileInputStream fstream = new FileInputStream(dataname);
in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
int k=0;
while((strLine = br.readLine()) != null){
labels.put(k, strLine);
k++;
}
in.close();
}catch (IOException e){
System.err.println("Warning: " + e.getMessage());
}
return labels;
}
}
Ads help maintain this website.