diff --git a/lib/pangea/constructs/construct_identifier.dart b/lib/pangea/constructs/construct_identifier.dart index f5c1716ca..ffc7136bb 100644 --- a/lib/pangea/constructs/construct_identifier.dart +++ b/lib/pangea/constructs/construct_identifier.dart @@ -137,7 +137,7 @@ class ConstructIdentifier { } bool get isContentWord => - PartOfSpeechEnumExtensions.fromString(category)?.isContentWord ?? false; + PartOfSpeechEnum.fromString(category)?.isContentWord ?? false; LemmaInfoRequest lemmaInfoRequest(Map messageInfo) => LemmaInfoRequest( diff --git a/lib/pangea/morphs/get_grammar_copy.dart b/lib/pangea/morphs/get_grammar_copy.dart index ab23c75f9..14085ab4a 100644 --- a/lib/pangea/morphs/get_grammar_copy.dart +++ b/lib/pangea/morphs/get_grammar_copy.dart @@ -15,7 +15,7 @@ String? getGrammarCopy({ required String lemma, required BuildContext context, }) { - if (category.toLowerCase() == 'other') { + if (category.toLowerCase() == 'other' || lemma.toLowerCase() == 'other') { return null; } diff --git a/lib/pangea/morphs/parts_of_speech_enum.dart b/lib/pangea/morphs/parts_of_speech_enum.dart index b3d202c1b..c9103781d 100644 --- a/lib/pangea/morphs/parts_of_speech_enum.dart +++ b/lib/pangea/morphs/parts_of_speech_enum.dart @@ -32,20 +32,13 @@ enum PartOfSpeechEnum { adp, propn, intj, - x, -} - -extension PartOfSpeechEnumExtensions on PartOfSpeechEnum { - /// Convert enum to string - String toShortString() { - return toString().split('.').last.toLowerCase(); - } + x; static PartOfSpeechEnum? fromString(String categoryName) { final pos = PartOfSpeechEnum.values.firstWhereOrNull( - (pos) => pos.toShortString() == categoryName.toLowerCase(), + (pos) => pos.name.toLowerCase() == categoryName.toLowerCase(), ); - if (pos == null) { + if (pos == null && categoryName.toLowerCase() != 'other') { ErrorHandler.logError( e: "Missing part of speech", s: StackTrace.current, @@ -154,6 +147,8 @@ extension PartOfSpeechEnumExtensions on PartOfSpeechEnum { String? getVocabCategoryName(String category, BuildContext context) { return PartOfSpeechEnum.values - .firstWhereOrNull((pos) => pos.toShortString() == category.toLowerCase()) + .firstWhereOrNull( + (pos) => pos.name.toLowerCase() == category.toLowerCase(), + ) ?.getDisplayCopy(context); }