@@ -67,7 +67,7 @@ an<Candidate> TableTranslation::Peek() {
67
67
if (exhausted ())
68
68
return nullptr ;
69
69
bool is_user_phrase = PreferUserPhrase ();
70
- auto e = PreferedEntry (is_user_phrase);
70
+ auto e = PreferredEntry (is_user_phrase);
71
71
string comment (is_constructed (e.get ()) ? kUnitySymbol : e->comment );
72
72
if (options_) {
73
73
options_->comment_formatter ().Apply (&comment);
@@ -559,12 +559,14 @@ TableTranslator::MakeSentence(const string& input, size_t start,
559
559
if (filter_by_charset) {
560
560
uter.AddFilter (CharsetFilter::FilterDictEntry);
561
561
}
562
- entries[consumed_length] = uter.Peek ();
563
- if (start_pos == 0 && !uter.exhausted ()) {
564
- // also provide words for manual composition
565
- uter.Release (&user_phrase_collector[consumed_length]);
566
- DLOG (INFO) << " user phrase[" << consumed_length << " ]: "
567
- << user_phrase_collector[consumed_length].size ();
562
+ if (!uter.exhausted ()) {
563
+ entries[consumed_length] = uter.Peek ();
564
+ if (start_pos == 0 ) {
565
+ // also provide words for manual composition
566
+ uter.Release (&user_phrase_collector[consumed_length]);
567
+ DLOG (INFO) << " user phrase[" << consumed_length << " ]: "
568
+ << user_phrase_collector[consumed_length].size ();
569
+ }
568
570
}
569
571
if (resume_key > active_key &&
570
572
!boost::starts_with (resume_key, active_key))
@@ -586,12 +588,14 @@ TableTranslator::MakeSentence(const string& input, size_t start,
586
588
if (filter_by_charset) {
587
589
uter.AddFilter (CharsetFilter::FilterDictEntry);
588
590
}
589
- entries[consumed_length] = uter.Peek ();
590
- if (start_pos == 0 && !uter.exhausted ()) {
591
- // also provide words for manual composition
592
- uter.Release (&user_phrase_collector[consumed_length]);
593
- DLOG (INFO) << " unity phrase[" << consumed_length << " ]: "
594
- << user_phrase_collector[consumed_length].size ();
591
+ if (!uter.exhausted ()) {
592
+ entries[consumed_length] = uter.Peek ();
593
+ if (start_pos == 0 ) {
594
+ // also provide words for manual composition
595
+ uter.Release (&user_phrase_collector[consumed_length]);
596
+ DLOG (INFO) << " unity phrase[" << consumed_length << " ]: "
597
+ << user_phrase_collector[consumed_length].size ();
598
+ }
595
599
}
596
600
if (resume_key > active_key &&
597
601
!boost::starts_with (resume_key, active_key))
@@ -615,12 +619,14 @@ TableTranslator::MakeSentence(const string& input, size_t start,
615
619
if (filter_by_charset) {
616
620
iter.AddFilter (CharsetFilter::FilterDictEntry);
617
621
}
618
- entries[consumed_length] = iter.Peek ();
619
- if (start_pos == 0 && !iter.exhausted ()) {
620
- // also provide words for manual composition
621
- collector[consumed_length] = std::move (iter);
622
- DLOG (INFO) << " table[" << consumed_length << " ]: "
623
- << collector[consumed_length].entry_count ();
622
+ if (!iter.exhausted ()) {
623
+ entries[consumed_length] = iter.Peek ();
624
+ if (start_pos == 0 ) {
625
+ // also provide words for manual composition
626
+ collector[consumed_length] = std::move (iter);
627
+ DLOG (INFO) << " table[" << consumed_length << " ]: "
628
+ << collector[consumed_length].entry_count ();
629
+ }
624
630
}
625
631
}
626
632
}
0 commit comments