›Scoring text where the data lives
1.1 · Lesson

Scoring text where the data lives

Suppose you have a graph of stocks, their daily prices and the news headlines written about them. You want each headline to carry a sentiment score, without calling an outside service and without sending every headline through your application.

A common route is to score each headline in the application and write the result back, which costs a round trip for every headline. Instead, you can write a Java plugin that adds a function, sentiment.score, which runs the VADER sentiment library inside the database. CypherNeo4j's implementation of GQL, the ISO standard query language for graph databases. It is declarative: you describe the pattern to find, and the database decides how to find it. calls it like any built-in function, so each headline is scored as it is loaded: