libime
Public Member Functions | Protected Member Functions | List of all members
libime::PinyinContext Class Reference
Inheritance diagram for libime::PinyinContext:
Inheritance graph
[legend]
Collaboration diagram for libime::PinyinContext:
Collaboration graph
[legend]

Public Member Functions

 PinyinContext (PinyinIME *ime)
 
void setUseShuangpin (bool sp)
 
bool useShuangpin () const
 
void erase (size_t from, size_t to) override
 
void setCursor (size_t pos) override
 
int maxSentenceLength () const
 
void setMaxSentenceLength (int length)
 
const std::vector< SentenceResult > & candidates () const
 
const std::unordered_set< std::string > & candidateSet () const
 Return the set of candidates, useful for deduplication. More...
 
const std::vector< SentenceResult > & candidatesToCursor () const
 
const std::unordered_set< std::string > & candidatesToCursorSet () const
 Return the set of candidates to current cursor. More...
 
void select (size_t idx)
 
void selectCandidatesToCursor (size_t idx)
 
void cancel ()
 
bool cancelTill (size_t pos)
 
void selectCustom (size_t inputLength, std::string_view segment, std::string_view encodedPinyin="")
 Create a custom selection. More...
 
bool selected () const
 Whether the input is fully selected.
 
std::string sentence () const
 The sentence for this context, can be used as preedit.
 
std::string preedit (PinyinPreeditMode mode) const
 
std::pair< std::string, size_t > preeditWithCursor (PinyinPreeditMode mode) const
 Mixed preedit (selected hanzi + pinyin).
 
std::string preedit () const
 
std::pair< std::string, size_t > preeditWithCursor () const
 Mixed preedit (selected hanzi + pinyin).
 
std::string selectedSentence () const
 Selected hanzi.
 
size_t selectedLength () const
 Selected pinyin length.
 
std::vector< std::string > selectedWords () const
 Selected hanzi segments.
 
std::vector< HistoryBigram::WordWithCode > selectedWordsWithPinyin () const
 Selected hanzi with encoded pinyin.
 
std::string selectedFullPinyin () const
 Get the full pinyin string of the selected part.
 
std::string candidateFullPinyin (size_t i) const
 Get the full pinyin string of certain candidate.
 
std::string candidateFullPinyin (const SentenceResult &candidate) const
 Get the full pinyin string of certain candidate.
 
void learn ()
 Add the selected part to history if selected() == true.
 
int pinyinBeforeCursor () const
 Return the position of last pinyin. More...
 
int pinyinAfterCursor () const
 Return the position of last pinyin. More...
 
PinyinIMEime () const
 
State state () const
 Opaque language model state.
 
void setContextWords (const std::vector< std::string > &contextWords)
 Set context words for better prediction. More...
 
void clearContextWords ()
 Clear context words. More...
 
void appendContextWords (const std::vector< std::string > &contextWords)
 Append context words for better prediction. More...
 
std::vector< std::string > contextWords () const
 Get context words for better prediction. More...
 
void setContextWordsWithPinyin (const std::vector< HistoryBigram::WordWithCode > &contextWordsWithPinyin)
 Set context words with pinyin for better prediction. More...
 
void appendContextWordsWithPinyin (const std::vector< HistoryBigram::WordWithCode > &contextWordsWithPinyin)
 Append context words with pinyin for better prediction. More...
 
std::vector< HistoryBigram::WordWithCode > contextWordsWithPinyin () const
 Get context words with pinyin for better prediction. More...
 
- Public Member Functions inherited from libime::InputBuffer
bool type (std::string_view s)
 
std::string_view at (size_t i) const
 
std::string_view operator[] (size_t i) const
 
iterator begin ()
 
iterator end ()
 

Protected Member Functions

bool typeImpl (const char *s, size_t length) override
 

Detailed Description

Definition at line 29 of file pinyincontext.h.

Member Function Documentation

◆ appendContextWords()

void libime::PinyinContext::appendContextWords ( const std::vector< std::string > &  contextWords)

Append context words for better prediction.

Parameters
contextWordsThe context words.
Since
1.1.13

Definition at line 1053 of file pinyincontext.cpp.

◆ appendContextWordsWithPinyin()

void libime::PinyinContext::appendContextWordsWithPinyin ( const std::vector< HistoryBigram::WordWithCode > &  contextWordsWithPinyin)

Append context words with pinyin for better prediction.

Parameters
contextWordsWithPinyinThe context words with pinyin.
Since
1.1.14

Definition at line 1086 of file pinyincontext.cpp.

◆ candidateSet()

const std::unordered_set< std::string > & libime::PinyinContext::candidateSet ( ) const

Return the set of candidates, useful for deduplication.

See also
PinyinContext::candidates
Since
1.0.18

Definition at line 507 of file pinyincontext.cpp.

◆ candidatesToCursorSet()

const std::unordered_set< std::string > & libime::PinyinContext::candidatesToCursorSet ( ) const

Return the set of candidates to current cursor.

See also
PinyinContext::candidatesToCursor
Since
1.0.18

Definition at line 522 of file pinyincontext.cpp.

◆ clearContextWords()

void libime::PinyinContext::clearContextWords ( )

Clear context words.

Since
1.1.13

Definition at line 1048 of file pinyincontext.cpp.

◆ contextWords()

std::vector< std::string > libime::PinyinContext::contextWords ( ) const

Get context words for better prediction.

Returns
current context words
Since
1.1.13

Definition at line 1069 of file pinyincontext.cpp.

◆ contextWordsWithPinyin()

std::vector< HistoryBigram::WordWithCode > libime::PinyinContext::contextWordsWithPinyin ( ) const

Get context words with pinyin for better prediction.

Returns
current context words with pinyin
Since
1.1.14

Definition at line 1103 of file pinyincontext.cpp.

◆ pinyinAfterCursor()

int libime::PinyinContext::pinyinAfterCursor ( ) const

Return the position of last pinyin.

E.g. 你h|ao, return the offset after h.

Definition at line 479 of file pinyincontext.cpp.

◆ pinyinBeforeCursor()

int libime::PinyinContext::pinyinBeforeCursor ( ) const

Return the position of last pinyin.

E.g. 你h|ao, return the offset before h.

Definition at line 455 of file pinyincontext.cpp.

◆ selectCustom()

void libime::PinyinContext::selectCustom ( size_t  inputLength,
std::string_view  segment,
std::string_view  encodedPinyin = "" 
)

Create a custom selection.

This allows Engine to do make a custom selection that is not pinyin.

Parameters
inputLengththe length of characters to match in the input
segmentsegment
encodedPinyinwhether this segment has a pinyin
Since
1.1.7

Definition at line 545 of file pinyincontext.cpp.

◆ setContextWords()

void libime::PinyinContext::setContextWords ( const std::vector< std::string > &  contextWords)

Set context words for better prediction.

Parameters
contextWordsThe context words.
Since
1.1.13

Definition at line 1041 of file pinyincontext.cpp.

◆ setContextWordsWithPinyin()

void libime::PinyinContext::setContextWordsWithPinyin ( const std::vector< HistoryBigram::WordWithCode > &  contextWordsWithPinyin)

Set context words with pinyin for better prediction.

Parameters
contextWordsWithPinyinThe context words with encoded pinyin.
Since
1.1.14

Definition at line 1079 of file pinyincontext.cpp.


The documentation for this class was generated from the following files: