use of com.graphaware.nlp.domain.VectorContainer in project neo4j-nlp by graphaware.
the class NLPManager method computeVectorAndPersist.
public Node computeVectorAndPersist(ComputeVectorRequest request) {
try {
VectorComputation vectorComputation = vectorComputationProcesses.get(request.getType());
if (vectorComputation == null) {
throw new RuntimeException("Cannot find the VectorComputation instance with type: " + request.getType());
}
VectorHandler vector = vectorComputation.computeSparseVector(request.getInput().getId(), request.getParameters());
if (vector != null) {
VectorContainer vectorNode = new VectorContainer(request.getInput().getId(), request.getPropertyName(), vector);
getPersister(vectorNode.getClass()).persist(vectorNode, request.getLabel(), null);
}
return request.getInput();
} catch (Exception ex) {
LOG.error("Error in computeVectorAndPersist", ex);
throw ex;
}
}
use of com.graphaware.nlp.domain.VectorContainer in project neo4j-nlp by graphaware.
the class VectorPersister method fromNode.
@Override
public VectorContainer fromNode(Node node, Object... properties) {
String basePropertyname = (String) properties[0];
String type = (String) node.getProperty(getTypePropertyName(basePropertyname));
float[] vector = (float[]) node.getProperty(getArrayPropertyName(basePropertyname));
VectorHandler createVector = VectorFactory.createVector(type, vector);
return new VectorContainer(node.getId(), basePropertyname, createVector);
}
Aggregations