use target tokens instead of target constructs to get practice activi… (#1274)

* use target tokens instead of target constructs to get practice activity uses

* save morph construct for token parts of speech
This commit is contained in:
ggurdin 2024-12-18 16:08:33 -05:00 committed by GitHub
parent 2641d31c55
commit 341f44090d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 103 additions and 16 deletions

View file

@ -38,7 +38,15 @@ class TargetTokensAndActivityType {
.where(activityType.constructFilter)
.toList();
return listEquals(activity.tgtConstructs, relevantConstructs);
final List<ConstructIdentifier>? otherRelevantConstructs = activity
.targetTokens
?.map((t) => t.constructs)
.expand((e) => e)
.map((c) => c.id)
.where(activityType.constructFilter)
.toList();
return listEquals(otherRelevantConstructs, relevantConstructs);
}
@override

View file

@ -184,6 +184,16 @@ class PutAnalyticsController extends BaseController<AnalyticsStream> {
// get all our grammar constructs
for (final token in tokensToSave) {
uses.add(
OneConstructUse(
useType: useType,
lemma: token.pos,
form: token.text.content,
category: "POS",
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
);
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(

View file

@ -79,7 +79,7 @@ class OneConstructUse {
required this.lemma,
required this.constructType,
required this.metadata,
category,
required category,
required this.form,
this.id,
}) : _category = category ?? "other";

View file

@ -5,6 +5,7 @@
import 'dart:developer';
import 'package:fluffychat/pangea/enum/activity_type_enum.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/practice_activity_model.dart';
@ -153,20 +154,53 @@ class ActivityRecordResponse {
List<OneConstructUse> toUses(
PracticeActivityModel practiceActivity,
ConstructUseMetaData metadata,
) =>
practiceActivity.tgtConstructs
.map(
(construct) => OneConstructUse(
lemma: construct.lemma,
// TODO - add form to practiceActivity target_construct data somehow
form: null,
constructType: construct.type,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: construct.category,
),
)
.toList();
) {
if (practiceActivity.targetTokens == null) {
return [];
}
final uses = practiceActivity.targetTokens!
.map(
(token) => OneConstructUse(
lemma: token.lemma.text,
form: token.text.content,
constructType: ConstructTypeEnum.vocab,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: token.pos,
),
)
.toList();
uses.addAll(
practiceActivity.targetTokens!.map((token) {
return OneConstructUse(
lemma: token.pos,
form: token.text.content,
constructType: ConstructTypeEnum.morph,
useType: useType(practiceActivity.activityType),
metadata: metadata,
category: "POS",
);
}),
);
for (final token in practiceActivity.targetTokens!) {
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(
useType: useType(practiceActivity.activityType),
lemma: entry.value,
form: token.text.content,
category: entry.key,
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
);
}
}
return uses;
}
factory ActivityRecordResponse.fromJson(Map<String, dynamic> json) {
return ActivityRecordResponse(

View file

@ -154,6 +154,18 @@ class PangeaRepresentation {
MatrixState.pangeaController.languageController.activeL2Code();
final useType =
inUserL2 ? ConstructUseTypeEnum.wa : ConstructUseTypeEnum.unk;
uses.add(
OneConstructUse(
useType: useType,
lemma: token.pos,
form: token.text.content,
category: "POS",
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
);
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(
@ -206,6 +218,18 @@ class PangeaRepresentation {
metadata,
),
);
uses.add(
OneConstructUse(
useType: ConstructUseTypeEnum.ga,
lemma: token.pos,
form: token.text.content,
category: "POS",
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
);
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(
@ -223,6 +247,17 @@ class PangeaRepresentation {
}
}
uses.add(
OneConstructUse(
useType: ConstructUseTypeEnum.wa,
lemma: token.pos,
form: token.text.content,
category: "POS",
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
);
// the token wasn't found in any IT or IGC step, so it was wa
for (final entry in token.morph.entries) {
uses.add(