Skip to content

Commit 918c319

Browse files
authored
feat: custom sort order for morph features (#1794)
1 parent a0ef9c4 commit 918c319

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lib/pangea/analytics_details_popup/morph_analytics_view.dart

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ class MorphAnalyticsView extends StatelessWidget {
3131
builder: (context, snapshot) {
3232
final morphs = snapshot.data ?? defaultMorphMapping;
3333

34+
morphs.displayFeatures.sort(
35+
(a, b) => morphFeatureSortOrder
36+
.indexOf(a.feature)
37+
.compareTo(morphFeatureSortOrder.indexOf(b.feature)),
38+
);
39+
3440
return snapshot.connectionState == ConnectionState.done
3541
? ListView.builder(
3642
key: const PageStorageKey<String>('morph-analytics'),

lib/pangea/morphs/default_morph_mapping.dart

+33
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,36 @@ final MorphFeaturesAndTags defaultMorphMapping = MorphFeaturesAndTags.fromJson({
232232
}
233233
],
234234
});
235+
236+
final List<String> morphFeatureSortOrder = [
237+
"pos",
238+
"advtype",
239+
"aspect",
240+
"case",
241+
"conjtype",
242+
"definite",
243+
"degree",
244+
"evident",
245+
"gender",
246+
"mood",
247+
"nountype",
248+
"numform",
249+
"numtype",
250+
"number",
251+
"number[psor]",
252+
"person",
253+
"polarity",
254+
"polite",
255+
"poss",
256+
"prepcase",
257+
"prontype",
258+
"punctside",
259+
"puncttype",
260+
"reflex",
261+
"tense",
262+
"verbform",
263+
"verbtype",
264+
"voice",
265+
"foreign",
266+
"x",
267+
];

0 commit comments

Comments
 (0)