### Question:
NgramModel implements Serializable { public double[] getGoodTuringPars() { double[] pars = new double[order]; int[] total = new int[order]; int[] singles = new int[order]; for (String word : occur.keySet()) { if (word.length() > 0) { int k = word.length() - 1; int times = occur.get(word).getValue(); total[k] += times; if (times == 1) { ++singles[k]; } } } for (int k = 0; k < order; ++k) { pars[k] = singles[k] / (double) total[k]; } return pars; } 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 testGetGoodTuringPars() { System.out.println("size"); NgramModel ngrams = new NgramModel(3); ngrams.addWord("0000"); ngrams.addWord("0100"); double[] expResult = {0.1, 0.2, 0.5}; double[] result = ngrams.getGoodTuringPars(); assertEquals(expResult.length, result.length); for (int n = 0; n < result.length; ++n) { assertEquals(expResult[n], result[n], 0.001); } }