69 std::vector<std::string> a;
70 std::vector<std::string> b;
113 std::vector<int32> hyp;
114 std::vector<int32> ref;
115 int32 ins, del, sub, total_cost;
129 KALDI_ASSERT(total_cost == 3 && ins == 0 && del == 2 && sub == 1);
133 KALDI_ASSERT(total_cost == 3 && ins == 2 && del == 0 && sub == 1);
144 KALDI_ASSERT(total_cost == 1 && ins == 0 && del == 0 && sub == 1);
147 for (; num < 1000; num ++) {
154 for (; index < hyp_len; index ++)
155 hyp[index] =
Rand()%4;
156 for (index = 0; index < ref_len; index ++)
157 ref[index] =
Rand()%4;
165 KALDI_ASSERT(del-ins == static_cast<int32>(ref.size() -hyp.size()));
173 std::vector<std::string> hyp;
174 std::vector<std::string> ref;
175 int32 ins, del, sub, total_cost;
189 KALDI_ASSERT(total_cost == 3 && ins == 0 && del == 2 && sub == 1);
193 KALDI_ASSERT(total_cost == 3 && ins == 2 && del == 0 && sub == 1);
204 KALDI_ASSERT(total_cost == 1 && ins == 0 && del == 0 && sub == 1);
207 for (; num < 1000; num ++) {
214 for (; index < hyp_len; index ++)
215 hyp[index] =
Rand()%4;
216 for (index = 0; index < ref_len; index ++)
217 ref[index] =
Rand()%4;
225 KALDI_ASSERT(del-ins == static_cast<int32>(ref.size() -hyp.size()));
232 for (
size_t i = 0;
i < 100;
i++) {
233 size_t a_sz =
Rand() % 5, b_sz =
Rand() % 5;
234 std::vector<int32> a, b;
235 for (
size_t j = 0;
j < a_sz;
j++) a.push_back(
Rand() % 10);
236 for (
size_t j = 0;
j < b_sz;
j++) b.push_back(
Rand() % 10);
238 std::vector<std::pair<int32, int32> > ans;
244 std::vector<int32> a2, b2;
245 for (
size_t i = 0;
i < ans.size();
i++) {
246 if (ans[
i].first != eps_sym) a2.push_back(ans[
i].first);
247 if (ans[
i].second != eps_sym) b2.push_back(ans[
i].second);
257 using namespace kaldi;
263 std::cout <<
"Test OK\n";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 LevenshteinAlignment(const std::vector< T > &a, const std::vector< T > &b, T eps_symbol, std::vector< std::pair< T, T > > *output)
void TestLevenshteinAlignment()
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
void TestEditDistance2String()
int32 LevenshteinEditDistance(const std::vector< T > &a, const std::vector< T > &b)
int Rand(struct RandomState *state)
#define KALDI_ASSERT(cond)
void TestEditDistanceString()