Syllables

//group/people worked with: skooklar, sejin, james import java.util.*; public class countSyl{ public static void countSyl() { String[] words = {"cat", "hello", "world", "tennis", "episcopal", "count", "learn", "denise", "state","statement","fruit", "calculation","spite","spiteful","reservation", "late","lately","extreme","expensive", "purposeful"}; int wordsLength = words.length; for(int i=0; i<wordsLength; i++) findSylFind(words[i]); } public static void findSylFind(String word){ String[] arr = word.split("(?!^)"); int count = 0; int length = word.length(); for(int i=0; i<length; i++){ if(arr[i].equals("a")| arr[i].equals("e")| arr[i].equals("i")| arr[i].equals("o")| arr[i].equals("u")| arr[i].equals("y")){ count ++; try{ if(arr[i].equals("y")&&(arr[i+1].equals("a") | arr[i+1].equals("e") | arr[i+1].equals("o") | arr[i+1].equals("u"))){ count--; //end of vowel/y sound search } }catch(Exception e){ } try{ if(arr[i-1].equals("a")| arr[i-1].equals("e")| arr[i-1].equals("i")| arr[i-1].equals("o")| arr[i-1].equals("u")){ count--; //end of double vowel rule try{ if(arr[i-1].equals("i")) count ++; }catch(Exception e){ } try{ if((arr[i-2].equals("a") | arr[i-2].equals("i") | arr[i-2].equals("e") | arr[i-2].equals("o") | arr[i-2].equals("u")) &! arr[i-1].equals("i")) count ++; }catch(Exception e){ } } }catch(Exception e){ } if(arr[i].equals("e") && i>2 && (arr[i-2].equals("a") | arr[i-2].equals("i") | arr[i-2].equals("e") | arr[i-2].equals("o") | arr[i-2].equals("u"))){ count --; if(arr[i-1].equals("x")) count++; try{ if(arr[i+1].equals("d")||arr[i+1].equals("r")) count++; }catch(Exception e){ } try{ if(arr[i+2].equals("e")) count ++; }catch(Exception e){ } } } } if(count>1 && arr[length-1].equals("e") &! (arr[length-3].equals("a") | arr[length-3].equals("i") | arr[length-3].equals("e") | arr[length-3].equals("o") | arr[length-3].equals("u"))) count--;//e ending words System.out.println("Word: " + word + " SylFind: " + count); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.