libime
Public Types | Public Member Functions | List of all members
libime::HistoryBigram Class Reference

Public Types

using WordWithCode = std::pair< std::string, std::string >
 
using WordWithCodeView = std::pair< std::string_view, std::string_view >
 

Public Member Functions

 FCITX_DECLARE_VIRTUAL_DTOR_MOVE (HistoryBigram)
 
void load (std::istream &in)
 
void loadText (std::istream &in)
 
void save (std::ostream &out)
 
void dump (std::ostream &out)
 
void clear ()
 
void setUnknownPenalty (float unknown)
 Set unknown probability penatly. More...
 
float unknownPenalty () const
 
void setUseOnlyUnigram (bool useOnlyUnigram)
 
bool useOnlyUnigram () const
 
void forget (std::string_view word)
 
void forget (std::string_view word, std::string_view code)
 
bool isUnknown (std::string_view v) const
 
float score (const WordNode *prev, const WordNode *cur) const
 
float score (std::string_view prev, std::string_view cur) const
 
float scoreWithCode (WordWithCodeView prev, WordWithCodeView cur) const
 
float scoreWithCode (const WordNode *prev, const WordNode *cur, const ValidationCodeExtractor &extractor) const
 
void add (const SentenceResult &sentence)
 
void add (const std::vector< std::string > &sentence)
 
void addWithCode (const SentenceResult &sentence, const ValidationCodeExtractor &validationCodeExtractor)
 
void addWithCode (const std::vector< WordWithCode > &sentenceWithValidationCode)
 
void fillPredict (std::unordered_set< std::string > &words, const std::vector< std::string > &sentence, size_t maxSize) const
 Fill the prediction based on current sentence.
 
bool containsBigram (std::string_view prev, std::string_view cur) const
 
float unigramFrequency (WordWithCodeView word) const
 Query the weighted frequency of the unigram. More...
 
float bigramFrequency (WordWithCodeView prev, WordWithCodeView cur) const
 Query the weighted frequency of the bigram. More...
 
int32_t rawUnigramFrequency (WordWithCodeView word) const
 Query the raw frequency of the unigram. More...
 
int32_t rawBigramFrequency (WordWithCodeView prev, WordWithCodeView cur) const
 Query the raw frequency of the bigram. More...
 
void addWithContext (const std::vector< WordWithCode > &context, std::vector< WordWithCode > newSentence)
 

Detailed Description

Definition at line 30 of file historybigram.h.

Member Function Documentation

◆ bigramFrequency()

float libime::HistoryBigram::bigramFrequency ( WordWithCodeView  prev,
WordWithCodeView  cur 
) const

Query the weighted frequency of the bigram.

Since
1.1.14

Definition at line 735 of file historybigram.cpp.

◆ rawBigramFrequency()

int32_t libime::HistoryBigram::rawBigramFrequency ( WordWithCodeView  prev,
WordWithCodeView  cur 
) const

Query the raw frequency of the bigram.

Since
1.1.14

Definition at line 750 of file historybigram.cpp.

◆ rawUnigramFrequency()

int32_t libime::HistoryBigram::rawUnigramFrequency ( WordWithCodeView  word) const

Query the raw frequency of the unigram.

Since
1.1.14

Definition at line 741 of file historybigram.cpp.

◆ setUnknownPenalty()

void libime::HistoryBigram::setUnknownPenalty ( float  unknown)

Set unknown probability penatly.

Parameters
unknownis a log probability.

Definition at line 541 of file historybigram.cpp.

◆ unigramFrequency()

float libime::HistoryBigram::unigramFrequency ( WordWithCodeView  word) const

Query the weighted frequency of the unigram.

Since
1.1.14

Definition at line 730 of file historybigram.cpp.


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