make construct use category a String? instead of a list, set it to POS for vocab constructs
This commit is contained in:
parent
3a39a1aa85
commit
6b643a841a
7 changed files with 54 additions and 31 deletions
|
|
@ -151,6 +151,7 @@ class MyAnalyticsController extends BaseController<AnalyticsStream> {
|
|||
form: token.lemma.form,
|
||||
constructType: ConstructTypeEnum.vocab,
|
||||
metadata: metadata,
|
||||
category: token.pos,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
|
@ -161,7 +162,7 @@ class MyAnalyticsController extends BaseController<AnalyticsStream> {
|
|||
OneConstructUse(
|
||||
useType: useType,
|
||||
lemma: entry.value,
|
||||
categories: [entry.key],
|
||||
category: entry.key,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ConstructAnalyticsModel {
|
|||
class OneConstructUse {
|
||||
String? lemma;
|
||||
String? form;
|
||||
List<String> categories;
|
||||
String? category;
|
||||
ConstructTypeEnum constructType;
|
||||
ConstructUseTypeEnum useType;
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ class OneConstructUse {
|
|||
required this.lemma,
|
||||
required this.constructType,
|
||||
required this.metadata,
|
||||
this.categories = const [],
|
||||
this.category,
|
||||
this.form,
|
||||
this.id,
|
||||
});
|
||||
|
|
@ -104,13 +104,21 @@ class OneConstructUse {
|
|||
: null;
|
||||
debugger(when: kDebugMode && constructType == null);
|
||||
|
||||
final categoryEntry = json['categories'];
|
||||
String? category;
|
||||
if (categoryEntry != null) {
|
||||
if ((categoryEntry is List) && categoryEntry.isNotEmpty) {
|
||||
category = categoryEntry.first;
|
||||
} else if (categoryEntry is String) {
|
||||
category = categoryEntry;
|
||||
}
|
||||
}
|
||||
|
||||
return OneConstructUse(
|
||||
useType: ConstructUseTypeUtil.fromString(json['useType']),
|
||||
lemma: json['lemma'],
|
||||
form: json['form'],
|
||||
categories: json['categories'] != null
|
||||
? List<String>.from(json['categories'])
|
||||
: [],
|
||||
category: category,
|
||||
constructType: constructType ?? ConstructTypeEnum.vocab,
|
||||
id: json['id'],
|
||||
metadata: ConstructUseMetaData(
|
||||
|
|
@ -134,7 +142,7 @@ class OneConstructUse {
|
|||
data['constructType'] = constructType.string;
|
||||
|
||||
if (id != null) data['id'] = id;
|
||||
data['categories'] = categories;
|
||||
data['categories'] = category;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/models/analytics/constructs_model.dart';
|
||||
|
||||
/// Represents a lemma object
|
||||
class Lemma {
|
||||
/// [text] ex "ir" - text of the lemma of the word
|
||||
|
|
@ -39,18 +35,4 @@ class Lemma {
|
|||
|
||||
static Lemma create(String form) =>
|
||||
Lemma(text: '', saveVocab: true, form: form);
|
||||
|
||||
/// Given a [type] and [metadata], returns a [OneConstructUse] for this lemma
|
||||
OneConstructUse toVocabUse(
|
||||
ConstructUseTypeEnum type,
|
||||
ConstructUseMetaData metadata,
|
||||
) {
|
||||
return OneConstructUse(
|
||||
useType: type,
|
||||
lemma: text,
|
||||
form: form,
|
||||
constructType: ConstructTypeEnum.vocab,
|
||||
metadata: metadata,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import 'dart:developer';
|
|||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/models/analytics/constructs_model.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/message_activity_request.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
|
@ -127,6 +129,7 @@ class PangeaToken {
|
|||
id: ConstructIdentifier(
|
||||
lemma: lemma.text,
|
||||
type: ConstructTypeEnum.vocab,
|
||||
category: pos,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -135,8 +138,9 @@ class PangeaToken {
|
|||
constructs.add(
|
||||
ConstructWithXP(
|
||||
id: ConstructIdentifier(
|
||||
lemma: morph.key,
|
||||
lemma: morph.value,
|
||||
type: ConstructTypeEnum.morph,
|
||||
category: morph.key,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -147,6 +151,21 @@ class PangeaToken {
|
|||
constructs: constructs,
|
||||
);
|
||||
}
|
||||
|
||||
/// Given a [type] and [metadata], returns a [OneConstructUse] for this lemma
|
||||
OneConstructUse toVocabUse(
|
||||
ConstructUseTypeEnum type,
|
||||
ConstructUseMetaData metadata,
|
||||
) {
|
||||
return OneConstructUse(
|
||||
useType: type,
|
||||
lemma: lemma.text,
|
||||
form: lemma.form,
|
||||
constructType: ConstructTypeEnum.vocab,
|
||||
metadata: metadata,
|
||||
category: pos,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PangeaTokenText {
|
||||
|
|
|
|||
|
|
@ -12,16 +12,28 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||
class ConstructIdentifier {
|
||||
final String lemma;
|
||||
final ConstructTypeEnum type;
|
||||
String? category;
|
||||
|
||||
ConstructIdentifier({required this.lemma, required this.type});
|
||||
ConstructIdentifier({
|
||||
required this.lemma,
|
||||
required this.type,
|
||||
this.category,
|
||||
});
|
||||
|
||||
factory ConstructIdentifier.fromJson(Map<String, dynamic> json) {
|
||||
final categoryEntry = json['cat'];
|
||||
String? category;
|
||||
if (categoryEntry != null && categoryEntry is String) {
|
||||
category = categoryEntry;
|
||||
}
|
||||
|
||||
try {
|
||||
return ConstructIdentifier(
|
||||
lemma: json['lemma'] as String,
|
||||
type: ConstructTypeEnum.values.firstWhere(
|
||||
(e) => e.string == json['type'],
|
||||
),
|
||||
category: category,
|
||||
);
|
||||
} catch (e, s) {
|
||||
debugger(when: kDebugMode);
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ class ActivityRecordResponse {
|
|||
constructType: construct.type,
|
||||
useType: useType,
|
||||
metadata: metadata,
|
||||
category: construct.category,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class PangeaRepresentation {
|
|||
OneConstructUse(
|
||||
useType: useType,
|
||||
lemma: entry.value,
|
||||
categories: [entry.key],
|
||||
category: entry.key,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
),
|
||||
|
|
@ -166,7 +166,7 @@ class PangeaRepresentation {
|
|||
|
||||
if (lemma.saveVocab) {
|
||||
uses.add(
|
||||
lemma.toVocabUse(
|
||||
token.toVocabUse(
|
||||
inUserL2 ? ConstructUseTypeEnum.wa : ConstructUseTypeEnum.unk,
|
||||
metadata,
|
||||
),
|
||||
|
|
@ -213,7 +213,7 @@ class PangeaRepresentation {
|
|||
OneConstructUse(
|
||||
useType: ConstructUseTypeEnum.wa,
|
||||
lemma: entry.value,
|
||||
categories: [entry.key],
|
||||
category: entry.key,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
),
|
||||
|
|
@ -221,7 +221,7 @@ class PangeaRepresentation {
|
|||
}
|
||||
if (lemma.saveVocab) {
|
||||
uses.add(
|
||||
lemma.toVocabUse(
|
||||
token.toVocabUse(
|
||||
ConstructUseTypeEnum.wa,
|
||||
metadata,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue