@Test public void formatNumbersTest() throws IOException { TurkishMorphology morphology = TurkishMorphology.builder() .disableCache() .setLexicon("bir [P:Num]", "dört [P:Num;A:Voicing]", "üç [P:Num]", "beş [P:Num]") .build(); TurkishSpellChecker spellChecker = new TurkishSpellChecker(morphology); String[] inputs = { "1'e", "4'ten", "123'ü", "12,5'ten", "1'E", "4'TEN", "123'Ü", "12,5'TEN", "%1", "%1'i", "%1,3'ü", }; for (String input : inputs) { Assert.assertTrue("Fail at " + input, spellChecker.check(input)); } }
public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { continue; } String apostrophe = getApostrophe(input); if (formatter.canBeFormatted(analysis, caseType)) { String formatted = formatter.formatToCase(analysis, caseType, apostrophe); if (input.equals(formatted)) { return true; } } } return false; }
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { continue; } String apostrophe = getApostrophe(input); if (formatter.canBeFormatted(analysis, caseType)) { String formatted = formatter.formatToCase(analysis, caseType, apostrophe); if (input.equals(formatted)) { return true; } } } return false; } }
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { continue; } String apostrophe = getApostrophe(input); if (formatter.canBeFormatted(analysis, caseType)) { String formatted = formatter.formatToCase(analysis, caseType, apostrophe); if (input.equals(formatted)) { return true; } } } return false; } TurkishSpellChecker(TurkishMorphology morphology);  TurkishSpellChecker(TurkishMorphology morphology, CharacterGraph graph);  TurkishSpellChecker(
      TurkishMorphology morphology,
      CharacterGraphDecoder decoder,
      CharMatcher matcher); }
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { continue; } String apostrophe = getApostrophe(input); if (formatter.canBeFormatted(analysis, caseType)) { String formatted = formatter.formatToCase(analysis, caseType, apostrophe); if (input.equals(formatted)) { return true; } } } return false; } TurkishSpellChecker(TurkishMorphology morphology);  TurkishSpellChecker(TurkishMorphology morphology, CharacterGraph graph);  TurkishSpellChecker(
      TurkishMorphology morphology,
      CharacterGraphDecoder decoder,
      CharMatcher matcher); NgramLanguageModel getUnigramLanguageModel(); void setAnalysisPredicate(Predicate<SingleAnalysis> analysisPredicate); static List<String> tokenizeForSpelling(String sentence); boolean check(String input); List<String> suggestForWord(String word, NgramLanguageModel lm); List<String> suggestForWord(
      String word,
      String leftContext,
      String rightContext,
      NgramLanguageModel lm); List<String> suggestForWord(String word); CharacterGraphDecoder getDecoder(); List<String> rankWithUnigramProbability(List<String> strings, NgramLanguageModel lm); }
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { continue; } String apostrophe = getApostrophe(input); if (formatter.canBeFormatted(analysis, caseType)) { String formatted = formatter.formatToCase(analysis, caseType, apostrophe); if (input.equals(formatted)) { return true; } } } return false; } TurkishSpellChecker(TurkishMorphology morphology);  TurkishSpellChecker(TurkishMorphology morphology, CharacterGraph graph);  TurkishSpellChecker(
      TurkishMorphology morphology,
      CharacterGraphDecoder decoder,
      CharMatcher matcher); NgramLanguageModel getUnigramLanguageModel(); void setAnalysisPredicate(Predicate<SingleAnalysis> analysisPredicate); static List<String> tokenizeForSpelling(String sentence); boolean check(String input); List<String> suggestForWord(String word, NgramLanguageModel lm); List<String> suggestForWord(
      String word,
      String leftContext,
      String rightContext,
      NgramLanguageModel lm); List<String> suggestForWord(String word); CharacterGraphDecoder getDecoder(); List<String> rankWithUnigramProbability(List<String> strings, NgramLanguageModel lm);  }