diff --git a/src/clickTrainDetector/classification/standardClassifier/StandardClassificationJSON.java b/src/clickTrainDetector/classification/standardClassifier/StandardClassificationJSON.java index da0009d1..6c609119 100644 --- a/src/clickTrainDetector/classification/standardClassifier/StandardClassificationJSON.java +++ b/src/clickTrainDetector/classification/standardClassifier/StandardClassificationJSON.java @@ -1,10 +1,22 @@ package clickTrainDetector.classification.standardClassifier; +import java.io.ByteArrayInputStream; +import java.io.IOException; + import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import clickTrainDetector.classification.CTClassification; import clickTrainDetector.classification.SimpleClassifierJSONLogging; +import clickTrainDetector.classification.bearingClassifier.BearingClassification; +import clickTrainDetector.classification.bearingClassifier.BearingClassifier; +import clickTrainDetector.classification.idiClassifier.IDIClassification; +import clickTrainDetector.classification.idiClassifier.IDIClassifier; +import clickTrainDetector.classification.simplechi2classifier.Chi2CTClassification; +import clickTrainDetector.classification.simplechi2classifier.Chi2ThresholdClassifier; +import clickTrainDetector.classification.templateClassifier.CTTemplateClassifier; +import clickTrainDetector.classification.templateClassifier.TemplateClassification; /** @@ -25,6 +37,11 @@ public class StandardClassificationJSON extends SimpleClassifierJSONLogging { this.standardClassifier=ctClassifications; } + public StandardClassificationJSON() { + + } + + @Override public void writeJSONData(JsonGenerator jg, CTClassification ctClassification) { @@ -35,27 +52,59 @@ public class StandardClassificationJSON extends SimpleClassifierJSONLogging { @Override - public CTClassification createClassification(JsonNode jTree) { - - JsonNode na = jTree.findValue("SPECIES"); - int speciesID; - if (na != null ) { - speciesID = na.asInt(); - } - else { - System.err.println("Cannot load template classifier"); - return null; - } + public CTClassification createClassification(String jsonString) { + try { + ObjectMapper om = new ObjectMapper(); + JsonNode jTree = om.readTree(new ByteArrayInputStream(jsonString.getBytes())); + // JsonNode nv = jTree.findValue("NAME"); - CTClassification[] ctClassification = new CTClassification[standardClassifier.length]; - for (int i=0; i