feat: custom sort order for morph features (#1794)

This commit is contained in:
ggurdin 2025-02-14 11:06:45 -05:00 committed by GitHub
parent a0ef9c4424
commit 918c3193af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View file

@ -31,6 +31,12 @@ class MorphAnalyticsView extends StatelessWidget {
builder: (context, snapshot) {
final morphs = snapshot.data ?? defaultMorphMapping;
morphs.displayFeatures.sort(
(a, b) => morphFeatureSortOrder
.indexOf(a.feature)
.compareTo(morphFeatureSortOrder.indexOf(b.feature)),
);
return snapshot.connectionState == ConnectionState.done
? ListView.builder(
key: const PageStorageKey<String>('morph-analytics'),

View file

@ -232,3 +232,36 @@ final MorphFeaturesAndTags defaultMorphMapping = MorphFeaturesAndTags.fromJson({
}
],
});
final List<String> morphFeatureSortOrder = [
"pos",
"advtype",
"aspect",
"case",
"conjtype",
"definite",
"degree",
"evident",
"gender",
"mood",
"nountype",
"numform",
"numtype",
"number",
"number[psor]",
"person",
"polarity",
"polite",
"poss",
"prepcase",
"prontype",
"punctside",
"puncttype",
"reflex",
"tense",
"verbform",
"verbtype",
"voice",
"foreign",
"x",
];