use of com.graphaware.nlp.persistence.persisters.KeywordPersister in project neo4j-nlp by graphaware.
the class TextRankPersister method persistKeywords.
public void persistKeywords(Map<String, Keyword> results, Node annotatedText) {
List<String> printKeywords = new ArrayList<>();
KeywordPersister persister = NLPManager.getInstance().getPersister(Keyword.class);
persister.setLabel(keywordLabel);
results.entrySet().stream().forEach(en -> {
// check keyword consistency
if (en.getKey().split("_").length > 2) {
LOG.warn("Tag " + en.getKey() + " has more than 1 underscore symbols, newly created " + keywordLabel.name() + " node might be wrong.");
}
Node newNode = persister.persist(en.getValue(), en.getKey(), String.valueOf(System.currentTimeMillis()));
if (newNode != null) {
// LOG.info("New node has labels: " + iterableToList(newNode.getLabels()).stream().map(l -> l.name()).collect(Collectors.joining(", ")));
Relationship rel = mergeRelationship(annotatedText, newNode);
rel.setProperty("count_exactMatch", en.getValue().getExactMatchCount());
rel.setProperty("count", en.getValue().getTotalCount());
rel.setProperty("relevance", en.getValue().getRelevance());
}
printKeywords.add(en.getKey().split("_")[0]);
});
LOG.debug("--- TextRank results: \n " + printKeywords.stream().collect(Collectors.joining("\n ")));
}
use of com.graphaware.nlp.persistence.persisters.KeywordPersister in project neo4j-nlp by graphaware.
the class TextRank method peristKeyword.
private void peristKeyword(Map<String, Keyword> results, Node annotatedText) {
LOG.info("--- Results: ");
KeywordPersister persister = NLPManager.getInstance().getPersister(Keyword.class);
persister.setLabel(keywordLabel);
results.entrySet().stream().forEach(en -> {
// check keyword consistency
if (en.getKey().split("_").length > 2) {
LOG.warn("Tag " + en.getKey() + " has more than 1 underscore symbols, newly created " + keywordLabel.name() + " node might be wrong.");
}
Node newNode = persister.persist(en.getValue(), en.getKey(), String.valueOf(System.currentTimeMillis()));
if (newNode != null) {
// LOG.info("New node has labels: " + iterableToList(newNode.getLabels()).stream().map(l -> l.name()).collect(Collectors.joining(", ")));
Relationship rel = mergeRelationship(annotatedText, newNode);
rel.setProperty("count_exactMatch", en.getValue().getExactMatchCount());
rel.setProperty("count", en.getValue().getTotalCount());
rel.setProperty("relevance", en.getValue().getRelevance());
}
LOG.info(en.getKey().split("_")[0]);
});
}
Aggregations