added 'categories' field to construct use model and started saving morph category
This commit is contained in:
parent
a367b756af
commit
0265019284
3 changed files with 35 additions and 32 deletions
|
|
@ -201,22 +201,19 @@ class MyAnalyticsController extends BaseController {
|
|||
)
|
||||
.toList();
|
||||
|
||||
final List<String> morphs = tokens
|
||||
.map((t) => t.morph.values)
|
||||
.expand((m) => m)
|
||||
.cast<String>()
|
||||
.toList();
|
||||
|
||||
uses.addAll(
|
||||
morphs.map(
|
||||
(morph) => OneConstructUse(
|
||||
useType: useType,
|
||||
lemma: morph,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
),
|
||||
),
|
||||
);
|
||||
for (final token in tokens) {
|
||||
for (final entry in token.morph.entries) {
|
||||
uses.add(
|
||||
OneConstructUse(
|
||||
useType: useType,
|
||||
lemma: entry.value,
|
||||
categories: [entry.key],
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final level = _pangeaController.analytics.level;
|
||||
addLocalMessage('draft$roomID', uses).then(
|
||||
|
|
|
|||
|
|
@ -74,8 +74,9 @@ class ConstructAnalyticsModel {
|
|||
|
||||
class OneConstructUse {
|
||||
String? lemma;
|
||||
ConstructTypeEnum? constructType;
|
||||
String? form;
|
||||
List<String> categories;
|
||||
ConstructTypeEnum? constructType;
|
||||
ConstructUseTypeEnum useType;
|
||||
String? id;
|
||||
ConstructUseMetaData metadata;
|
||||
|
|
@ -85,6 +86,7 @@ class OneConstructUse {
|
|||
required this.lemma,
|
||||
required this.constructType,
|
||||
required this.metadata,
|
||||
this.categories = const [],
|
||||
this.form,
|
||||
this.id,
|
||||
});
|
||||
|
|
@ -100,6 +102,9 @@ class OneConstructUse {
|
|||
ConstructUseTypeEnum.unk,
|
||||
lemma: json['lemma'],
|
||||
form: json['form'],
|
||||
categories: json['categories'] != null
|
||||
? List<String>.from(json['categories'])
|
||||
: [],
|
||||
constructType: json['constructType'] != null
|
||||
? ConstructTypeUtil.fromString(json['constructType'])
|
||||
: null,
|
||||
|
|
@ -113,7 +118,7 @@ class OneConstructUse {
|
|||
}
|
||||
|
||||
Map<String, dynamic> toJson([bool condensed = false]) {
|
||||
final Map<String, String?> data = {
|
||||
final Map<String, dynamic> data = {
|
||||
'useType': useType.string,
|
||||
'chatId': metadata.roomId,
|
||||
'timeStamp': metadata.timeStamp.toIso8601String(),
|
||||
|
|
@ -125,7 +130,7 @@ class OneConstructUse {
|
|||
data['constructType'] = constructType!.string;
|
||||
}
|
||||
if (id != null) data['id'] = id;
|
||||
|
||||
data['categories'] = categories;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,23 +146,23 @@ class PangeaRepresentation {
|
|||
final List<OneConstructUse> uses = [];
|
||||
final lemma = token.lemma;
|
||||
final content = token.text.content;
|
||||
final morphs = token.morph.values.toList();
|
||||
|
||||
if (choreo == null) {
|
||||
final bool inUserL2 = langCode ==
|
||||
MatrixState.pangeaController.languageController.activeL2Code();
|
||||
final useType =
|
||||
inUserL2 ? ConstructUseTypeEnum.wa : ConstructUseTypeEnum.unk;
|
||||
uses.addAll(
|
||||
morphs.map(
|
||||
(morph) => OneConstructUse(
|
||||
for (final entry in token.morph.entries) {
|
||||
uses.add(
|
||||
OneConstructUse(
|
||||
useType: useType,
|
||||
lemma: morph,
|
||||
lemma: entry.value,
|
||||
categories: [entry.key],
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
uses.add(
|
||||
lemma.toVocabUse(
|
||||
inUserL2 ? ConstructUseTypeEnum.wa : ConstructUseTypeEnum.unk,
|
||||
|
|
@ -205,16 +205,17 @@ class PangeaRepresentation {
|
|||
}
|
||||
}
|
||||
|
||||
uses.addAll(
|
||||
morphs.map(
|
||||
(morph) => OneConstructUse(
|
||||
for (final entry in token.morph.entries) {
|
||||
uses.add(
|
||||
OneConstructUse(
|
||||
useType: ConstructUseTypeEnum.wa,
|
||||
lemma: morph,
|
||||
lemma: entry.value,
|
||||
categories: [entry.key],
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
uses.add(
|
||||
lemma.toVocabUse(
|
||||
ConstructUseTypeEnum.wa,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue