Skip to content

Commit

Permalink
speakable strings
Browse files Browse the repository at this point in the history
  • Loading branch information
witek committed Apr 8, 2015
1 parent 7a6201b commit da68033
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 97 deletions.
40 changes: 5 additions & 35 deletions src/main/java/ilarkesto/base/Str.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Copyright 2011 Witoslaw Koczewsi <[email protected]>, Artjom Kochtchi
*
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
*
* You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -38,8 +38,7 @@
public class Str extends ilarkesto.core.base.Str {

public static void main(String[] args) {
System.out.println(activateLinksInHtml(toHtml("abc <http://koczewski.de?x=x&y=y>"), null));
System.exit(0);
System.out.println(getSimilarity("St. Märgen", "Sankt Märgen"));
}

private static final char[] UNICODE_CHARS = new char[] { ue, UE, oe, OE, ae, AE, sz, EUR };
Expand All @@ -52,6 +51,7 @@ public static void main(String[] args) {
private static final Object UIDLOCK = new Object();

public static List<String> tokenize(String s, String delimiters) {
if (s == null) return Collections.emptyList();
List<String> ret = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(s, delimiters);
while (tokenizer.hasMoreTokens()) {
Expand Down Expand Up @@ -134,36 +134,6 @@ public static String generateRandomSentence(int minWords, int maxWords, int minW
return sb.toString();
}

public static boolean isSpeakable(String s) {
if (s == null) return false;
s = s.toLowerCase();

String vovels = "aeiouyäüö";

int vovelsInRow = 0;
int consonantsInRow = 0;

for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
String c = String.valueOf(ch);
if (!Character.isLetter(ch)) {
vovelsInRow = 0;
consonantsInRow = 0;
} else if (vovels.contains(c)) {
vovelsInRow++;
consonantsInRow = 0;
} else {
consonantsInRow++;
vovelsInRow = 0;
}
if (vovelsInRow >= 4 || consonantsInRow >= 5) return false;
}

if (s.length() == consonantsInRow) return false;

return true;
}

public static String generateRandomWord(int minLength, int maxLength, boolean uppercase) {
String vovels = "aeiouy";
String consonants = "bcdfghjklmnpqrstvwxz";
Expand Down
62 changes: 0 additions & 62 deletions src/test/java/ilarkesto/base/StrTest.java

This file was deleted.

0 comments on commit da68033

Please sign in to comment.