Results 1 to 2 of 2
  1. #1
    Fluxtime is offline Member
    Join Date
    Mar 2012
    Posts
    8
    Rep Power
    0

    Default How to define what a word is for a word count?

    I am writing a word count program where a word is defined as any sequence of letters only. Which means, any non-letter characters are used to separate words. Consequently, the sequence “ab12cd3ef gh-ij” contains the “words” ‘ab’, ‘cd’. ‘ef’, ‘gh’ and ‘ij’.

    All I want to know is how to define a word this way. I have been trying a number of different ways using the isLetter, isDigit and isWhitespace methods for characters. I am reading my file using bufferedreader and the readline() method. I then convert the file contents to a string with the toString() method and I have also tried to convert it to character array to solve this problem. However, I have yet to figure out how to define a "word" as the brief asks.

    Please help,

    Thanks.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: How to define what a word is for a word count?

    You say you tried isLetter.
    I would expect that to work.
    You could also look into regex, if that's allowed.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Java Word Count Issue
    By Fluxtime in forum New To Java
    Replies: 3
    Last Post: 11-26-2012, 06:16 PM
  2. Replies: 6
    Last Post: 04-25-2012, 09:17 PM
  3. Word Count in Java
    By michaelangelokrk in forum New To Java
    Replies: 4
    Last Post: 09-22-2011, 08:34 AM
  4. Count same word from many file in directory
    By cassiests in forum New To Java
    Replies: 4
    Last Post: 05-20-2010, 09:21 AM
  5. count occurence of word in a line of text
    By sinyi88 in forum New To Java
    Replies: 19
    Last Post: 02-28-2009, 07:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •