@Test public void formatNonProperNoun() { TurkishMorphology morphology = TurkishMorphology.builder() .disableCache() .setLexicon("elma", "kitap", "demek", "evet") .build(); String[] inputs = {"elmamadaki", "elma", "kitalarımdan", "kitabımızsa", "diyebileceğimiz", "dedi", "evet"}; WordAnalysisSurfaceFormatter formatter = new WordAnalysisSurfaceFormatter(); for (String input : inputs) { WordAnalysis results = morphology.analyze(input); for (SingleAnalysis result : results) { Assert.assertEquals(input, formatter.format(result, null)); } } }
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);  }