@Test public void formatNumerals() { TurkishMorphology morphology = TurkishMorphology.builder().disableCache().build(); String[] inputs = {"1e", "4ten", "123ü", "12,5ten"}; String[] expected = {"1'e", "4'ten", "123'ü", "12,5ten"}; WordAnalysisSurfaceFormatter formatter = new WordAnalysisSurfaceFormatter(); int i = 0; for (String input : inputs) { WordAnalysis results = morphology.analyze(input); for (SingleAnalysis result : results) { if (result.getDictionaryItem().primaryPos == PrimaryPos.Numeral) { Assert.assertEquals(expected[i], formatter.format(result, "'")); } } i++; } }
public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ? item.normalizedLemma() + apostrophe + ending : item.normalizedLemma(); } else { if (item.attributes.contains(RootAttribute.NoQuote)) { return item.normalizedLemma() + ending; } else { return analysis.getStem() + ending; } } }
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ? item.normalizedLemma() + apostrophe + ending : item.normalizedLemma(); } else { if (item.attributes.contains(RootAttribute.NoQuote)) { return item.normalizedLemma() + ending; } else { return analysis.getStem() + ending; } } } }
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ? item.normalizedLemma() + apostrophe + ending : item.normalizedLemma(); } else { if (item.attributes.contains(RootAttribute.NoQuote)) { return item.normalizedLemma() + ending; } else { return analysis.getStem() + ending; } } }  }
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ? item.normalizedLemma() + apostrophe + ending : item.normalizedLemma(); } else { if (item.attributes.contains(RootAttribute.NoQuote)) { return item.normalizedLemma() + ending; } else { return analysis.getStem() + ending; } } }  String format(SingleAnalysis analysis, String apostrophe); String format(SingleAnalysis analysis); String formatToCase(SingleAnalysis analysis, CaseType type, String apostrophe); String formatToCase(SingleAnalysis analysis, CaseType type); boolean canBeFormatted(SingleAnalysis analysis, CaseType type); CaseType guessCase(String input); }
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ? item.normalizedLemma() + apostrophe + ending : item.normalizedLemma(); } else { if (item.attributes.contains(RootAttribute.NoQuote)) { return item.normalizedLemma() + ending; } else { return analysis.getStem() + ending; } } }  String format(SingleAnalysis analysis, String apostrophe); String format(SingleAnalysis analysis); String formatToCase(SingleAnalysis analysis, CaseType type, String apostrophe); String formatToCase(SingleAnalysis analysis, CaseType type); boolean canBeFormatted(SingleAnalysis analysis, CaseType type); CaseType guessCase(String input);  }