Ignoring the period in a sentence

Hello,
I am trying to create a code segment that goes through a sentence (input) word by word and displays all words which have an even number of letters and ignores the words with an odd number of letters. I have created a code that is able to do that. But, the only problem is that the last word in the sentence includes the punctuation (period, question mark) in it's count. Can anyone tell me how to go about fixingthat problem. Here's what I've come up with so far . . .
public static void main (String[] args)
   Scanner scan = new Scanner (System.in);
   System.out.print("Enter a statement >");
   String sentenceIn = scan.nextLine();
   String oneWord;
   StringTokenizer st = new StringTokenizer(sentenceIn);
    while (st.hasMoreTokens())
       oneWord = st.nextToken();
       if (oneWord.length() % 2 == 0)
       System.out.println(oneWord);
}Any help will be greatly appreciated!! Ana : )

Hi,
You could use a regular expression to remove the non word characters. Here's an example
          String test = "this is a test line, where ? there are some words!";
          test = test.replaceAll("\\W", " ");
          System.out.println("test = " + test);
          String[] parts = test.split("\\s");
          System.out.println("parts.lenth = " + parts.length);
          for (int i = 0; i < parts.length; i++) {
               int length = parts.trim().length();
               if (length > 0 && length % 2 == 0) {
                    System.out.println(parts[i]);

Similar Messages

  • Dictation does not recognize the word 'period' as a . at the end of a sentence when spoken

    Dictation does not recognize the spoken word "period" as a . at the end of a sentence when "period" spoken. Any suggestions?

    I don't know what version of English you speak, but here in the UK my dictation recognises the words "full stop" to produce a, well, full stop. It also recognises the word "comma" correctly.
    I find that it correctly s "semicolon" and "backslash" and "open quotes" and "close quotes".
    When I spoke "This is a dictated example comma which turns out to be correct full stop" it produced correctly:
    This is a dictated example, which turns out to be correct.
    This also came out OK: Would a rose by any other name smell as sweet.
    On the other hand "Here is o umlout and e grave" produces "Here is all going out and eat grass."!
    There's is lots of fun available here!

  • How do I ignore the difference​s in DBMSs when reading data from a DB?

    My boss wants me to create a text parser that parses the below sentence and executes an SQL query.
    'get table field1,field2,field3,...,fieldN [where SQL conditional statements]'
    This corresponds to 'select field1, field2, field3, ..., fieldN from table where blahblah'.
    Since different DBMSs have different formats for timestamp, that sentence has to be changed for each DBMS.
    One way to ignore the differences is to make a complex text anlayzer that converts a certain type of timestamp string to one that fits each DBMS.
    But it looks ridiculous to adopt such a solution when there might be an elegant solution.
    LabVIEW DB Toolkit is not capable of concealing the differences.
    Does anybody have a better idea than I do?
    Solved!
    Go to Solution.

    I remember having an issue like this when working with an older version of an Oracle server. I was able alter the session by setting 'NLS_TIMESTAMP_FORMAT'.
    This page might be of interest; I found this when searching for 'NLS_TIMESTAMP_FORMAT'
    Database Portability: Date and Timestamp Columns
    (PS The Format Into String and Scan From String functions work nicely with the correct date format specifiers. See the link below in my signature for ISO 8601 timestamp/string conversions)
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • How do I get iPad Pages app to capitalize the first word of sentences?, how do I get iPad Pages app to capitalize the first word of sentences?

    Maybe this is not a Pages feature on the iPad. Does anyone know if Pages will auto-cap "i" or the first word in a sentence?

    That's strange.  What keyboard language are you using in iPad, maybe that effects it? Settings >> Keyboard >> International Keyboard
    Other than that try a reboot - Press and Hold the Home and Sleep buttons simultaneously until the Apple symbol appears, ignore the red slider.  That usually resets the settings to default.
    iPad 2, Click 'Like' if I helped ;-)

  • How do I measure the period of one TTL signal and the delay until a second TTL signal?

    Hi,
    I have a PCI 6024E board, the SCB-68 terminal box and am running LabView 6.1.  If needed I could install 7.1.
    I have two Honeywell sensors (HOA7720) which each consist of an infrared transmitter and a infrared reciever.  When the beam is broken they output 5V, when the beam is open it outputs 0V.  These are sensing the presence of a hole in two discs passing thru the sensors.  
    So as disc 1 rotates the signal is 5V until the hole passes thru sensor 1, then it drops to 0V until the hole passes.  Then it jumps back to 5 V. 
    Disc 2 is rotating at exactly the same RPM as disc 1 because they are coupled with a spring loaded coupling.  There is a delay between the first hole passing thru sensor 1 and the second hole passing thru sensor 2.  The delay increases with torque. 
    Using the oscilliscope function and connecting Signal1 and Signal2 to AIn0 and AIn1, I have verified that the TTL signals are there.  So electrically everything is working.  I just need to know how to measure the period and delay.  I'm familiar with A/D, but not with counters/gates etc and I think that's what is required here. 
    The first measurement needed is RPM.   Somehow I need to measure the period of the TTL signal. 
    The second measurement needed is the delay between the 1st falling edge and the 2nd falling edge.  
    I don't think it's possible to use the millisecond timer for anything, because the accuracy wouldn't be good enough.  At 3600RPM the disc will spin 60 revs per second, or one every 17ms.  A resolution of 17 samples per revolution is not good enough.    
    Help please!

    It worked!
    I ended up figuring it out today.  It's really simple.  I went analog in to AIn14 and AIn15 which were free. Then the program does a multichannel scan of the signals (collects array of 2 waveforms), Signal 1 and Signal 2 at some scan rate.  I used 100,000 S/s for 10,000 samples. Then I split the array into two separate waveforms.  Then I did an edge detect on each one and it returns the position in the array where the falling edge occurs.  The difference is the delay (after correcting for the scan rate), unless Sig2 comes first in which case the delay is the period - (or +) the difference
    To find the period I used a subset of the Signal 1 waveform from the first falling edge on to the end of the waveform, then did the same edge detect except set the reset setting to true instead of false so it wouldn't detect the low signal which was now at the position 0 in the waveform.  So it would ignore the initial low value, wait for it to go high, then detect the falling edge position.
    Anyway, it works awesome, seems very accurate and gives very stable readings.  3600rpm no problem.  It detects changes of one or two degrees in angular position, with a range from ~145 degrees to ~280 degrees

  • Request is pending; ignoring the ServiceConfigUpdate

    Periodically I am seeing thousands of messages like this in my logs, followed by the "logging character limit exceeded" message, followed by several long, multi-second full GCs (which were possibly due to the need to free up the memory taken up by the 294,978 lines and 433,373,442 characters in the discarded log messages).  It all goes downhill from there with members leaving the cluster and eventual JVM crashes.
    These are debug messages and not errors, but finding out what is going on in the cluster right before everything falls apart could help me figure out why everything falls apart.  So what do these "Request is pending; ignoring the ServiceConfigUpdate" log messages mean (i.e. what is the log message telling me)?
    2013-09-07 15:33:59,000 DEBUG [Logger@9219105 3.5.3/465p10] Coherence: Oracle Coherence GE 3.5.3/465p10 <D5> (thread=DistributedCache:DistributedResultCache, member=210): Request is pending; ignoring the ServiceConfigUpdate UpdateMap={224=Owners(0, 0), 254=Owners(0, 0), 255=Owners(0, 0), 252=Owners(0, 0), 253=Owners(0, 0), 250=Owners(0, 0), 251=Owners(0, 0), 248=Owners(0, 0), 249=Owners(0, 0), 246=Owners(0, 0), 247=Owners(0, 0), 244=Owners(0, 0), 245=Owners(0, 0), 242=Owners(0, 0), 243=Owners(0, 0), 240=Owners(0, 0), 241=Owners(0, 0), 256=Owners(0, 0)}; Remove=false
    2013-09-07 15:33:59,000 DEBUG [Logger@9219105 3.5.3/465p10] Coherence: Oracle Coherence GE 3.5.3/465p10 <D5> (thread=DistributedCache:DistributedResultCache, member=210): Request is pending; ignoring the ServiceConfigUpdate UpdateMap={254=Owners(0, 0), 255=Owners(0, 0), 252=Owners(0, 0), 253=Owners(0, 0), 250=Owners(0, 0), 251=Owners(0, 0), 248=Owners(0, 0), 249=Owners(0, 0), 246=Owners(0, 0), 247=Owners(0, 0), 244=Owners(0, 0), 245=Owners(0, 0), 242=Owners(0, 0), 243=Owners(0, 0), 240=Owners(0, 0), 241=Owners(0, 0), 256=Owners(0, 0)}; Remove=false
    2013-09-07 15:33:59,001 DEBUG [Logger@9219105 3.5.3/465p10] Coherence: Oracle Coherence GE 3.5.3/465p10 <D5> (thread=DistributedCache:DistributedResultCache, member=210): Request is pending; ignoring the ServiceConfigUpdate UpdateMap={255=Owners(0, 0), 252=Owners(0, 0), 253=Owners(0, 0), 250=Owners(0, 0), 251=Owners(0, 0), 248=Owners(0, 0), 249=Owners(0, 0), 246=Owners(0, 0), 247=Owners(0, 0), 244=Owners(0, 0), 245=Owners(0, 0), 242=Owners(0, 0), 243=Owners(0, 0), 240=Owners(0, 0), 241=Owners(0, 0), 256=Owners(0, 0)}; Remove=false
    2013-09-07 15:33:59,001 DEBUG [Logger@9219105 3.5.3/465p10] Coherence: Oracle Coherence GE 3.5.3/465p10 <D5> (thread=DistributedCache:DistributedResultCache, member=210): Request is pending; ignoring the ServiceConfigUpdate UpdateMap={252=Owners(0, 0), 253=Owners(0, 0), 250=Owners(0, 0), 251=Owners(0, 0), 248=Owners(0, 0), 249=Owners(0, 0), 246=Owners(0, 0), 247=Owners(0, 0), 244=Owners(0, 0), 245=Owners(0, 0), 242=Owners(0, 0), 243=Owners(0, 0), 240=Owners(0, 0), 241=Owners(0, 0), 256=Owners(0, 0)}; Remove=false
    2013-09-07 15:35:06,637 WARN  [Logger@9219105 3.5.3/465p10] Coherence: Oracle Coherence 3.5.3/465p10 <Warning> (thread=Logger@9219105 3.5.3/465p10, member=n/a): Asynchronous logging character limit exceeded; discarding 147489 log messages (lines=294978, chars=433373442)

    Hi Jarrod
    I just noticed that you are running with backup count = 2. There is a difference in behavior between v3.4 and v3.5 regarding systems that are configured with 2 levels of backup. This is considered a bug in 3.5; however, I don’t have an estimate on when the fix will be made.
    My advice is to use 1 level of backup, which is our recommended configuration. I apologize for any inconvenience this may have caused you.
    thanks
    Paul

  • Thunderbird 31.5.0 spell check does not handle contractions at the start of a sentence properly.

    For example, trying to enter Don't changes to T Don', another would be Isn't will become T Isn'.
    In either case, the letter after the apostrophe is moved to the start of the sentence and capitalized with a space after it. The rest of the word and the apostrophe stay the same.

    I'm surprised because I've used that add-on myself and have not had that particular issue with it. I gave up on it for other reasons; it was near impossible to use terms such as i.e. without it capitalizing, since as far as it was concerned, a period could only mean the end of a sentence, and it seemed impossible to teach it that I really wanted i.e. unmolested. File names such as profiles.ini present similar challenges.
    I'm having similar issues on the Android device I'm using right now, but as you see, it can be done with some persistence on my part.

  • Find Grep And Ignore the line break

    Hi Guys!,
    In my document having the text of "application \nfor you"
    Then, I need to ignore the line break in entire text indesign document.
    please help me!
    Thanks by
    John Peter.

    hi,
    I am find only words
    the line break wherever it is used in the document. so i am ignore the \n
    Document text : \napplication \nfor \nyou      ----this sentence contain many line breaks
    I will find the text of above document text.
    Find what of grep preferences: (application for you)(--here what to do for ignore \n)
    Please help me.
    thanks,
    John peter.

  • SSRS 2008 Column Chart with Calculated Series (moving average) "formula error - there are not enough data points for the period" error

    I have a simple column chart grouping on 1 value on the category axis.  For simplicity's sake, we are plotting $ amounts grouping by Month on the category axis.  I right click on the data series and choose "Add calculated series...".  I choose moving average.  I want to move the average over at least 2 periods.
    When I run the report, I get the error "Formula error - there are not enough data points for the period".  The way the report is, I never have a guaranteed number of categories (there could be one or there could be 5).  When there is 2 or more, the chart renders fine, however, when there is only 1 value, instead of suppressing the moving average line, I get that error and the chart shows nothing.
    I don't think this is entirely acceptable for our end users.  At a minimum, I would think the moving average line would be suppressed instead of hiding the entire chart.  Does anyone know of any workarounds or do I have to enter another ms. connect bug/design consideration.
    Thank you,
    Dan

    I was having the same error while trying to plot a moving average across 7 days. The work around I found was rather simple.
    If you right click your report in the solution explorer and select "View Code" it will give you the underlying XML of the report. Find the entry for the value of your calculated series and enter a formula to dynamically create your periods.
    <ChartFormulaParameter Name="Period">
                      <Value>=IIf(Count(Fields!Calls.Value) >= 7 ,7, (Count(Fields!Calls.Value)))</Value>
    </ChartFormulaParameter>
    What I'm doing here is getting the row count of records returned in the chart. If the returned rows are greater than or equal to 7 (The amount of days I want the average) it will set the points to 7. If not, it will set the number to the amount of returned rows. So far this has worked great. I'm probably going to add more code to handle no records returned although in my case that shouldn't happen but, you never know.
    A side note:
    If you open the calculated series properties in the designer, you will notice the number of periods is set to "0". If you change this it will overwrite your custom formula in the XML.

  • No data in IT0007 during the period 05.05.2010 - 31.05.2010

    Hi experts,
            When i am running PY simulation for a particular employee who has joined as trainee a year before and was confirmed on 05.05.2011 I am getting error in log saying No data in IT0007 during the period 05.05.2010 to 31.05.2010. Pls brief me to overcome this issue ASAP.
    Thanks in advance
    Upensap

    Please go to PA30 select the IT0007 and go for overview
    check the start date of the records, check if there is data  for the mentioned period in the error?
    if not maintain it .
    from which date the employees payroll is going to start?

  • When the asset is sold in the mid of the period, how the depreciation is ca

    when the asset is sold in the mid of the period, how the depreciation is calculated as you can not run AFAB in the mid of the period.

    Adding to the above reply, when the asset is sold in the mid period, during such sale process, based on the period control, depreciation till the date will be computed by the system and adjusted.

  • E613 SYST: You cannot determine the period for rule 03

    Dear All,
    We are configuring asset module and using MSTL dep key for Tax books. When we tried to create an asset with MSTL dep key, we encountered error - 'E613 SYST: You cannot determine the period for rule 03'. when verified config OAVH Define Calender Assignments transaction,  Period control '03' is missing for fiscal year variant K4. Period control is exisiting  in Maintain Period Control and but not in Define Calender Assignment. What I understand these period controls are being delivered by SAP. Not sure why period control '03' is missing.  all other period control keys are available.
    question is how to add period control 03 so that we can use MSTL dep key. we are currently using 4.7c. Any suggestions would be appreciated.
    thanks
    Sunil

    message went abruptly before I finish.
    +++++++++
    continuing from previous email
    Period control 01 has following entry in the transaction
    Fiscal Year Variant        Per control          Name of the period control             Year      Month      Day      Period        Mid Month
    K4                                      01                        Pro rata at period start date        blank       0            0             blank        not selected
    If I follow SAP help to define period control '03', then I just need to copy period control '01' which is listed above and select 'Mid Month' check box.
    Wondering anyone did this in the past. MSTL depreciation key is being used in MACRS tax for US. I am sure people who  have implemented assets module for US with tax dep, they might have encountered this issue.
    thanks
    Sunil

  • Want TV guide so can mark hrs ahead favorite ahead shows,&ignore the rest.

    I don't know where else to post this question, so here goes:
    Want online TV guide so can mark hrs ahead favorite ahead shows,&ignore the rest.
    Oh, and I mean for antenna broadcast tv. Not for cable or satellite, can't afford that.
    Is there such an online site or application for Mac, Firefox.
    Want to be able to look over a TV schedule and click on the shows interested in for the hours ahead and not have to bother even seeing (much less having to re-read) again the shows we have no interest in.
    I would like the shows I do not mark to just disappear from the schedule and see them no more that day and evening.
    Less clutter, much simpler, and a lot less re-reading.
    So frustrating to have to skim down the column for each hour and look at all those shows channels I've already looked at and know I have no interest in.
    I know, I should be able to remember (naahhhh), or write them down (naahhh). The mac is supposed to do all our work and thinkin for us these days.
    Hasn't some bright bulb already solved this problem for millions of viewerrs? Made such an online tv guide website, invented sucha application?
    I have been using zap2it, but it does not have any sucha feature.
    I have Mac, Snow Leopard, and using Firefox.
    Don't think I won't thank you, cuz
    I will.
    Forest Gump ("I'm not a smaaarrrt maaaaannnn.")
    Always very grateful.
    Snow Mac
    P.S.: New to Using Intel MacMini with SnowLeopard.

    thelnukus wrote:
    The mac is supposed to do all our work and thinkin for us these days.
    Oh, dear, then I must have a seriously defective Mac. It refuses to go to work for me, doesn't do my laundry or feed the cat. And it won't do my homework for me.

  • HT2357 So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    Fantastic!  Didn't work at first so restarted App store and tried again.  This time it asked 'ignore update'.  All gone!

  • How to open the period who has already closed in MM

    hi All
    i have got problem regarding open and close period
    Posting only possible in periods 2007/07 and 2007/06 in company code
    but i want to post my material in period 2007/06 and 2007/05
    plaese hepl me out how open period again after closing the period
    thanks in advance

    Hi,
    This question has been already answered in this forum......
    Deatiled process is:
    1. Lock all users out of PRD
    2. Take snapshot of MB5L for all materials at company code for current and previous periods
    3. Add User parameter MMPI_READ_NOTE with value = current date in this format YYYYMMDD
    4. Stop all processing that updates inventory values
    5. Run t-code MMPI with correct period
    6. Run Z_DEl_HIST_ENTRIES program
    7. Take MB5L snapshot for all materials at company code fs01 for current and previous periods
    8. Validate that values match on MB5L pre-post snapshots or are appropriate.
    9. Unlock all users in PRD
    10. Remove User parameter MMPI_READ_NOTE from user ID
    Regards,
    Sachin

Maybe you are looking for

  • Using Genius with Songs on iPod but not in iTunes

    Of all the music on my iPod, only about a third of it is also on my computer in iTunes. As far as I can tell, Genius only works with the music that is in iTunes. If I try to make a playlist with any song that is not in iTunes, then it can't do it. Do

  • Problem with ABAP Import in Installation

    Hi all. We are installing an ECC 6.0 system and during the installation on the import ABAP phase an error keeps coming up that the Logwriter is switched off. How and where does 1 turn this on? Is it in the MaxDB Gui that we're using or can it be done

  • I have recently read the adobe acrobat portfolio sdk column. I want that my pdf files should get aut

    Any help would be greatly appreciated.

  • OCR and Voting Disk partition

    Dear all I uninstall clusterware. And i want to install again that but when i made partition in windows 2003 then CVU fail the stage command. I did the following things.. 1) diskpart --->select Disk 1----> clean -->exit (both the nodes) 2) diskpart -

  • 10.6.3 infinite loop crashes?

    according to one of the programmers of Adium, he says that 'according to the adium crash report, It's that same infinite loop crash. Its very odd that safari doesn't crash too, since it looks to be a bug with the operating system, rather than any spe