}
private static Concept parseConcept(XPath xpath, Element conceptElem)
throws XPathExpressionException {
Concept c = new Concept();
c.setName(xpath.evaluate("@name", conceptElem));
String description = xpath.evaluate("description/text()", conceptElem);
if (StringUtils.isNotBlank(description)) {
c.setDescription(description);
}
/* threshold parameter */
Element thresholdParam = (Element) xpath.evaluate("param[@name='threshold']", conceptElem,
XPathConstants.NODE);
Double threshold = null;
if (thresholdParam != null) {
threshold = Double.parseDouble(xpath.evaluate("@value", thresholdParam));
}
/* act attribute */
String actAttr = conceptElem.getAttribute("act");
if ("SIGNUM".equals(actAttr)) {
SignumActivator act = new SignumActivator();
if (threshold != null) {
act.setThreshold(threshold);
}
c.setConceptActivator(act);
} else if ("SIGMOID".equals(actAttr)) {
SigmoidActivator act = new SigmoidActivator();
Element kParam = (Element) xpath.evaluate("param[@name='k']", conceptElem,
XPathConstants.NODE);
Double k = null;
if (kParam != null) {
k = Double.parseDouble(xpath.evaluate("@value", kParam));
}
if (k != null) {
act.setK(k);
}
c.setConceptActivator(act);
} else if ("TANH".equals(actAttr)) {
HyperbolicTangentActivator act = new HyperbolicTangentActivator();
/* add alpha parameter */
Element alphaParam = (Element) xpath.evaluate("param[@name='alpha']", conceptElem,
XPathConstants.NODE);
Double alpha = null;
if (alphaParam != null) {
alpha = Double.parseDouble(xpath.evaluate("@value", alphaParam));
}
if (alpha != null) {
act.setAlpha(alpha);
}
if (threshold != null) {
act.setThreshold(threshold);
}
c.setConceptActivator(act);
} else if ("IDENTITY".equals(actAttr)) {
IdentityActivator act = new IdentityActivator();
c.setConceptActivator(act);
}
String s;
s = xpath.evaluate("@input", conceptElem);
if (StringUtils.isNotBlank(s)) {
c.setInput(Double.parseDouble(s));
}
s = xpath.evaluate("@output", conceptElem);
if (StringUtils.isNotBlank(s)) {
c.setOutput(Double.parseDouble(s));
}
s = xpath.evaluate("@fixed", conceptElem);
if (StringUtils.isNotBlank(s)) {
c.setFixedOutput(Boolean.parseBoolean(s));
}
return c;
}