File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing NOAA weather report project

 
Norm Radder
Ranch Hand
Posts: 707
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks,
Norm

Here's a sample of what I mean by a FSM. Some methods are dummies:
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I take it you are parsing the plain text forecast? That would be painful. NOAA forecasts are also available in xml format which would be much easier to work with.
 
Norm Radder
Ranch Hand
Posts: 707
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic