e.printStackTrace();
statusText = "failure";
}
<<<<<<< HEAD
finally{
response.setContentType("text/plain");
out = response.getWriter();
out.println(statusText);
out.close();
=======
} else {
//this is how to handle a TuningTask
String statusText = "success";
System.out.println("writeOutScanTask - TuningTask: I am starting up.");
//set up our StringBuffers for the test and training files
StringBuffer train = new StringBuffer();
StringBuffer test = new StringBuffer();
//let's get our boosting scores in.
String[] predictInput = new String[10];
myShepherd.beginDBTransaction();
ScanTask st2 = null;
try {
if (request.getParameter("number").equals("TuningTask")) {
st2 = myShepherd.getScanTask("TuningTask");
} else {
st2 = myShepherd.getScanTask("FalseMatchTask");
}
st2.setFinished(true);
long time = System.currentTimeMillis();
st2.setEndTime(time);
//let's write out the results
//File file=new File((new File(".")).getCanonicalPath()+File.separator+"webapps"+File.separator+"ROOT"+File.separator+"appadmin"+File.separator+request.getParameter("number")+"_tuningTaskOutput.xls");
/**
File file=new File(getServletContext().getRealPath(("/appadmin/"+request.getParameter("number")+"_tuningTaskOutput.xls")));
WritableWorkbook workbook = Workbook.createWorkbook(file);
WritableCellFormat floatFormat = new WritableCellFormat (NumberFormats.FLOAT);
WritableCellFormat integerFormat = new WritableCellFormat (NumberFormats.INTEGER);
WritableSheet sheet = workbook.createSheet(request.getParameter("number")+" Output", 0);
//add the label row
Label label0 = new Label(0, 0, "Encounter A");
Label label1 = new Label(1, 0, "Encounter B");
Label label2 = new Label(2, 0, "Shark");
boostString = boostString + ", 1.0";
Label label2a = new Label(3, 0, "Groth: Fraction Matched Triangles");
Label label3 = new Label(4, 0, "Groth: Match Score");
Label label5 = new Label(5, 0, "I3S Match Score");
Label label6 = new Label(6, 0, "RefA 1x");
Label label7 = new Label(7, 0, "RefA 1y");
Label label8 = new Label(8, 0, "RefA 2x");
Label label9 = new Label(9, 0, "RefA 2y");
Label label10 = new Label(10, 0, "RefA 3x");
Label label11 = new Label(11, 0, "RefA 3y");
Label label6b = new Label(12, 0, "RefB 1x");
Label label7b = new Label(13, 0, "RefB 1y");
Label label8b = new Label(14, 0, "RefB 2x");
Label label9b = new Label(15, 0, "RefB 2y");
Label label10b = new Label(16, 0, "RefB 3x");
Label label11b = new Label(17, 0, "RefB 3y");
Label label12 = new Label(18, 0, "Spot used for A?");
Label label13 = new Label(19, 0, "Spot used for B?");
Label label13y = new Label(20, 0, "Side");
//boosting scores
Label label14 = new Label(21, 0, "Boost - match score");
Label label15 = new Label(22, 0, "Boost - not score");
if(!request.getParameter("number").equals("TuningTask")){
sheet.addCell(label15);
sheet.addCell(label14);
sheet.addCell(label13y);
sheet.addCell(label13);
sheet.addCell(label12);
sheet.addCell(label11b);
sheet.addCell(label10b);
sheet.addCell(label9b);
sheet.addCell(label8b);
sheet.addCell(label7b);
sheet.addCell(label6b);
sheet.addCell(label11);
sheet.addCell(label10);
sheet.addCell(label9);
sheet.addCell(label8);
sheet.addCell(label7);
sheet.addCell(label6);
sheet.addCell(label5);
sheet.addCell(label3);
sheet.addCell(label2a);
sheet.addCell(label2);
sheet.addCell(label1);
sheet.addCell(label0);
}
*/
ArrayList wis = null;
if (request.getParameter("number").equals("TuningTask")) {
wis = gm.getRemainingWorkItemsForTask("TuningTask");
} else {
wis = gm.getRemainingWorkItemsForTask("FalseMatchTask");
//System.out.println("wis size in writeOutScanTask is: " + wis.size());
}
ArrayList wirs = null;
if (request.getParameter("number").equals("TuningTask")) {
wirs = gm.getResultsForTask("TuningTask");
} else {
wirs = gm.getResultsForTask("FalseMatchTask");
}
System.out.println("writeOutScanTask: got my scanTask...");
int resultSize = wirs.size();
for (int i = 1; i < (resultSize + 1); i++) {
String boostString = "";
//get the objects we need to populate intelligent results
MatchObject mo = wirs.get(i - 1).getResult();
//scanWorkItem ttt=wirs.get(i-1).
ScanWorkItem swi = getWI4MO(wirs.get(i - 1), wis);
Encounter encA = myShepherd.getEncounter(swi.getNewEncNumber());
Encounter encB = myShepherd.getEncounter(swi.getExistingEncNumber());
//boost sex
if ((encA.getSex()!=null)&&(encB.getSex()!=null)&&(encA.getSex().equals(encB.getSex()))) {
boostString += (encA.getSex() + ",");
predictInput[0] = encA.getSex();
}
else {
boostString += "unknown,";
predictInput[0] = "unknwon";
}
//boost locationCode
String locCodeA = encA.getLocationCode().trim();
String locCodeB = encB.getLocationCode().trim();
boostString += (locCodeA + "," + locCodeB + ",");
predictInput[1] = locCodeA.trim();
predictInput[2] = locCodeB.trim();
//add the label row
/*Label label0a = new Label(0, i, encA.getEncounterNumber());
Label label1a = new Label(1, i, encB.getEncounterNumber());
try {
Label label2aaa = new Label(2, i, mo.getIndividualName());
Label label2aa = new Label(3, i, Double.toString(mo.adjustedMatchValue));
Label label3a = new Label(4, i, Double.toString((mo.getMatchValue()*mo.getAdjustedMatchValue())));
Label label5a = new Label(5, i, Double.toString(mo.i3sMatchValue));
*/
//boost I3S score
boostString = boostString + mo.i3sMatchValue + ",";
predictInput[3] = Double.toString(mo.i3sMatchValue);
//boost Groth score
boostString = boostString + (mo.getMatchValue()) + ",";
predictInput[4] = Double.toString((mo.getMatchValue()));
boostString = boostString + mo.getAdjustedMatchValue() + ",";
predictInput[5] = Double.toString((mo.getAdjustedMatchValue()));
String logM = "";
try {
logM = (new Double(mo.getLogMStdDev()).toString());
} catch (java.lang.NumberFormatException nfe) {
logM = "0.01";
}
boostString = boostString + logM + ",";
predictInput[6] = logM;
//boost time difference in absolute years
boostString = boostString + Math.abs((encA.getYear() - encB.getYear())) + ",";
predictInput[7] = Integer.toString(Math.abs((encA.getYear() - encB.getYear())));
//boost num matching keywords
List keywords = myShepherd.getKeywordsInCommon(encA.getEncounterNumber(), encB.getEncounterNumber());
int keywordsSize = keywords.size();
boostString = boostString + keywordsSize + ",";
predictInput[8] = Integer.toString(keywordsSize);
String sizeDiffString = "unknown";
if ((encA.getSizeAsDouble()!=null)&&(encB.getSizeAsDouble()!=null)&&(encA.getSize() > 0) && (encB.getSize() > 0)) {
double sizeDiff = Math.abs((encA.getSize() - encB.getSize()));
if (sizeDiff <= 2.0) {
sizeDiffString = "small";
} else {
sizeDiffString = "large";
}
}
predictInput[9] = sizeDiffString;
boostString = boostString + sizeDiffString + ",";
//boost the label
if (request.getParameter("number").equals("TuningTask")) {
boostString = boostString + "match";
} else {
boostString = boostString + "not";
}
//add weight
//if((request.getParameter("boostWeight")!=null)&&(!request.getParameter("boostWeight").equals(""))){
if (request.getParameter("number").equals("TuningTask")) {
if ((mo.getAdjustedMatchValue() * mo.getMatchValue()) < 30) {
boostString = boostString + ", 2.0";
} else {
}
} else {
if ((mo.getAdjustedMatchValue() * mo.getMatchValue()) > 50) {
boostString = boostString + ",2.0";
} else {
boostString = boostString + ", 1.0";
}
}
//numSpotsDiff
int numSpotsDiff = 0;
if (swi.rightScan) {
numSpotsDiff = Math.abs(encA.getNumRightSpots() - encB.getNumRightSpots());
} else {
numSpotsDiff = Math.abs(encA.getNumSpots() - encB.getNumSpots());
}
boostString = boostString + ", " + Integer.toString(numSpotsDiff);
boostString = boostString + ";";
//add to the right boosting area, left sides are used for training, right sides are used for testing
if (swi.rightScan) {
test.append(("//" + encA.getEncounterNumber()) + " vs. " + encB.getEncounterNumber() + "\n");
test.append((boostString + "\n"));
} else {
train.append(("//" + encA.getEncounterNumber()) + " vs. " + encB.getEncounterNumber() + "\n");
train.append((boostString + "\n"));
}
//now let's populate the reference spots
String ref1x_A = "";
String ref1y_A = "";
String ref2x_A = "";
String ref2y_A = "";
String ref3x_A = "";
String ref3y_A = "";
String ref1x_B = "";
String ref1y_B = "";
String ref2x_B = "";
String ref2y_B = "";
String ref3x_B = "";
String ref3y_B = "";
//populate these for encA
if (swi.rightScan) {
if ((encA.getRightReferenceSpots() != null) && (encA.getRightReferenceSpots().size() > 0)) {
ref1x_A = Double.toString(encA.getRightReferenceSpots().get(0).getCentroidX());
ref1y_A = Double.toString(encA.getRightReferenceSpots().get(0).getCentroidY());
ref2x_A = Double.toString(encA.getRightReferenceSpots().get(1).getCentroidX());
ref2y_A = Double.toString(encA.getRightReferenceSpots().get(1).getCentroidY());
ref3x_A = Double.toString(encA.getRightReferenceSpots().get(2).getCentroidX());
ref3y_A = Double.toString(encA.getRightReferenceSpots().get(2).getCentroidY());
}
} else {
if ((encA.getLeftReferenceSpots() != null) && (encA.getLeftReferenceSpots().size() > 0)) {
ref1x_A = Double.toString(encA.getLeftReferenceSpots().get(0).getCentroidX());
ref1y_A = Double.toString(encA.getLeftReferenceSpots().get(0).getCentroidY());
ref2x_A = Double.toString(encA.getLeftReferenceSpots().get(1).getCentroidX());
ref2y_A = Double.toString(encA.getLeftReferenceSpots().get(1).getCentroidY());
ref3x_A = Double.toString(encA.getLeftReferenceSpots().get(2).getCentroidX());
ref3y_A = Double.toString(encA.getLeftReferenceSpots().get(2).getCentroidY());
}
}
//populate reference spots for encB
if (swi.rightScan) {
if ((encB.getRightReferenceSpots() != null) && (encB.getRightReferenceSpots().size() > 0)) {
ref1x_B = Double.toString(encB.getRightReferenceSpots().get(0).getCentroidX());
ref1y_B = Double.toString(encB.getRightReferenceSpots().get(0).getCentroidY());
ref2x_B = Double.toString(encB.getRightReferenceSpots().get(1).getCentroidX());
ref2y_B = Double.toString(encB.getRightReferenceSpots().get(1).getCentroidY());
ref3x_B = Double.toString(encB.getRightReferenceSpots().get(2).getCentroidX());
ref3y_B = Double.toString(encB.getRightReferenceSpots().get(2).getCentroidY());
}
} else {
if ((encB.getLeftReferenceSpots() != null) && (encB.getLeftReferenceSpots().size() > 0)) {
ref1x_B = Double.toString(encB.getLeftReferenceSpots().get(0).getCentroidX());
ref1y_B = Double.toString(encB.getLeftReferenceSpots().get(0).getCentroidY());
ref2x_B = Double.toString(encB.getLeftReferenceSpots().get(1).getCentroidX());
ref2y_B = Double.toString(encB.getLeftReferenceSpots().get(1).getCentroidY());
ref3x_B = Double.toString(encB.getLeftReferenceSpots().get(2).getCentroidX());
ref3y_B = Double.toString(encB.getLeftReferenceSpots().get(2).getCentroidY());
}
}
//Spot maps
String aSpot = "false";
String bSpot = "false";
if (swi.rightScan) {
try {
if (encB.rightSpotImageFileName.endsWith("-mapped.jpg")) {
bSpot = "true";
}
} catch (Exception f) {
f.printStackTrace();
System.out.println("I couldn't find the rightSpotImageFileName for encounter " + encB.getEncounterNumber());
}
if (encA.rightSpotImageFileName.endsWith("-mapped.jpg")) {
aSpot = "true";
}
} catch (Exception f) {
f.printStackTrace();
System.out.println("I couldn't find the rightSpotImageFileName for encounter " + encA.getEncounterNumber());
}
} else {
try {
if (encB.spotImageFileName.endsWith("-mapped.jpg")) {
bSpot = "true";
}
} catch (Exception f) {
f.printStackTrace();
System.out.println("I couldn't find the spotImageFileName for encounter " + encB.getEncounterNumber());
}
try {
if (encA.spotImageFileName.endsWith("-mapped.jpg")) {
aSpot = "true";
}
} catch (Exception f) {
f.printStackTrace();
System.out.println("I couldn't find the spotImageFileName for encounter " + encA.getEncounterNumber());
}
}
String side = "l";
if (swi.rightScan) {
side = "r";
}
}
//write out the Excel file
if (!request.getParameter("number").equals("TuningTask")) {
//finalize(workbook);
//workbook.close();
}
//let's finalize the boosting files
writeBoostFiles(train, test, request.getParameter("number"));
myShepherd.commitDBTransaction();
myShepherd.closeDBTransaction();
if (request.getParameter("number").equals("TuningTask")) {
String resultsURL = ("http://" + CommonConfiguration.getURLLocation(request) + "/appadmin/endTuningTask.jsp?number=TuningTask");
response.sendRedirect(resultsURL);
} else {
String resultsURL = ("http://" + CommonConfiguration.getURLLocation(request) + "/appadmin/endTuningTask.jsp?number=FalseMatchTask");
response.sendRedirect(resultsURL);
}
} catch (Exception e) {
myShepherd.rollbackDBTransaction();
System.out.println("writeOutScanTask registered the following error...");
e.printStackTrace();
statusText = "failure";
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
}
} |