|
3 | 3 | The full dataset is never inferred from a moving branch. Builders must check out |
4 | 4 | ``globalwordnet/english-wordnet`` at the exact release tag and commit declared |
5 | 5 | below, then pass the ``src/yaml`` directory to :func:`load_oewn_2025`. |
| 6 | +
|
| 7 | +Sense order is source evidence. The loader therefore preserves the order of the |
| 8 | +OEWN ``sense`` list exactly rather than sorting senses by identifier. |
6 | 9 | """ |
7 | 10 |
|
8 | 11 | # === MODULE_BUILD === |
9 | 12 | # id: edcm_language_oewn_source |
10 | 13 | # module_name: source |
11 | 14 | # module_kind: adapter |
12 | | -# summary: loads the exact Open English WordNet 2025 YAML release into deterministic lemma, sense, synset, and relation records and computes a source-tree digest |
| 15 | +# summary: loads the exact Open English WordNet 2025 YAML release while preserving source sense and definition order, deterministic lemma/synset indexing, relation records, and source-tree digest |
13 | 16 | # owner: Erin Spencer |
14 | 17 | # public_surface: OEWN_REPOSITORY, OEWN_TAG, OEWN_COMMIT, OEWN_LICENSE, LexemeRecord, SenseRecord, SynsetRecord, WordnetSnapshot, load_oewn_2025 |
15 | 18 | # internal_surface: _load_yaml, _source_tree_digest, _relation_values |
|
18 | 21 | # network_boundary: none |
19 | 22 | # user_data_boundary: none |
20 | 23 | # admin_only: false |
21 | | -# tests: tests.test_language_full_run |
| 24 | +# tests: tests.test_language_full_run, tests.test_source_order |
22 | 25 | # rollout: builder_only |
23 | 26 | # rollback: remove loader and generated artifacts before publishing another source manifest |
24 | 27 | # requires: PyYAML only during artifact construction |
25 | 28 | # since: 2026-07-13 |
26 | 29 | # unresolved: none |
27 | 30 | # === END MODULE_BUILD === |
28 | 31 |
|
| 32 | +# === CONTRACTS === |
| 33 | +# id: oewn_source_preserves_sense_order |
| 34 | +# given: a lexical entry with an ordered OEWN sense list |
| 35 | +# then: LexemeRecord.senses preserves that source order exactly rather than sorting by sense id |
| 36 | +# class: correctness |
| 37 | +# since: 2026-09-14 |
| 38 | +# === END CONTRACTS === |
| 39 | + |
29 | 40 | from __future__ import annotations |
30 | 41 |
|
31 | 42 | from dataclasses import dataclass |
@@ -89,7 +100,12 @@ class SynsetRecord: |
89 | 100 |
|
90 | 101 | @dataclass(frozen=True, slots=True) |
91 | 102 | class WordnetSnapshot: |
92 | | - """Deterministically ordered, dictionary-bounded source snapshot.""" |
| 103 | + """Deterministically indexed, dictionary-bounded source snapshot. |
| 104 | +
|
| 105 | + Lexeme and synset containers are sorted for deterministic lookup, while |
| 106 | + order-bearing source sequences inside records (notably senses and |
| 107 | + definitions) retain their source order. |
| 108 | + """ |
93 | 109 |
|
94 | 110 | lexemes: tuple[LexemeRecord, ...] |
95 | 111 | synsets: tuple[SynsetRecord, ...] |
@@ -242,7 +258,7 @@ def load_oewn_2025(source_root: str | Path) -> WordnetSnapshot: |
242 | 258 | lemma=lemma, |
243 | 259 | part_of_speech=str(raw_pos), |
244 | 260 | forms=forms, |
245 | | - senses=tuple(sorted(senses, key=lambda item: item.sense_id)), |
| 261 | + senses=tuple(senses), |
246 | 262 | ) |
247 | 263 | ) |
248 | 264 |
|
|
0 commit comments