in languagetool-core/src/main/java/org/languagetool/rules/ReadabilityRule.java [217:255]
protected int simpleSyllablesCount(String word) {
if (word.length() == 0) {
return 0;
}
if (word.length() == 1) {
return 1;
}
int nSyllables = 0;
boolean lastDouble = false;
for (int i = 0; i < word.length() - 1; i++) {
char c = word.charAt(i);
if (isVowel(c)) {
char cn = word.charAt(i + 1);
if (lastDouble) {
nSyllables++;
lastDouble = false;
} else if (((c == 'e' || c == 'E') && (cn == 'a' || cn == 'o' || cn == 'e' || cn == 'i' || cn == 'y')) ||
((c == 'a' || c == 'A') && (cn == 'e' || cn == 'i' || cn == 'u')) ||
((c == 'o' || c == 'O') && (cn == 'o' || cn == 'i' || cn == 'u' || cn == 'a')) ||
((c == 'u' || c == 'U') && (cn == 'i' || cn == 'a')) ||
((c == 'i' || c == 'I') && (cn == 'e'|| cn == 'o'))) {
lastDouble = true;
} else {
nSyllables++;
lastDouble = false;
}
} else {
lastDouble = false;
}
}
char c = word.charAt(word.length() - 1);
char cl = word.charAt(word.length() - 2);
if (cl == 'e' && (c == 's' || c == 'd') || cl == 'u' && c == 'e') {
nSyllables--;
} else if (isVowel(c) && c != 'e') {
nSyllables++;
}
return nSyllables <= 0 ? 1 : nSyllables;
}