remove context from span data, improve isITStart

This commit is contained in:
wcjord 2024-12-20 08:26:33 -05:00
parent 06817ba4cc
commit ccf19aa8a4
6 changed files with 7 additions and 36 deletions

View file

@ -23,7 +23,7 @@ void main() async {
// #Pangea
try {
await dotenv.load(fileName: ".env");
await dotenv.load(fileName: ".env.local_choreo");
} catch (e) {
Logs().e('Failed to load .env file', e);
}

View file

@ -81,7 +81,7 @@ class SpanDataController {
choreographer.igc.igcTextData!.matches[matchIndex].match =
(await response).span;
} catch (err, s) {
ErrorHandler.logError(e: err, s: s);
ErrorHandler.logError(e: err, s: s, data: req.toJson());
}
choreographer.setState();

View file

@ -1,5 +1,8 @@
class MatchRuleIds {
static const interactiveTranslation = "interactive_translation";
/// note these are not currently being passed by the server
/// we may bring them back at some point
static const tokenNeedsTranslation = "token_needs_translation";
static const tokenSpanNeedsTranslation = "token_span_needs_translation";
static const l1SpanAndGrammar = "l1_span_and_grammar";

View file

@ -65,7 +65,8 @@ class PangeaMatch {
bool get isITStart =>
match.rule?.id == MatchRuleIds.interactiveTranslation ||
match.type.typeName == SpanDataTypeEnum.itStart;
[SpanDataTypeEnum.itStart, SpanDataTypeEnum.itStart.name]
.contains(match.type.typeName);
bool get needsTranslation => match.rule?.id != null
? [

View file

@ -19,7 +19,6 @@ class SpanData {
required this.choices,
required this.offset,
required this.length,
required this.context,
required this.fullText,
required this.type,
required this.rule,
@ -37,8 +36,6 @@ class SpanData {
.toList(),
offset: json['offset'] as int,
length: json['length'] as int,
context:
json['context'] != null ? Context.fromJson(json['context']) : null,
fullText:
json['sentence'] ?? json['full_text'] ?? json['fullText'] as String,
type: SpanDataType.fromJson(json['type'] as Map<String, dynamic>),
@ -53,7 +50,6 @@ class SpanData {
List<SpanChoice>? choices;
int offset;
int length;
Context? context;
String fullText;
SpanDataType type;
Rule? rule;
@ -66,40 +62,12 @@ class SpanData {
: null,
'offset': offset,
'length': length,
'context': context?.toJson(),
'full_text': fullText,
'type': type.toJson(),
'rule': rule?.toJson(),
};
}
class Context {
Context({
required this.text,
required this.offset,
required this.length,
});
factory Context.fromJson(Map<String, dynamic> json) {
return Context(
text: json['text'] as String,
offset: json['offset'] as int,
length: json['length'] as int,
);
}
/// full text of the message
String text;
int offset;
int length;
Map<String, dynamic> toJson() => {
'text': text,
'offset': offset,
'length': length,
};
}
class SpanChoice {
String value;
SpanChoiceType type;

View file

@ -119,7 +119,6 @@ final spanDataRepomockSpan = SpanData(
length: 2,
fullText: "This be a sample text",
type: SpanDataType(typeName: SpanDataTypeEnum.correction),
context: null,
choices: [SpanChoice(value: "is", type: SpanChoiceType.bestCorrection)],
message: null,
rule: null,