This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I'm looking for some design ideas for a project I'm working on: parsing and plotting NOAA weather report texts. The current problem is parsing the day/times for the report. There are many formats for the day/times. I have a tokenizer that returns the next word from the report. So far I have an awful mess of if else if and nested ifs to try to parse the input. I haven't studied computer science techniques for years and was wondering if anyone could give me some design ideas. The only technique that I can think of is a finite state machine. Then the syntax would be in a table instead of the mass of if else ifs.
Here are some sample days/times from the NOAA weather texts: today and tonight thu and thu night tonight mon night today through fri this afternoon and tonight this afternoon tonight wed night and thru
These strings are then followed optionally by a wind report, a hurricane report, a seas report or comment of some kind. I am using the PushbackReader class so that I can read ahead to find the beginning of the next report, recognize the end of the current report and push back the parts of the next report.
Here's a sample of what I mean by a FSM. Some methods are dummies:
Joe, Thanks for the link. I looked at the site and find that NOAA doesn't include the area I'm interested in in its database (Caribbean sea). Also there output is for single locations and not for areas. So back to parsing.
How did you happen to know about the NOAA XML site?
I made a weather alert app last year and went through NOAA's data with a fine tooth comb. There was something weird with the previous web data product, like they had a place holder for hurricane warnings for Ohio but no severe thunderstorm warnings (which, of course, are far more likely in the midwest). I turned the site inside out trying to see the logic of it. They had information about the XML feeds, but they weren't live at that time. They would have saved me a lot of trouble.