-
Notifications
You must be signed in to change notification settings - Fork 38
/
Exercise.hs
58 lines (39 loc) · 1.88 KB
/
Exercise.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module Y2017.M10.D26.Exercise where
{--
Okay, so we've subdivided our hurricanes (or the topics you chose) into
subtopics by doing a little bit of scanning into the documents. Are we done?
OF COURSE NOT!
Some articles are 'trash'; some articles are wildly misclassified from the
media source (you know, for teh viewzorx!) and some articles, yes, mention
the topic, e.g.: Harvey, to talk about "President Trump is Not Taking Climate
Change Seriously" Or "104 YO Man, Harvey, Reflects with his wife, Irma, on the
Last Century!"
No, really. There are articles about those topics in the archives.
So, we're going to do a little 'artificial-artificial intelligence' today
(that's the name google gives: 'doing it by hand'). I've categorized and
subcategorized these articles by hand by going through the archive and reading
them.
Ugh. Yup. I was up all last night doing this.
Then I've assigned a theme to each article, like: gov't or Trump, or
climate change, or human interest, or preparedness/response or some other
themes.
Today's Haskell problem, read in my artificial-artificial intelligence
classifications-by-theme of these articles from hurricanes.csv on this
directory, then, group each article by theme, THEN save out each article into
its own <theme>.csv file
--}
import Data.Map (Map)
-- below import available via 1HaskellADay git repository
import Control.Scan.CSV
-- hint: csv treats quoted values as a column. That's a good thing
data ArticleClass = ARowFromYourCSVFile
readArts :: FilePath -> IO [ArticleClass]
readArts csvfile = undefined
-- Now that we have our article classifications, let's group them by theme
type Theme = String
groupArts :: [ArticleClass] -> Map Theme [ArticleClass]
groupArts arts = undefined
-- And now we have articles-by-theme, save out each themed-set to its own-named
-- CSV file
saveThemes :: Map Theme [ArticleClass] -> IO ()
saveThemes themes = undefined