Preprocessor { public static Set<String> find_abbreviations(File file) { if (!file.canRead()) { throw new IllegalArgumentException(file + " is non-existent or not readable"); } String[] potentials = find_potential_abbreviations(file).toArray( new String[] {}); Set<String> confirmed_abbreviations = new HashSet<String>(); for (int i = 0; i < potentials.length; i++) { potentials[i] = potentials[i].substring(0, potentials[i].length() - 1); } String regexpr = "\\b("; for (String str : potentials) { regexpr += str.replaceAll("\\.", "\\\\.") + "|"; } regexpr = regexpr.substring(0, regexpr.length() - 1) + ")\\b"; Pattern p = Pattern.compile(regexpr); HashMap<String, Double> proportions_dot = new HashMap<String, Double>( potentials.length); HashMap<String, Integer> total_occurences = new HashMap<String, Integer>( potentials.length); for (String str : potentials) { proportions_dot.put(str, 0.0); total_occurences.put(str, 0); } try { BufferedReader f = new BufferedReader(new FileReader(file)); String line; while ((line = f.readLine()) != null) { Matcher m = p.matcher(line); while (m.find()) { double old_prop = proportions_dot.get(m.group()); int old_total = total_occurences.get(m.group()); int new_total = old_total + 1; if (line.length() > m.end() && line.charAt(m.end()) == '.') { proportions_dot.put(m.group(), old_prop * old_total / new_total + 1.0 / new_total); total_occurences.put(m.group(), new_total); } else { proportions_dot.put(m.group(), old_prop * old_total / new_total); total_occurences.put(m.group(), new_total); } } } for (String str : potentials) { if (proportions_dot.get(str) > 0.9 && (total_occurences.get(str) > 1 || str.contains("."))) { confirmed_abbreviations.add(str + "."); } } } catch (FileNotFoundException e) { e.printStackTrace(); System.exit(-1); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } return confirmed_abbreviations; }  static void main(String[] args); static String preprocess(String file); static void removeuseless(String filename, String outfilename); static void usecomma(String filename, String outfilename,
			String charactersplit); static Set<String> find_abbreviations(File file); static Set<String> find_potential_abbreviations(File file); static Set<String> find_simple_regex_abbreviations(File file); static void removeBOM(String filename);  }
@Ignore @Test public void testFind_abbreviations() { fail("Not yet implemented"); }