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