@@ -196,7 +196,7 @@ an<Translation> ScriptTranslator::Query(const string& input,
196
196
}
197
197
auto deduped = New<DistinctTranslation>(result);
198
198
if (contextual_suggestions_) {
199
- return poet_->ContextualWeighted (deduped, input, this );
199
+ return poet_->ContextualWeighted (deduped, input, segment. start , this );
200
200
}
201
201
return deduped;
202
202
}
@@ -218,9 +218,10 @@ string ScriptTranslator::Spell(const Code& code) {
218
218
return result;
219
219
}
220
220
221
- string ScriptTranslator::GetPrecedingText () const {
222
- return contextual_suggestions_ ?
223
- engine_->context ()->commit_history ().latest_text () : string ();
221
+ string ScriptTranslator::GetPrecedingText (size_t start) const {
222
+ return !contextual_suggestions_ ? string () :
223
+ start > 0 ? engine_->context ()->composition ().GetTextBefore (start) :
224
+ engine_->context ()->commit_history ().latest_text ();
224
225
}
225
226
226
227
bool ScriptTranslator::Memorize (const CommitEntry& commit_entry) {
@@ -547,9 +548,10 @@ an<Sentence> ScriptTranslation::MakeSentence(Dictionary* dict,
547
548
}
548
549
}
549
550
}
550
- if (auto sentence = poet_->MakeSentence (graph,
551
- syllable_graph.interpreted_length ,
552
- translator_->GetPrecedingText ())) {
551
+ if (auto sentence =
552
+ poet_->MakeSentence (graph,
553
+ syllable_graph.interpreted_length ,
554
+ translator_->GetPrecedingText (start_))) {
553
555
sentence->Offset (start_);
554
556
sentence->set_syllabifier (syllabifier_);
555
557
return sentence;
0 commit comments