code: private void processUserDictionary(final String text, ViterbiLattice lattice) {
          List<UserDictionary.UserDictionaryMatch> matches = userDictionary.findUserDictionaryMatches(text);
  
          for (UserDictionary.UserDictionaryMatch match : matches) {
              int wordId = match.getWordId();
              int index = match.getMatchStartIndex();
              int length = match.getMatchLength();
  
              String word = text.substring(index, index + length);
  
              ViterbiNode node = new ViterbiNode(wordId, word, userDictionary, index, ViterbiNode.Type.USER);
              int nodeStartIndex = index + 1;
              int nodeEndIndex = nodeStartIndex + length;
  
              lattice.addNode(node, nodeStartIndex, nodeEndIndex);
  
              if (isLatticeBrokenBefore(nodeStartIndex, lattice)) {
                  repairBrokenLatticeBefore(lattice, index);
              }
  
              if (isLatticeBrokenAfter(nodeStartIndex + length, lattice)) {
                  repairBrokenLatticeAfter(lattice, nodeEndIndex);
              }
          }
      }
docs: Find token(s) in input text and set found token(s) in arrays as normal tokens
  
  @param text
  @param lattice