本文共 1989 字,大约阅读时间需要 6 分钟。
import java.util.ArrayList;import java.util.Arrays;import java.io.BufferedReader;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;public class BUC { private String [][] dataSet; private ArrayListdimension; private ArrayList inputList; private ArrayList removeList; private Integer minSup; public BUC(int rank, int col,Integer minSup, String filename) { this.dataSet = new String[rank][col]; this.dimension = new ArrayList (); this.minSup = minSup; this.inputList = new ArrayList (); this.removeList = new ArrayList (); this.readFile(filename); this.getDimension(); this.getOutput(0); } //读取csv数据到dataSet里面 public void readFile(String filename){ File inFile = new File(filename); // 读取的CSV文件 String inString = ""; try { BufferedReader reader = new BufferedReader(new FileReader(inFile)); inString = reader.readLine(); String [] tempRank = null; for(int i=0;inString!=null;i++){ tempRank = inString.split(","); for(int j=0;j getDimension(ArrayList a){ for(int i=0;i getDimension(ArrayList a,Integer k){ if(k>this.dataSet[0].length){ return null; }else { for(int i=0;i endSet = new ArrayList (); for(int i=0;i t){ boolean flag = true; for(int i=0;i tempSet = new ArrayList (); this.getDimension(tempSet); Integer [] SetCount = new Integer[tempSet.size()]; for(int i=0;i =this.minSup){ this.inputList.add(tempSet.get(i)+"<"+SetCount[i]+">"); }else { this.removeList.add(tempSet.get(i)); } } }else { ArrayList tempSet = new ArrayList (); tempSet = this.getDimension(tempSet,dim); this.removeList = new ArrayList (); Integer [] SetCount = new Integer[tempSet.size()]; for(int i=0;i =this.minSup){ this.inputList.add(tempSet.get(i)+"<"+SetCount[i]+">"); }else { this.removeList.add(tempSet.get(i)); } } System.out.println("输出结果为:"+this.inputList.toString()); } } //工作函数 public void getOutput(int dim){ if(dim
转载地址:http://xjkl.baihongyu.com/