Skip to content

Commit 0a97b09

Browse files
fix(english-gonol): preserve OEWN source sense order
1 parent 3840fb0 commit 0a97b09

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

  • research/english-gonol/english_gonol/language

research/english-gonol/english_gonol/language/source.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
The full dataset is never inferred from a moving branch. Builders must check out
44
``globalwordnet/english-wordnet`` at the exact release tag and commit declared
55
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.
69
"""
710

811
# === MODULE_BUILD ===
912
# id: edcm_language_oewn_source
1013
# module_name: source
1114
# 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
1316
# owner: Erin Spencer
1417
# public_surface: OEWN_REPOSITORY, OEWN_TAG, OEWN_COMMIT, OEWN_LICENSE, LexemeRecord, SenseRecord, SynsetRecord, WordnetSnapshot, load_oewn_2025
1518
# internal_surface: _load_yaml, _source_tree_digest, _relation_values
@@ -18,14 +21,22 @@
1821
# network_boundary: none
1922
# user_data_boundary: none
2023
# admin_only: false
21-
# tests: tests.test_language_full_run
24+
# tests: tests.test_language_full_run, tests.test_source_order
2225
# rollout: builder_only
2326
# rollback: remove loader and generated artifacts before publishing another source manifest
2427
# requires: PyYAML only during artifact construction
2528
# since: 2026-07-13
2629
# unresolved: none
2730
# === END MODULE_BUILD ===
2831

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+
2940
from __future__ import annotations
3041

3142
from dataclasses import dataclass
@@ -89,7 +100,12 @@ class SynsetRecord:
89100

90101
@dataclass(frozen=True, slots=True)
91102
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+
"""
93109

94110
lexemes: tuple[LexemeRecord, ...]
95111
synsets: tuple[SynsetRecord, ...]
@@ -242,7 +258,7 @@ def load_oewn_2025(source_root: str | Path) -> WordnetSnapshot:
242258
lemma=lemma,
243259
part_of_speech=str(raw_pos),
244260
forms=forms,
245-
senses=tuple(sorted(senses, key=lambda item: item.sense_id)),
261+
senses=tuple(senses),
246262
)
247263
)
248264

0 commit comments

Comments
 (0)