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);
}
}
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);
}
}
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);
}
}
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);
}
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();
}
Aggregations