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:
parent
a322cb5ad2
commit
4374e60779
3 changed files with 8 additions and 13 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue