e*****n 发帖数: 124 | 1 Today: Mostly cloudy with a 20 percent chance of snow. Highs in the mid 30s.
Tonight: Cloudy with a 20 percent chance of snow. Lows in the lower to mid
20s.
Saturday: Warmer. Mostly cloudy with a 10 percent chance of snow. Highs in
the lower to mid 40s. Winds 10 to 15 mph.
Saturday Night: Mostly cloudy. Chance of rain in the morning, then chance of
snow overnight. Probability of rain and snow 40 percent. Lows 25 to 31.
Sunday: Partly cloudy. Highs 40 to 46.
Sunday Night: Partly cloudy. Lows 24 to 30.
These words are automatically generated from various gridded weather
information such as: Temperature, Wind, Probability of Precipitation, and
Precipitation Type (Rain, Snow, etc.). Note there are dependencies from one
time period to another (e.g. “Warmer”) plus dependencies between phrases
within a time period as appears in the Saturday Night forecast.
Design the algorithm allowing the auto-generation of these textual
descriptions from said gridded fields. How would you approach this software
design problem?
Since “one size does not fit all”, the software must be extensible and
easily customized. For example, “Warm” in Alaska may mean something
different than in Florida. Also, the algorithms to produce the digital data
may differ from location to location.
What software design concepts (or approach) would you use?
怎么入手?数据结构?怎么设计? | m**********s 发帖数: 518 | 2 Consider the output as segments
Each segment needs a strategy
Each strategy has multiple factories | h***n 发帖数: 1600 | 3 你的数据可能来源于XML, JSON或者databse等,你设置好switch case和和rule,根据
你取到的数据加不同英文句子。比如这句:
Saturday: Warmer. Mostly cloudy with a 10 percent chance of snow. Highs in
the lower to mid 40s. Winds 10 to 15 mph.
一开始是时间,然后是“warmer" ,warmer“ 这个可能要根据和前一天的温度比较得
出, “ most cloudy" 是它的数据里的信息,降雪概率10%它的数据里也会有。你就把
数据套到句子里去就行了。......
另外有些描述性句子,它原始给出的数据就可能这样的。 |
|