BrokenSentence.fromJson constructor
BrokenSentence.fromJson(
- Map<String, dynamic> json
)
Implementation
factory BrokenSentence.fromJson(Map<String, dynamic> json) {
final sentLen = (json['sentLen'] as List).cast<int>();
List<String> segments = [];
int start = 0;
for (final len in sentLen) {
segments.add(json['text'].substring(start, start + len));
start += len;
}
return BrokenSentence(
text: json['text'],
sentLen: sentLen,
segments: segments,
detectedLanguage: json.containsKey('detectedLanguage')
? DetectedLanguage.fromJson(json['detectedLanguage'])
: null,
);
}