Commit f6a3f34
authored
Add document type (normtyp) as metadata (#39)
## Summary
This PR adds support for classifying SFS documents by their legal type
(doctype) with three categories:
- **Grundlag** (Fundamental law) - Sweden's four constitutional laws
- **Lag** (Law) - Regular laws
- **Förordning** (Regulation) - Regulations
## Changes
- ✨ Add `util/doctype_utils.py` with `determine_doctype()` function
- 🔍 Identify Sweden's four fundamental laws by SFS number (1974:152,
1810:0926, 1949:105, 1991:1469)
- 📝 Integrate doctype into markdown frontmatter generation (after
departement field)
- 🌐 Add doctype to HTML export metadata display
- 🔄 Update frontmatter property ordering to include doctype
- 📝 Use English key "doctype" for consistency in code and filenames
## Implementation Details
The doctype is determined by:
1. First checking if the SFS number matches one of the four grundlagar
2. If not, using the `forfattningstypNamn` field from source data
3. Defaulting to "Lag" if no explicit type information is available
Field key uses English ("doctype") while values remain in Swedish
(Grundlag, Lag, Förordning) as these are the official Swedish legal
terms.
## Test Results
- ✅ 1974:152 (Regeringsformen) → `doctype: Grundlag`
- ✅ 2010:800 (Skollagen) → `doctype: Lag`
- ✅ 2024:1274 → `doctype: Förordning`
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 35832eb commit f6a3f34
4 files changed
Lines changed: 89 additions & 2 deletions
File tree
- exporters/html
- formatters
- util
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
215 | 220 | | |
216 | 221 | | |
217 | 222 | | |
| |||
264 | 269 | | |
265 | 270 | | |
266 | 271 | | |
267 | | - | |
| 272 | + | |
268 | 273 | | |
269 | 274 | | |
270 | 275 | | |
271 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
272 | 282 | | |
273 | 283 | | |
274 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
314 | 319 | | |
315 | 320 | | |
316 | 321 | | |
| |||
348 | 353 | | |
349 | 354 | | |
350 | 355 | | |
| 356 | + | |
351 | 357 | | |
352 | 358 | | |
353 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments