Search in sources :

Example 1 with VectorComputation

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);
    });
}
Also used : VectorComputation(com.graphaware.nlp.vector.VectorComputation)

Example 2 with VectorComputation

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;
    }
}
Also used : VectorComputation(com.graphaware.nlp.vector.VectorComputation) NotSupportedException(javax.ws.rs.NotSupportedException) MethodNotSupportedException(org.apache.http.MethodNotSupportedException) VectorHandler(com.graphaware.nlp.vector.VectorHandler) VectorContainer(com.graphaware.nlp.domain.VectorContainer)

Example 3 with VectorComputation

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());
}
Also used : VectorComputation(com.graphaware.nlp.vector.VectorComputation)

Aggregations

VectorComputation (com.graphaware.nlp.vector.VectorComputation)3 VectorContainer (com.graphaware.nlp.domain.VectorContainer)1 VectorHandler (com.graphaware.nlp.vector.VectorHandler)1 NotSupportedException (javax.ws.rs.NotSupportedException)1 MethodNotSupportedException (org.apache.http.MethodNotSupportedException)1