Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: The Grand Canyon Date: Mon, 08 Dec 2014 01:21:21 -0500 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 8 Dec 2014 06:22:05 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="c50a9e5d554cfaba13eda1c71e805135"; logging-data="9833"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DyYndhU8UiQ/69WACeCCJ53kkNP702Sk=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 In-Reply-To: Cancel-Lock: sha1:JdYU32fNsvL/VdPLaepKJAe8vRo= Xref: csiph.com comp.lang.java.programmer:30506 On 12/07/2014 06:59 PM, Stefan Ram wrote: > Today, I saw the Grand Canyon! > > Say, you want to count the even numbers of a list. > Well, that's easy, you just ... > > > public class Main > { public static void main( final java.lang.String args[] ) > { final java.util.List< java.lang.Integer >list = java.util.Arrays.asList( 1, 2, 3, 4 ); > java.lang.System.out.println( list.stream().filter( i -> 0 == i % 2 ).count() ); }} > > Now, say, you want to count the vowel letters in a string. > > public class Main > { public static void main( final java.lang.String args[] ) > { final java.lang.String s = "alpha"; > ... x = ... s ... ; > java.lang.System.out.println( x.stream().filter( ch -> "aeiou".contains( ch )).count() ); }} > > Can you fill in something for »...« to bridge the gap between > the string and the filter counter? (The output should be »2«.) > > You can't. > > So, this is not just a gap, it's a canyon. > > The Grand Canyon of Java programming! > So, after much study, I conclude you will: For each language, and dialect of that language; Construct a word->IPA transcription dictionary: Split the string into words: Map the words to their IPA transcription: Filter the vowels from the transcriptions: Reduce to a vowel count. Voilà! vwäˈlä