Search in sources :

Example 1 with Description

use of org.neo4j.procedure.Description in project neo4j by neo4j.

the class BuiltInProcedures method listConstraints.

@Description("List all constraints in the database.")
@Procedure(name = "db.constraints", mode = READ)
public Stream<ConstraintResult> listConstraints() {
    Statement statement = tx.acquireStatement();
    ReadOperations operations = statement.readOperations();
    TokenNameLookup tokens = new StatementTokenNameLookup(operations);
    return asList(operations.constraintsGetAll()).stream().map((constraint) -> constraint.prettyPrint(tokens)).sorted().map(ConstraintResult::new).onClose(statement::close);
}
Also used : IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) ProcedureException(org.neo4j.kernel.api.exceptions.ProcedureException) Label(org.neo4j.graphdb.Label) Context(org.neo4j.procedure.Context) Status(org.neo4j.kernel.api.exceptions.Status) Iterators.asSet(org.neo4j.helpers.collection.Iterators.asSet) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) Statement(org.neo4j.kernel.api.Statement) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) ArrayList(java.util.ArrayList) TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) Procedure(org.neo4j.procedure.Procedure) TokenAccess(org.neo4j.kernel.impl.api.TokenAccess) ReadOperations(org.neo4j.kernel.api.ReadOperations) Set(java.util.Set) READ(org.neo4j.procedure.Mode.READ) Description(org.neo4j.procedure.Description) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Stream(java.util.stream.Stream) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Iterators.asList(org.neo4j.helpers.collection.Iterators.asList) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Name(org.neo4j.procedure.Name) RelationshipType(org.neo4j.graphdb.RelationshipType) Comparator(java.util.Comparator) ReadOperations(org.neo4j.kernel.api.ReadOperations) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) Statement(org.neo4j.kernel.api.Statement) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 2 with Description

use of org.neo4j.procedure.Description in project neo4j-nlp by graphaware.

the class AnnotateProcedure method filter.

@Procedure(name = "ga.nlp.filter", mode = Mode.WRITE)
@Description("Boolean filter for text accordingly to complex filter definition")
public Stream<SingleResult> filter(@Name("filterRequest") Map<String, Object> filterRequest) {
    FilterRequest request = FilterRequest.fromMap(filterRequest);
    Object result = getNLPManager().filter(request);
    return Stream.of(new SingleResult(result));
}
Also used : SingleResult(com.graphaware.nlp.dsl.result.SingleResult) FilterRequest(com.graphaware.nlp.dsl.request.FilterRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 3 with Description

use of org.neo4j.procedure.Description in project neo4j-nlp by graphaware.

the class TextProcessorsProcedure method addPipeline.

@Procedure(name = "ga.nlp.processor.addPipeline", mode = Mode.WRITE)
@Description("Add custom pipeline to a Text Processor")
public Stream<SingleResult> addPipeline(@Name("addPipelineRequest") Map<String, Object> addPipelineRequest) {
    try {
        PipelineSpecification request = mapper.convertValue(addPipelineRequest, PipelineSpecification.class);
        getNLPManager().addPipeline(request);
        return Stream.of(SingleResult.success());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 4 with Description

use of org.neo4j.procedure.Description in project neo4j-nlp by graphaware.

the class TextProcessorsProcedure method test.

@Procedure(name = "ga.nlp.processor.test", mode = Mode.WRITE)
@Description("Procedure for testing custom models.")
public Stream<SingleResult> test(@Name("customModelsRequest") Map<String, Object> customModelsRequest) {
    try {
        CustomModelsRequest request = CustomModelsRequest.fromMap(customModelsRequest);
        Object result = getNLPManager().test(request);
        return Stream.of(new SingleResult(result));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : SingleResult(com.graphaware.nlp.dsl.result.SingleResult) CustomModelsRequest(com.graphaware.nlp.dsl.request.CustomModelsRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 5 with Description

use of org.neo4j.procedure.Description in project neo4j-nlp by graphaware.

the class TextRankProcedure method textRankPostprocess.

@Procedure(name = "ga.nlp.ml.textRank.postprocess", mode = Mode.WRITE)
@Description("TextRank post-processing procedure")
public Stream<SingleResult> textRankPostprocess(@Name("textRankRequest") Map<String, Object> textRankRequest) {
    try {
        TextRankPostprocessRequest request = TextRankPostprocessRequest.fromMap(textRankRequest);
        TextRankProcessor processor = (TextRankProcessor) getNLPManager().getExtension(TextRankProcessor.class);
        return Stream.of(processor.postprocess(request));
    } catch (Exception e) {
        LOG.error("ERROR in TextRank", e);
        throw new RuntimeException(e);
    }
}
Also used : TextRankPostprocessRequest(com.graphaware.nlp.dsl.request.TextRankPostprocessRequest) TextRankProcessor(com.graphaware.nlp.ml.textrank.TextRankProcessor) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Aggregations

Description (org.neo4j.procedure.Description)65 Procedure (org.neo4j.procedure.Procedure)58 SystemProcedure (org.neo4j.kernel.api.procedure.SystemProcedure)25 ArrayList (java.util.ArrayList)19 Node (org.neo4j.graphdb.Node)15 HashMap (java.util.HashMap)14 Stream (java.util.stream.Stream)14 Map (java.util.Map)13 Context (org.neo4j.procedure.Context)13 Name (org.neo4j.procedure.Name)13 Collectors (java.util.stream.Collectors)12 Relationship (org.neo4j.graphdb.Relationship)12 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)12 ZoneId (java.time.ZoneId)11 Comparator (java.util.Comparator)11 List (java.util.List)11 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)11 Status (org.neo4j.kernel.api.exceptions.Status)11 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)11 Admin (org.neo4j.procedure.Admin)11