use of com.graphaware.nlp.vector.VectorComputation in project neo4j-nlp by graphaware.
the class NLPManager method loadVectorComputationProcesses.
private void loadVectorComputationProcesses() {
Map<String, VectorComputation> extensionMap = ServiceLoader.loadInstances(NLPVectorComputationProcess.class);
extensionMap.keySet().forEach(k -> {
VectorComputation extension = extensionMap.get(k);
extension.setDatabase(database);
vectorComputationProcesses.put(extension.getType(), extension);
});
}
use of com.graphaware.nlp.vector.VectorComputation 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.vector.VectorComputation in project neo4j-nlp by graphaware.
the class NLPManager method computeVectorTrainAndPersist.
public void computeVectorTrainAndPersist(ComputeVectorTrainRequest request) {
VectorComputation vectorComputation = vectorComputationProcesses.get(request.getType());
if (vectorComputation == null) {
throw new RuntimeException("Cannot find the VectorComputation instance with type: " + request.getType());
}
vectorComputation.train(request.getParameters());
}
Aggregations