Search in sources :

Example 41 with Description

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

the class Strings method regexGroups.

@UserFunction
@Description("apoc.text.regexGroups(text, regex) - return all matching groups of the regex on the given text.")
public List<List<String>> regexGroups(@Name("text") final String text, @Name("regex") final String regex) {
    if (text == null || regex == null) {
        return Collections.EMPTY_LIST;
    } else {
        final Pattern pattern = Pattern.compile(regex);
        final Matcher matcher = pattern.matcher(text);
        List<List<String>> result = new ArrayList<>();
        while (matcher.find()) {
            List<String> matchResult = new ArrayList<>();
            for (int i = 0; i <= matcher.groupCount(); i++) {
                matchResult.add(matcher.group(i));
            }
            result.add(matchResult);
        }
        return result;
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Arrays.asList(java.util.Arrays.asList) Description(org.neo4j.procedure.Description) UserFunction(org.neo4j.procedure.UserFunction)

Example 42 with Description

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

the class ComputeVectorProcedure method annotate.

@Procedure(name = "ga.nlp.vector.compute", mode = Mode.WRITE)
@Description("Compute vectors for input node and store vector in the property specified")
public Stream<NodeResult> annotate(@Name("computeVectorRequest") Map<String, Object> computeVectorRequest) {
    try {
        ComputeVectorRequest request = ComputeVectorRequest.fromMap(computeVectorRequest);
        Node result = getNLPManager().computeVectorAndPersist(request);
        return Stream.of(new NodeResult(result));
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : NodeResult(com.graphaware.nlp.dsl.result.NodeResult) Node(org.neo4j.graphdb.Node) ComputeVectorRequest(com.graphaware.nlp.dsl.request.ComputeVectorRequest) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 43 with Description

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

the class EnrichConceptProcedure method annotate.

@Procedure(name = "ga.nlp.enrich.concept", mode = Mode.WRITE)
@Description("Enrich knowledge concepts by consulting external knowledge bases like ConceptNet5 or Microsoft Concept Graphs")
public Stream<NodeResult> annotate(@Name("conceptRequest") Map<String, Object> conceptRequest) {
    ConceptRequest request = ConceptRequest.fromMap(conceptRequest);
    Enricher enricher = getNLPManager().getEnricher(request.getEnricherName());
    Node result = enricher.importConcept(request);
    return Stream.of(new NodeResult(result));
}
Also used : NodeResult(com.graphaware.nlp.dsl.result.NodeResult) Node(org.neo4j.graphdb.Node) ConceptRequest(com.graphaware.nlp.dsl.request.ConceptRequest) Enricher(com.graphaware.nlp.enrich.Enricher) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 44 with Description

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

the class EnrichConceptProcedure method list.

@Procedure(name = "ga.nlp.enrichers.list", mode = Mode.READ)
@Description("List enrichers available")
public Stream<EnricherList> list() {
    Map<String, Enricher> enrichers = getNLPManager().getEnrichmentRegistry().getEnrichers();
    List<EnricherList> list = new ArrayList<>();
    enrichers.values().forEach(e -> {
        list.add(new EnricherList(e.getName(), e.getAlias()));
    });
    return list.stream();
}
Also used : ArrayList(java.util.ArrayList) EnricherList(com.graphaware.nlp.dsl.result.EnricherList) Enricher(com.graphaware.nlp.enrich.Enricher) Description(org.neo4j.procedure.Description) Procedure(org.neo4j.procedure.Procedure)

Example 45 with Description

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

the class PageRankProcedure method computePageRank.

@Procedure(name = "ga.nlp.ml.pageRank", mode = Mode.WRITE)
@Description("PageRank procedure")
public Stream<SingleResult> computePageRank(@Name("pageRankRequest") Map<String, Object> pageRankRequest) {
    PageRankRequest request = mapper.convertValue(pageRankRequest, PageRankRequest.class);
    PageRankProcessor processor = (PageRankProcessor) getNLPManager().getExtension(PageRankProcessor.class);
    return Stream.of(processor.process(request));
}
Also used : PageRankProcessor(com.graphaware.nlp.ml.pagerank.PageRankProcessor) PageRankRequest(com.graphaware.nlp.dsl.request.PageRankRequest) 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