title: Modifying a Generalised Suffix Tree to hold number of times a node appears in the text string
body: <p>How do I modify the procedure in <a href="http://www.cs.helsinki.fi/u/ukkonen/SuffixT1withFigs.pdf" rel="nofollow noreferrer">Ukkonen's paper</a> to hold a value for number of times a word appears in the text. Are there any such implementations available that provide the string frequency as well?</p>
  
  <p>The modification I want is like for a string "hehe" the frequency count for all "h","e","he" should be 2 in the tree. Rest nodes have the default value 1.</p>
  
  <p>I found some libraries like <a href="https://geekli.st/abahgat/repos/suffixtree" rel="nofollow noreferrer">the best so far</a> and some previous questions like <a href="https://stackoverflow.com/questions/969448/generalized-suffix-tree-java-implementation">this</a>.</p>
  
  <p>But none of them describes a good enough solution to my problem. Also I have to process a very large dictionary file (about a billion words). Then the algorithm needs to be really fast. And I am ready to compromize on space a bit.</p>