5:11 PM

reorder.java


import java.io.*;
import java.util.*;

public class reorder {

/** 2-D aray to hold input data from data file. */
protected short[][] dataArray = null;
/** 2-D array used to renumber columns for input data in terms of
frequency of single attributes . */
protected int[][] conversionArray = null;
/** 1-D array used to reconvert input data column numbers to their
original numbering . */
protected short[] reconversionArray = null;

/** Minimum support value */
private static final double MIN_SUPPORT = 0.0;
/** Maximum support value */
private static final double MAX_SUPPORT = 100.0;
/** Maximum confidence value */
private static final double MIN_CONFIDENCE = 0.0;
/** Maximum confidence value */
private static final double MAX_CONFIDENCE = 100.0;

/** Command line argument for data file name. */
protected String fileName = null;
protected int numCols = 0;
protected int numRows = 0;
protected double support = 20.0;
protected double minSupport = 0;
protected double confidence = 80.0;
/** The number of one itemsets . */
protected int numOneItemSets = 0;


/** Error flag used when checking command line arguments */
protected boolean errorFlag = true;
/** Input format OK flag */
protected boolean inputFormatOkFlag = true;
/** Flag to indicate whether system has data or not. */
private boolean haveDataFlag = false;
/** Flag to indicate whether input data has been sorted or not. */
protected boolean isOrderedFlag = false;
/** Flag to indicate whether input data has been sorted and pruned or
not. */
protected boolean isPrunedFlag = false;

/** The input stream. */
protected BufferedReader fileInput;
/** The file path */
protected File filePath = null;

public reorder(String[] args) {
// Process command line arguments
for(int index=0;index // If command line arguments read successfully (errorFlag set to "true")
// check validity of arguments
if (errorFlag) CheckInputArguments();
else outputMenu();
}

/*Command line argument*/
protected void idArgument(String argument) {
if (argument.charAt(0) == '-') {
char flag = argument.charAt(1);
argument = argument.substring(2,argument.length());
switch (flag) {
case 'C':
confidence = Double.parseDouble(argument);
break;
case 'F':
fileName = argument;
break;
case 'S':
support = Double.parseDouble(argument);
break;
default:
System.out.println("INPUT ERROR: Unrecognise command " +
"line argument -" + flag + argument);
errorFlag = false;
}
}
else {
System.out.println("INPUT ERROR: All command line arguments " +
"must commence with a '-' character (" +
argument + ")");
errorFlag = false;
}
}

/* Check input arguments */
protected void CheckInputArguments() {
// Check support and confidence input
checkSupportAndConfidence();
// Check file name
checkFileName();
if (errorFlag) outputSettings();
else outputMenu();
}

/* CHECK SUPPORT AND CONFIDENCE */
protected void checkSupportAndConfidence() {
// Check Support
if ((support < MIN_SUPPORT) || (support > MAX_SUPPORT)) {
System.out.println("INPUT ERROR: Support must be specified " +
"as a percentage (" + MIN_SUPPORT +
" - " + MAX_SUPPORT + ")");
errorFlag = false;
}
// Check confidence
if ((confidence < MIN_CONFIDENCE) || (confidence > MAX_CONFIDENCE)) {
System.out.println("INPUT ERROR: Confidence must be " +
"specified as a percentage (" + MIN_CONFIDENCE +
" - " + MAX_CONFIDENCE + ")");
errorFlag = false;
}
}

0 comments: