/** * \brief Returns the non-terminal mappings. For more details see getRuleMappings function * \param idx rule (sorted) identifier. * \param mappings On completion, non-terminal mappings from source to target will be stored here. */ void getMappings ( std::size_t idx, unordered_map<uint, uint> *mappings ) const { if ( isPhrase ( idx ) ) return; const std::vector<std::string> source = getRHSSplitSource ( idx ); const std::vector<std::string> translation = getRHSSplitTranslation ( idx ); getRuleMappings ( source, translation, mappings ); return; }
void PinyinEngine::hit(unsigned int index) { if(isPhrase()){ m_phrases_table.set_frequency(m_offset_freq_pairs[index].first, m_offset_freq_pairs[index].second+1); } else{ PinyinKey& key=m_key.get_key_by_index(0); uint32 freq=m_table.get_char_frequency(m_chars[index],key)+1; m_table.set_char_frequency(m_chars[index],freq,key); } }
unsigned int PinyinEngine::search(const char* pinyin) { m_key.set_key(pinyin); if(isPhrase()){ unsigned int count=m_phrases_table.find_phrases(m_offset_freq_pairs,m_key); m_phrases_table.get_phrases_by_offsets(m_offset_freq_pairs,m_phrases); return count; } else{ return m_table.find_chars(m_chars,m_key.get_key_by_index(0)); } }