@Test public void testCalc_and_sum_frac() { System.out.println("calc_and_sum_frac"); assertEquals((Double) 1.5,(Double) Numek.calc_and_sum_frac("1 1/2")); }
public static Double calc_and_sum_frac(String snumber) { if (snumber.matches("([0-9]+ )?[0-9]+/[0-9]+")) { String[] temp; if (snumber.contains(" ")) { temp = snumber.split(" "); return Double.parseDouble(temp[0]) + Double.parseDouble(temp[1].substring(0, temp[1].indexOf('/'))) / Double.parseDouble(temp[1].substring(temp[1].indexOf('/') + 1)); } else { return Double.parseDouble(snumber.substring(0, snumber.indexOf('/'))) / Double.parseDouble(snumber.substring(snumber.indexOf('/') + 1)); } } else { if (System.getProperty("DEBUG") != null && System.getProperty("DEBUG").equalsIgnoreCase("true")) { System.err.println("Warining: error normalizing fraction (" + snumber + ") it has been set to 0.0 by default."); } return 0.0; } }
Numek { public static Double calc_and_sum_frac(String snumber) { if (snumber.matches("([0-9]+ )?[0-9]+/[0-9]+")) { String[] temp; if (snumber.contains(" ")) { temp = snumber.split(" "); return Double.parseDouble(temp[0]) + Double.parseDouble(temp[1].substring(0, temp[1].indexOf('/'))) / Double.parseDouble(temp[1].substring(temp[1].indexOf('/') + 1)); } else { return Double.parseDouble(snumber.substring(0, snumber.indexOf('/'))) / Double.parseDouble(snumber.substring(snumber.indexOf('/') + 1)); } } else { if (System.getProperty("DEBUG") != null && System.getProperty("DEBUG").equalsIgnoreCase("true")) { System.err.println("Warining: error normalizing fraction (" + snumber + ") it has been set to 0.0 by default."); } return 0.0; } } }
Numek { public static Double calc_and_sum_frac(String snumber) { if (snumber.matches("([0-9]+ )?[0-9]+/[0-9]+")) { String[] temp; if (snumber.contains(" ")) { temp = snumber.split(" "); return Double.parseDouble(temp[0]) + Double.parseDouble(temp[1].substring(0, temp[1].indexOf('/'))) / Double.parseDouble(temp[1].substring(temp[1].indexOf('/') + 1)); } else { return Double.parseDouble(snumber.substring(0, snumber.indexOf('/'))) / Double.parseDouble(snumber.substring(snumber.indexOf('/') + 1)); } } else { if (System.getProperty("DEBUG") != null && System.getProperty("DEBUG").equalsIgnoreCase("true")) { System.err.println("Warining: error normalizing fraction (" + snumber + ") it has been set to 0.0 by default."); } return 0.0; } } Numek();  Numek(Locale l);  Numek(Locale l, String resources_dir); }
Numek { public static Double calc_and_sum_frac(String snumber) { if (snumber.matches("([0-9]+ )?[0-9]+/[0-9]+")) { String[] temp; if (snumber.contains(" ")) { temp = snumber.split(" "); return Double.parseDouble(temp[0]) + Double.parseDouble(temp[1].substring(0, temp[1].indexOf('/'))) / Double.parseDouble(temp[1].substring(temp[1].indexOf('/') + 1)); } else { return Double.parseDouble(snumber.substring(0, snumber.indexOf('/'))) / Double.parseDouble(snumber.substring(snumber.indexOf('/') + 1)); } } else { if (System.getProperty("DEBUG") != null && System.getProperty("DEBUG").equalsIgnoreCase("true")) { System.err.println("Warining: error normalizing fraction (" + snumber + ") it has been set to 0.0 by default."); } return 0.0; } } Numek();  Numek(Locale l);  Numek(Locale l, String resources_dir); static Double calc_and_sum_frac(String snumber); String text2number(String snumber); final String disambiguate(String pattern); String getNormTextandPattern(String text, String pattern); static int countOccurrencesOf(String source, char pattern); static String Roman2Decimal(String roman); }
Numek { public static Double calc_and_sum_frac(String snumber) { if (snumber.matches("([0-9]+ )?[0-9]+/[0-9]+")) { String[] temp; if (snumber.contains(" ")) { temp = snumber.split(" "); return Double.parseDouble(temp[0]) + Double.parseDouble(temp[1].substring(0, temp[1].indexOf('/'))) / Double.parseDouble(temp[1].substring(temp[1].indexOf('/') + 1)); } else { return Double.parseDouble(snumber.substring(0, snumber.indexOf('/'))) / Double.parseDouble(snumber.substring(snumber.indexOf('/') + 1)); } } else { if (System.getProperty("DEBUG") != null && System.getProperty("DEBUG").equalsIgnoreCase("true")) { System.err.println("Warining: error normalizing fraction (" + snumber + ") it has been set to 0.0 by default."); } return 0.0; } } Numek();  Numek(Locale l);  Numek(Locale l, String resources_dir); static Double calc_and_sum_frac(String snumber); String text2number(String snumber); final String disambiguate(String pattern); String getNormTextandPattern(String text, String pattern); static int countOccurrencesOf(String source, char pattern); static String Roman2Decimal(String roman); public Locale locale; public HashSet<String> all_keys; public HashSet<String> repeated_keys; public PhraselistFile ambiguous; public PhraselistFile delimiters; public PhraselistFile units; public PhraselistFile tens; public PhraselistFile irregular_tens; public PhraselistFile magnitudes; public PhraselistFile special_groups; public PhraselistFile restrictions; public PhraselistFile ordinal_units; public PhraselistFile ordinal_irregular_tens; public PhraselistFile ordinal_tens; public PhraselistFile ordinal_suffixes; public PhraselistFile decimal_point_separator; public PhraselistFile group_separators; final static Integer MAX_NUMBERS_ORDER; static String romans; static String romans5; final static HashMap<String, Integer> romansMap; }