fix(emoji_activity): don't give activity on any tokens with the same lemma or form (#2533)
This commit is contained in:
parent
fe88836e89
commit
0027ce8536
1 changed files with 20 additions and 5 deletions
|
|
@ -1,9 +1,6 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/lemmas/lemma_info_response.dart';
|
||||
|
|
@ -12,6 +9,7 @@ import 'package:fluffychat/pangea/practice_activities/activity_type_enum.dart';
|
|||
import 'package:fluffychat/pangea/practice_activities/practice_selection_repo.dart';
|
||||
import 'package:fluffychat/pangea/practice_activities/practice_target.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class PracticeSelection {
|
||||
late String _userL2;
|
||||
|
|
@ -127,8 +125,21 @@ class PracticeSelection {
|
|||
return [];
|
||||
}
|
||||
|
||||
final List<PangeaToken> tokens =
|
||||
_tokens.where((t) => t.lemma.saveVocab).sorted(
|
||||
final List<PangeaToken> basicallyEligible =
|
||||
_tokens.where((t) => t.lemma.saveVocab).toList();
|
||||
|
||||
// list of tokens with unique lemmas and surface forms
|
||||
final List<PangeaToken> tokens = [];
|
||||
for (final t in basicallyEligible) {
|
||||
if (!tokens.any(
|
||||
(token) =>
|
||||
token.lemma == t.lemma && token.text.content == t.text.content,
|
||||
)) {
|
||||
tokens.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
tokens.sorted(
|
||||
(a, b) {
|
||||
final bScore = b.activityPriorityScore(activityType, null) *
|
||||
(tokenIsIncludedInActivityOfAnyType(b) ? 1.1 : 1);
|
||||
|
|
@ -140,6 +151,10 @@ class PracticeSelection {
|
|||
},
|
||||
);
|
||||
|
||||
if (tokens.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
PracticeTarget(
|
||||
activityType: activityType,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue