Skip to content

Conversation

@marcarl
Copy link
Collaborator

@marcarl marcarl commented Jan 6, 2026

Summary

Implements the selex:upphavd_av attribute to track which ändringsförfattning repealed each section. This resolves the TODO comment at formatters/format_sfs_text.py:718.

Changes

New files:

  • temporal/parse_anteckningar.py - Parser for Swedish amendment notes (anteckningar)
    • Extracts repealed (upph.), amended (ändr.), and new (ny/nya) paragraphs
    • Handles various formats: upph. 29 kap. 15, 16 §§
    • 92% test coverage
  • test/test_parse_anteckningar.py - Comprehensive test suite (27 tests)

Modified files:

  • sfs_processor.py - Build repeal_map from andringsforfattningar and pass to formatter
  • formatters/format_sfs_text.py - Add selex:upphavd_av attribute with ID normalization
  • test/test_format_sfs_text.py - Integration tests for repeal_map functionality (8 tests)

Example Output

Before:

<section class="paragraf" selex:status="upphavd" selex:upphor_datum="2015-07-01">

After:

<section class="paragraf" selex:status="upphavd" selex:upphor_datum="2015-07-01" selex:upphavd_av="2015:73">

Testing

  • ✅ All 68 tests passing
  • ✅ No regressions in existing functionality
  • ✅ Validated with real data from 2010:800.json
  • ✅ Backward compatible (works without repeal_map)

Scope

Phase 1 (this PR):

  • Simple paragraph-level repeals: upph. 15 §, upph. 29 kap. 15 §
  • Multiple paragraphs: upph. 29 kap. 15, 16 §§
  • Paragraph letters: upph. 29 kap. 22 a §

Phase 2 (future):

  • Chapter-level repeals: upph. 23 kap.
  • Paragraph renumbering: betecknas
  • Complex patterns

🤖 Generated with Claude Code

Implements selex:upphavd_av attribute to link repealed sections to their
repealing ändringsförfattning. This resolves the TODO at format_sfs_text.py:718.

Changes:
- Add temporal/parse_anteckningar.py: Parser for Swedish amendment notes
  (anteckningar) that extracts repealed, amended, and new paragraphs
- Modify sfs_processor.py: Build repeal_map from andringsforfattningar
  and pass to formatter
- Modify formatters/format_sfs_text.py: Add selex:upphavd_av attribute
  to repealed sections with helper function for ID normalization
- Add comprehensive test coverage: 27 parser tests + 8 integration tests

Example output:
<section selex:status="upphavd" selex:upphavd_av="2015:73">

All 68 tests passing. Validated with real data from 2010:800.json.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@marcarl marcarl changed the title Track which ändringsförfattning repealed each section Track which document repealed each section Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants