File size: 4,316 Bytes
7da72ab
 
 
 
8abbe81
7da72ab
8abbe81
7da72ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Presse-public-domain

I'm fascinated by this new dataset https://huggingface.co/datasets/PleIAs/French-PD-Newspapers that just dropped on :hugging_face:.

It references about 3 million French newspapers, with full-text. ("only" 320 files of about 700MB each :slightly_smiling_face:).

I wrote a data loader that outputs a single parquet file combining all their metadata (that is, without the text contents). It takes only about 5 minutes to run, thanks to parquet magic (and fiber internet); not sure how much of the ~200+GB I downloaded for that. Now I've started exploring the metadata in an observable project.

In one query, I see that A LOT of publications stopped publishing in 1944/1945, and conversely a large number of newspapers started publishing between 1941 and 1946. This probably includes both collaborationist publications and resistance publications—it would be interesting to find a ML way to separate them.

In another exploration, I see that the word "gazette" was quite frequent in the 17th Century.

Not sure what to look for, but making these queries in an Observable project is really nice.

```js
import { DuckDBClient } from "npm:@observablehq/duckdb";
const db = DuckDBClient.of({ presse: FileAttachment("data/presse.parquet") });
```

```js
const selection = db.query(
  `SELECT * FROM presse WHERE date >= '1600' AND date < '1820'`
);
```

```js
const letters = [];
const dates = [];

for (const { date, title } of selection) {
  if (title) {
    for (let l of [...title]) {
      l = l.toUpperCase();
      if (l >= "A" && l <= "Z") {
        const d = +d3.isoParse(date);
        if (d) {
          dates.push(d);
          letters.push(l);
        }
      }
    }
  }
}
```

```js
// display(letters);
// display(dates);
```

```js
display(
  Plot.plot({
    marks: [
      Plot.areaY(
        letters,
        Plot.stackY(
          { offset: "normalize", _o_rder: "value" },
          Plot.binX(
            {
              y: "count",
              filter: null,
            },
            {
              x: dates,
              thresholds: "5 years",
              fill: letters,
              tip: true,
            }
          )
        )
      ),
    ],
  })
);
```

```js
const search = view(Inputs.text({ type: "search", placeholder: "search…" }));
```

```js
display(selection);
```

```js
const test = new RegExp(search, "i");
```

```js
display(
  Plot.plot({
    marginLeft: 60,
    marks: [
      Plot.rectY(
        selection,
        Plot.binX(
          {
            y: "count",
          },
          {
            x: "date",
            fill: (d) => d.title && test.test(d.title),
            thresholds: "1 year",
          }
        )
      ),
    ],
  })
);
```

```js
const authors = db.query(
  `
SELECT author
     , MIN(date) AS start
     , MAX(date) AS end
  FROM presse
 WHERE date <> 'None'
 GROUP BY 1
`
);
```

```js
display(authors);
```

```js
display(
  Plot.plot({
    x: { type: "utc" },
    marks: [
      Plot.ruleY(authors, {
        x1: "start",
        x2: "end",
        y: "author",
        stroke: (d) => d3.isoParse(d.end) - d3.isoParse(d.start),
        sort: {
          y: "stroke",
        },
      }),
    ],
  })
);
```

```js
display(
  Plot.plot({
    x: { type: "utc" },
    marks: [
      Plot.rectY(
        authors,
        Plot.binX(
          { y: "count" },
          {
            x: "start",
            fill: (d) => d3.isoParse(d.end)?.getUTCFullYear(),
            thresholds: "1 year",
            tip: true,
          }
        )
      ),
    ],
  })
);
```

```js
display(
  Plot.plot({
    x: { type: "utc" },
    marks: [
      Plot.rectY(
        authors,
        Plot.binX(
          { y: "count" },
          {
            x: "end",
            fill: (d) => d3.isoParse(d.start)?.getUTCFullYear(),
            thresholds: "1 year",
            tip: true,
          }
        )
      ),
    ],
  })
);
```

```js
const aroundWar = db.query(
  `SELECT * FROM presse WHERE date >= '1920' AND date < '1970'`
);
```

```js
display(
  Plot.plot({
    x: { type: "utc" },
    marks: [
      Plot.rectY(
        aroundWar,
        Plot.binX(
          { y: "count" },
          {
            x: "date",
            thresholds: "1 year",
            tip: true,
          }
        )
      ),
    ],
  })
);
```