Squashed initial commit

This commit is contained in:
2024-09-10 13:47:29 -04:00
commit 8ebb6ad265
6221 changed files with 2512206 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
/*
* This is the main class to execute the computation and get the GOID.
*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.Vector;
import weka.core.Instances;
/**
*
* @author DTian
*/
public class ExecMain {
public static void main(String[] args) {
// SGD2AttrTable sgd = new SGD2AttrTable();
// Get clusters
try {
// Check the input arguments
checkParameters(args.length);
GetClusters myGetClusters = new GetClusters();
// To get the input file type
Instances oriData = myGetClusters.input(args[0]);
// Get the output files name
String outputWholeCluster = args[0] + "-WholeTree.txt";
String outputFinalTable = args[0] + "-finalTable.csv";
String outputSummary = args[0] + "-summary.csv";
boolean fromFunction = true?false:args[4].trim().compareToIgnoreCase("true") == 0;
// Create the root cluster name
int round = 1; //for tree level
int position = 0; // for node position in same level
String rootName = (round-1)+"-"+position+"-"+0;
// System.out.println("root cluster is:" + rootName);
myGetClusters.printRootName(outputWholeCluster,rootName);
// Create a vector for fianl table
Vector vecFinalTable = new Vector();
Vector vecSummary = new Vector();
//get the variable name
vecFinalTable.addElement(myGetClusters.printTableHead(oriData));
// Create the root node
TreeNode root = new TreeNode(rootName,0.0,oriData,null);
OutputStreamWriter xmlWriter = new OutputStreamWriter(
new FileOutputStream(new File("tree.xml"), true));
xmlWriter.write(" <tree>\n <declarations> \n <attributeDecl name=\"name\" type=\"String\"/>\n </declarations>\n");
xmlWriter.write(" <branch>\n <attribute name=\"name\" value=\""+"root" +"\"/>\n");
xmlWriter.flush();
// Recursive clustering the data
myGetClusters.clustering(
root,
round,
""+position,
vecFinalTable,
vecSummary,
outputWholeCluster,
xmlWriter,
args[1],
args[2],
args[3],
fromFunction
);
xmlWriter.write(" </branch>\n");
xmlWriter.write("</tree>\n");
xmlWriter.close();
// Output final result
myGetClusters.printVector(vecFinalTable,outputFinalTable);
myGetClusters.printVector(vecSummary,outputSummary);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
/**
* check the number of the arguments:
* java GetCluster arg1 arg2 ...
*
* @param length the length of the arguments
* in this program, length should be 1
*/
private static void checkParameters(int length) {
if(length != 5) {
// there are 5 parameters, 1,file for clustering; 2, lookup table file;
// 3, backgroud file; 4, repeat counts(an integer) 5, GoIDfromFunction (boolean)
System.out.println("Usage: java ExecMain clusterFileName GoMatrixFilename backGroundFilename repeatTime true|false");
System.exit(1);
}
}
}