KwsAlignment Class Reference

#include <kws-scoring.h>

Collaboration diagram for KwsAlignment:

Public Types

typedef std::vector< AlignedTermsPairAlignedTerms
 

Public Member Functions

void WriteCsv (std::iostream &os, const float frames_per_sec)
 
AlignedTerms::const_iterator begin () const
 
AlignedTerms::const_iterator end () const
 
int size () const
 

Private Member Functions

void Add (const AlignedTermsPair &next)
 

Private Attributes

AlignedTerms alignment_
 

Friends

class KwsTermsAligner
 

Detailed Description

Definition at line 97 of file kws-scoring.h.

Member Typedef Documentation

◆ AlignedTerms

typedef std::vector<AlignedTermsPair> AlignedTerms

Definition at line 104 of file kws-scoring.h.

Member Function Documentation

◆ Add()

void Add ( const AlignedTermsPair next)
inlineprivate

Definition at line 121 of file kws-scoring.h.

Referenced by KwsTermsAligner::AlignTerms(), and KwsTermsAligner::FillUnmatchedRefs().

121  {
122  alignment_.push_back(next);
123  }
AlignedTerms alignment_
Definition: kws-scoring.h:119

◆ begin()

AlignedTerms::const_iterator begin ( ) const
inline

Definition at line 106 of file kws-scoring.h.

Referenced by TwvMetrics::AddAlignment().

106 {return alignment_.begin();}
AlignedTerms alignment_
Definition: kws-scoring.h:119

◆ end()

AlignedTerms::const_iterator end ( ) const
inline

Definition at line 107 of file kws-scoring.h.

Referenced by TwvMetrics::AddAlignment().

107 {return alignment_.end();}
AlignedTerms alignment_
Definition: kws-scoring.h:119

◆ size()

int size ( ) const
inline

Definition at line 108 of file kws-scoring.h.

Referenced by KwsTermsAligner::AlignTerms().

108 {return alignment_.size(); }
AlignedTerms alignment_
Definition: kws-scoring.h:119

◆ WriteCsv()

void WriteCsv ( std::iostream &  os,
const float  frames_per_sec 
)

Definition at line 244 of file kws-scoring.cc.

Referenced by main().

244  {
245  AlignedTerms::const_iterator it = begin();
246  os << "language,file,channel,termid,term,ref_bt,ref_et,"
247  << "sys_bt,sys_et,sys_score,sys_decision,alignment\n";
248 
249  while ( it != end() ) {
250  int file = it->ref.valid() ? it->ref.utt_id() : it->hyp.utt_id();
251  std::string termid = it->ref.valid() ? it->ref.kw_id() : it->hyp.kw_id();
252  std::string term = termid;
253  std::string lang = "";
254  int channel = 1;
255 
256  os << lang << ","
257  << file << ","
258  << channel << ","
259  << termid << ","
260  << term << ",";
261 
262  if (it->ref.valid()) {
263  os << it->ref.start_time() / static_cast<float>(frames_per_sec) << ","
264  << it->ref.end_time() / static_cast<float>(frames_per_sec) << ",";
265  } else {
266  os << "," << ",";
267  }
268  if (it->hyp.valid()) {
269  os << it->hyp.start_time() / static_cast<float>(frames_per_sec) << ","
270  << it->hyp.end_time() / static_cast<float>(frames_per_sec) << ","
271  << it->hyp.score() << ","
272  << (it->hyp.score() >= 0.5 ? "YES" : "NO") << ",";
273  } else {
274  os << "," << "," << "," << ",";
275  }
276 
277  if (it->ref.valid() && it->hyp.valid()) {
278  os << (it->hyp.score() >= 0.5 ? "CORR" : "MISS");
279  } else if (it->ref.valid()) {
280  os << "MISS";
281  } else if (it->hyp.valid()) {
282  os << (it->hyp.score() >= 0.5 ? "FA" : "CORR!DET");
283  }
284  os << std::endl;
285  it++;
286  }
287 }
AlignedTerms::const_iterator begin() const
Definition: kws-scoring.h:106
AlignedTerms::const_iterator end() const
Definition: kws-scoring.h:107

Friends And Related Function Documentation

◆ KwsTermsAligner

friend class KwsTermsAligner
friend

Definition at line 98 of file kws-scoring.h.

Member Data Documentation

◆ alignment_

AlignedTerms alignment_
private

Definition at line 119 of file kws-scoring.h.


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