### Question:
NgramModel implements Serializable { protected void addSubstrings(String context, String text) { if (text.length() < 1) { throw new IllegalArgumentException("Cannot extract n-grams from empty text"); } String s = context + text; for (int high = context.length() + 1; high <= s.length(); ++high) { for (int low = Math.max(0, high - order); low < high; ++low) { addEntry(s.substring(low, high)); } } addEntries("", text.length()); } NgramModel(int order);  NgramModel(File file); int size(); void save(File file); double[] getGoodTuringPars(); int occurrences(String key); void addWord(String word); void addWords(File file, Charset encoding, boolean caseSensitive); double logWordProb(String word); double logPerWordLikelihood(boolean caseSensitive); void addText(InputStream is); double logLikelihood(InputStream is, int contextLength); double logLikelihood(String context, String input); double logProb(String context, char c); @Override String toString(); void showDiff(NgramModel other); boolean equals(NgramModel other); @Override boolean equals(Object o); @Override int hashCode(); static void main(String[] args);  }### Answer:
@Test public void testAddSubstrings() { System.out.println("addSubstrings"); String EOS = String.valueOf(NgramModel.EOS); NgramModel ngrams = new NgramModel(3); NgramModel ref = new NgramModel(3); ngrams.addSubstrings("b", "cde"); ref.addEntry("bcd"); ref.addEntry("cde"); ref.addEntry("bc"); ref.addEntry("cd"); ref.addEntry("de"); ref.addEntry("c"); ref.addEntry("d"); ref.addEntry("e"); ref.addEntries("", 3); ref.showDiff(ngrams); assertEquals(ref, ngrams); }