chore(practice_selection): preferencing tokens without activities in selection
This commit is contained in:
parent
af1cc0b8c2
commit
9971ca50b9
2 changed files with 34 additions and 19 deletions
|
|
@ -110,6 +110,16 @@ class PracticeSelection {
|
|||
// bool get canDoWordFocusListening =>
|
||||
// _tokens.where((t) => t.canBeHeard).length > 4;
|
||||
|
||||
bool tokenIsIncludedInActivityOfAnyType(
|
||||
PangeaToken t,
|
||||
) {
|
||||
return _activityQueue.entries.any(
|
||||
(perActivityQueue) => perActivityQueue.value.any(
|
||||
(entry) => entry.tokens.contains(t),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<PracticeTarget> buildActivity(ActivityTypeEnum activityType) {
|
||||
if (!eligibleForPractice) {
|
||||
return [];
|
||||
|
|
@ -117,10 +127,16 @@ class PracticeSelection {
|
|||
|
||||
final List<PangeaToken> tokens =
|
||||
_tokens.where((t) => t.lemma.saveVocab).sorted(
|
||||
(a, b) => b.activityPriorityScore(activityType, null).compareTo(
|
||||
a.activityPriorityScore(activityType, null),
|
||||
),
|
||||
);
|
||||
(a, b) {
|
||||
final bScore = b.activityPriorityScore(activityType, null) *
|
||||
(tokenIsIncludedInActivityOfAnyType(b) ? 1.1 : 1);
|
||||
|
||||
final aScore = a.activityPriorityScore(activityType, null) *
|
||||
(tokenIsIncludedInActivityOfAnyType(a) ? 1.1 : 1);
|
||||
|
||||
return bScore.compareTo(aScore);
|
||||
},
|
||||
);
|
||||
|
||||
return [
|
||||
PracticeTarget(
|
||||
|
|
@ -148,17 +164,17 @@ class PracticeSelection {
|
|||
);
|
||||
},
|
||||
).sorted(
|
||||
(a, b) => b.tokens.first
|
||||
.activityPriorityScore(
|
||||
ActivityTypeEnum.morphId,
|
||||
b.morphFeature!,
|
||||
)
|
||||
.compareTo(
|
||||
a.tokens.first.activityPriorityScore(
|
||||
ActivityTypeEnum.morphId,
|
||||
a.morphFeature!,
|
||||
),
|
||||
),
|
||||
(a, b) {
|
||||
final bScore = b.tokens.first.activityPriorityScore(
|
||||
ActivityTypeEnum.morphId, b.morphFeature!) *
|
||||
(tokenIsIncludedInActivityOfAnyType(b.tokens.first) ? 1.1 : 1);
|
||||
|
||||
final aScore = a.tokens.first.activityPriorityScore(
|
||||
ActivityTypeEnum.morphId, a.morphFeature!) *
|
||||
(tokenIsIncludedInActivityOfAnyType(a.tokens.first) ? 1.1 : 1);
|
||||
|
||||
return bScore.compareTo(aScore);
|
||||
},
|
||||
);
|
||||
//pick from the top 5, only including one per token
|
||||
final List<PracticeTarget> finalSelection = [];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pages/chat/chat.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/enums/message_mode_enum.dart';
|
||||
|
|
@ -11,6 +7,8 @@ import 'package:fluffychat/pangea/toolbar/widgets/message_speech_to_text_card.da
|
|||
import 'package:fluffychat/pangea/toolbar/widgets/message_translation_card.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/practice_activity/practice_activity_card.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/widgets/word_zoom/morph_focus_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
const double minContentHeight = 120;
|
||||
|
||||
|
|
@ -116,6 +114,7 @@ class ReadingAssistanceInputBar extends StatelessWidget {
|
|||
constraints: BoxConstraints(
|
||||
maxHeight: (MediaQuery.of(context).size.height / 2) -
|
||||
AppConfig.toolbarButtonsHeight,
|
||||
maxWidth: overlayController.maxWidth,
|
||||
),
|
||||
child: AnimatedSize(
|
||||
duration: const Duration(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue