Skip to content
Snippets Groups Projects
Commit c7e86f51 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

proper check of indices in getter and setter of frequencies in HMMColumn

parent 8b484de7
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,22 @@ Real HMMColumn::GetEntropy() const { ...@@ -60,6 +60,22 @@ Real HMMColumn::GetEntropy() const {
return entropy; return entropy;
} }
Real HMMColumn::GetFreq(char ch) const{
int idx = this->GetIndex(ch);
if(idx == -1){
throw std::runtime_error("Invalid One Letter Code observed when getting frequency in HMMColumn!");
}
return freq_[idx];
}
void HMMColumn::SetFreq(char ch, Real freq){
int idx = this->GetIndex(ch);
if(idx == -1){
throw std::runtime_error("Invalid One Letter Code observed when setting frequency in HMMColumn!");
}
freq_[idx] = freq;
}
HMMPtr HMM::Load(const std::string& filename) { HMMPtr HMM::Load(const std::string& filename) {
HMMPtr hmm(new HMM); HMMPtr hmm(new HMM);
boost::iostreams::filtering_stream<boost::iostreams::input> in; boost::iostreams::filtering_stream<boost::iostreams::input> in;
......
...@@ -59,13 +59,9 @@ class HMMColumn { ...@@ -59,13 +59,9 @@ class HMMColumn {
Real GetNEffDel() const { return n_eff_del_; } Real GetNEffDel() const { return n_eff_del_; }
Real GetFreq(char ch) const { Real GetFreq(char ch) const;
return freq_[this->GetIndex(ch)];
}
void SetFreq(char ch, Real freq) { void SetFreq(char ch, Real freq);
freq_[this->GetIndex(ch)]=freq;
}
bool operator==(const HMMColumn& rhs) const { bool operator==(const HMMColumn& rhs) const {
return !memcmp(freq_, rhs.freq_, sizeof(freq_)) && return !memcmp(freq_, rhs.freq_, sizeof(freq_)) &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment