fix: Prevent Grammar Practice Blank Fill-Ins (#5464)
This commit is contained in:
parent
165a8fb7a4
commit
61f18aa403
2 changed files with 10 additions and 11 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/analytics_misc/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/analytics_misc/construct_use_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/analytics_practice/analytics_practice_constants.dart';
|
||||
|
|
@ -238,12 +240,19 @@ class AnalyticsPracticeSessionRepo {
|
|||
for (int i = 0; i < choreo.choreoSteps.length; i++) {
|
||||
final step = choreo.choreoSteps[i];
|
||||
final igcMatch = step.acceptedOrIgnoredMatch;
|
||||
final stepText = choreo.stepText(stepIndex: i - 1);
|
||||
if (igcMatch?.isGrammarMatch != true ||
|
||||
igcMatch?.match.bestChoice == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final choices = igcMatch!.match.choices!.map((c) => c.value).toList();
|
||||
if (igcMatch!.match.offset == 0 &&
|
||||
igcMatch.match.length >= stepText.trim().characters.length) {
|
||||
// Skip if the grammar error spans the entire step
|
||||
continue;
|
||||
}
|
||||
|
||||
final choices = igcMatch.match.choices!.map((c) => c.value).toList();
|
||||
final choiceTokens = tokens
|
||||
.where(
|
||||
(token) =>
|
||||
|
|
|
|||
|
|
@ -593,7 +593,6 @@ class PangeaMessageEvent {
|
|||
}
|
||||
|
||||
Future<String> requestRespresentationByL1() async {
|
||||
debugPrint("LATEST EDIT: ${_latestEdit.toJson()}");
|
||||
if (_l1Code == null || _l2Code == null) {
|
||||
throw Exception("Missing language codes");
|
||||
}
|
||||
|
|
@ -605,9 +604,7 @@ class PangeaMessageEvent {
|
|||
RepresentationEvent? rep;
|
||||
if (!includedIT) {
|
||||
// if the message didn't go through translation, get any l1 rep
|
||||
debugPrint("REPRESENTATIONS: ${representations.length}");
|
||||
rep = representationByLanguage(_l1Code!);
|
||||
debugPrint("REP: $rep");
|
||||
} else {
|
||||
// if the message went through translation, get the non-original
|
||||
// l1 rep since originalWritten could contain some l2 words
|
||||
|
|
@ -624,13 +621,6 @@ class PangeaMessageEvent {
|
|||
? (originalWritten?.langCode ?? _l1Code!)
|
||||
: (originalSent?.langCode ?? _l2Code!);
|
||||
|
||||
debugPrint("Original written content: $originalWrittenContent");
|
||||
debugPrint("Message display text: $messageDisplayText");
|
||||
debugPrint("Original sent: ${originalSent?.content.toJson()}");
|
||||
debugPrint(
|
||||
"Message display rep: ${representationByLanguage(messageDisplayLangCode)?.content.toJson()}",
|
||||
);
|
||||
|
||||
final resp = await _requestRepresentation(
|
||||
includedIT ? originalWrittenContent : messageDisplayText,
|
||||
_l1Code!,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue