concept text in category graphs

This is an excerpt from Manning's book Graph Powered Machine Learning.
The Figure 1.2, from [Banko and Brill, 2001], shows the learning curves for some learner considering the average accuracy performance from few up to one billion words of training data. The specific algorithm works on text in order to disambiguate words, but now is not relevant the specific type of algorithm since the concept it is valid in general terms. As appear clearly from the image, the performance of the learner are improved, increasing the amount and the quality of the data available during the training phase. These results suggest how to reconsider the trade-off between spending time and money on algorithm development versus spending it on corpus development. On another perspective, as data scientist you can focus on the vertical dimension - finding a better algorithm - but the graph shows that there is more room for improvement in the horizontal direction - gather more data. As a proof, the worse algorithm in the graph with 10M elements performs much better than the best one with 1M element.
Text, text, and more text! We are surrounded by textual data. Much of the world’s knowledge is stored and shared using text in natural language. This has been true since the beginning of human history, when we started sharing knowledge in different languages—first just by voice and later, to make it permanent, by writing.
Natural language is the way in which we interact with other humans. We begin learning it as infants—yet understanding language is one of the most complex tasks a machine can do. Nevertheless, computer scientists, data scientists, and machine learning practitioners have worked hard to make machines capable of dealing with textual data, providing for complex solutions that leverage text to offer advanced features to the final users. Let’s consider the most common solutions that you likely use every day, probably without even noticing just how complex and useful they are.
Chapter 4 dealt with text to implement a recommendation engine that uses the “contents” related to the items, such as the description of a product or a movie plot. In that case this data was used to compare items or user profiles, find commonalities (or, more specifically, similarities) among users or items, and leverage them to suggest something that might be of interest to the current user.
Figure 11.1 A content-based recommendation engine as presented in chapter 4
![]()
The Items Analyzer and User Profilers Builder deal with text to make it available during the recommendation phase. The result of their analysis is stored in such a way that is it easy to access and query during the model generation and the recommendation process.
For many years now, the search engine has been perhaps the most critical type of application dealing with text, providing relevant results to users while they are looking for something. Think about Google and Yahoo! Without search engines like these, the internet simply wouldn’t have been the same; there would have been no useful way to discover new content or access the huge wealth of resources it offers, and as a result it might never have grown to the scale it has. Searching is the most common technique we use to interact with a variety of content sources (news sites, retail sites, databases, and more). It helps us gain access to relevant data in an intuitive and effective way. Figure 11.2 shows a simplified schema of a search engine [Turnbul and Berryman, 2016].
The following Cypher query shows how to process the text and obtain the expected graph database.
Query 11.1 Splitting a sentence using whitespace and storing it according to the model
WITH split("You will not be able to send new mail until you upgrade your email."," ") as words UNWIND range(0, size(words)-2) as idx MERGE (w1:Word {value:words[idx]}) MERGE (w2:Word {value:words[idx+1]}) CREATE (w1)-[:NEXT]->(w2);In this query, the WITH clause at the beginning provides data to the next query statement. Note how split() defines the “tokenization” process based on whitespace, which is specified as the delimiter in the second parameter. The range() function creates a range of numbers, in this case from 0 to the size of the sentence—obtained by using the size() function on the text—minus 2. The UNWIND clause turns the range collection into result rows with the index value to use to get the right word. The MERGE clause, as usual, helps us to avoid creating the same node (the same word, in this scenario) twice. At the end, we use CREATE to store the relationships between two consecutive words.