### Question:
LangProfile { public void omitLessFreq() { if (name == null) return; int threshold = n_words[0] / LESS_FREQ_RATIO; if (threshold < MINIMUM_FREQ) threshold = MINIMUM_FREQ; Set<String> keys = freq.keySet(); int roman = 0; for(Iterator<String> i = keys.iterator(); i.hasNext(); ){ String key = i.next(); int count = freq.get(key); if (count <= threshold) { n_words[key.length()-1] -= count; i.remove(); } else { if (key.matches("^[A-Za-z]$")) { roman += count; } } } if (roman < n_words[0] / 3) { Set<String> keys2 = freq.keySet(); for(Iterator<String> i = keys2.iterator(); i.hasNext(); ){ String key = i.next(); if (key.matches(".*[A-Za-z].*")) { n_words[key.length()-1] -= freq.get(key); i.remove(); } } } } LangProfile();  LangProfile(String name); void add(String gram); void omitLessFreq(); void update(String text); public String name; public HashMap<String, Integer> freq; public int[] n_words; }### Answer:
@Test public final void testOmitLessFreq() { LangProfile profile = new LangProfile("en"); String[] grams = "a b c \u3042 \u3044 \u3046 \u3048 \u304a \u304b \u304c \u304d \u304e \u304f".split(" "); for (int i=0;i<5;++i) for (String g : grams) { profile.add(g); } profile.add("\u3050"); assertEquals((int)profile.freq.get("a"), 5); assertEquals((int)profile.freq.get("\u3042"), 5); assertEquals((int)profile.freq.get("\u3050"), 1); profile.omitLessFreq(); assertEquals(profile.freq.get("a"), null); assertEquals((int)profile.freq.get("\u3042"), 5); assertEquals(profile.freq.get("\u3050"), null); }
@Test public final void testOmitLessFreqIllegally() { LangProfile profile = new LangProfile(); profile.omitLessFreq(); }