Search in sources :

Example 6 with Description

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

the class TextRankProcedure method computeTextRank.

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

Example 7 with Description

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

the class TextRankProcedure method summarizeText.

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

Example 8 with Description

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

the class WorkflowTaskProcedure method stop.

@Procedure(name = "ga.nlp.workflow.task.stop", mode = Mode.WRITE)
@Description("Start a Task")
public Stream<WorkflowInstanceItemInfo> stop(@Name(value = "name") String name) {
    try {
        WorkflowTask workflowTask = getWorkflowManager().getWorkflowTask(name);
        if (workflowTask == null) {
            throw new RuntimeException("Pipeline task not found");
        }
        TaskManager.getInstance().stop(workflowTask);
        return Stream.of(workflowTask.getInfo());
    } catch (Exception e) {
        LOG.error("ERROR in WorkflowTaskProcedure", e);
        throw new RuntimeException(e);
    }
}
Also used : WorkflowTask(com.graphaware.nlp.workflow.task.WorkflowTask) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 9 with Description

use of org.neo4j.procedure.Description in project neo4j-apoc-procedures by neo4j-contrib.

the class Numbers method format.

@UserFunction
@Description("apoc.number.format(number)  | format a long or double using the default system pattern and language to produce a string")
public String format(@Name("number") final Object value, @Name(value = "pattern", defaultValue = "") String pattern, @Name(value = "lang", defaultValue = "") String lang) {
    Number number = validateNumberParam(value);
    if (number == null)
        return null;
    DecimalFormat format = buildFormatter(pattern, lang);
    if (format == null)
        return null;
    return format.format(number);
}
Also used : DecimalFormat(java.text.DecimalFormat) Description(org.neo4j.procedure.Description) UserFunction(org.neo4j.procedure.UserFunction)

Example 10 with Description

use of org.neo4j.procedure.Description in project neo4j-apoc-procedures by neo4j-contrib.

the class Strings method random.

@UserFunction
@Description("apoc.text.random(length, valid) YIELD value - generate a random string")
public String random(@Name("length") final long length, @Name(value = "valid", defaultValue = "A-Za-z0-9") String valid) {
    valid = valid.replaceAll("A-Z", upper).replaceAll("a-z", lower).replaceAll("0-9", numeric);
    StringBuilder output = new StringBuilder(toIntExact(length));
    ThreadLocalRandom rand = ThreadLocalRandom.current();
    while (output.length() < length) {
        output.append(valid.charAt(rand.nextInt(valid.length())));
    }
    return output.toString();
}
Also used : ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Description(org.neo4j.procedure.Description) UserFunction(org.neo4j.procedure.UserFunction)

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