don't log missing POS error for POS 'other' (#5039)

* don't long missing POS error for POS 'other'

* don't long error for missing grammar copy if lemma is 'other'
This commit is contained in:
ggurdin 2026-01-05 11:05:34 -05:00 committed by GitHub
parent a322cb5ad2
commit 4374e60779
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 13 deletions

View file

@ -137,7 +137,7 @@ class ConstructIdentifier {
}
bool get isContentWord =>
PartOfSpeechEnumExtensions.fromString(category)?.isContentWord ?? false;
PartOfSpeechEnum.fromString(category)?.isContentWord ?? false;
LemmaInfoRequest lemmaInfoRequest(Map<String, dynamic> messageInfo) =>
LemmaInfoRequest(

View file

@ -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;
}

View file

@ -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);
}