MCPcopy Create free account
hub / github.com/binbinjiang/CVT-SLR / DecoderState

Method DecoderState

ctcdecode/ctcdecode/src/ctc_beam_search_decoder.cpp:17–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15using FSTMATCH = fst::SortedMatcher<fst::StdVectorFst>;
16
17DecoderState::DecoderState(const std::vector<std::string> &vocabulary,
18 size_t beam_size,
19 double cutoff_prob,
20 size_t cutoff_top_n,
21 size_t blank_id,
22 int log_input,
23 Scorer *ext_scorer)
24 : abs_time_step(0)
25 , beam_size(beam_size)
26 , cutoff_prob(cutoff_prob)
27 , cutoff_top_n(cutoff_top_n)
28 , blank_id(blank_id)
29 , log_input(log_input)
30 , vocabulary(vocabulary)
31 , ext_scorer(ext_scorer)
32{
33 // assign space id
34 auto it = std::find(vocabulary.begin(), vocabulary.end(), " ");
35 // if no space in vocabulary
36 if (it == vocabulary.end()) {
37 space_id = -2;
38 } else {
39 space_id = std::distance(vocabulary.begin(), it);
40 }
41
42 // init prefixes' root
43 root.score = root.log_prob_b_prev = 0.0;
44 prefixes.push_back(&root);
45
46 if (ext_scorer != nullptr && !ext_scorer->is_character_based()) {
47 auto fst_dict = static_cast<fst::StdVectorFst *>(ext_scorer->dictionary);
48 fst::StdVectorFst *dict_ptr = fst_dict->Copy(true);
49 root.set_dictionary(dict_ptr);
50 auto matcher = std::make_shared<FSTMATCH>(*dict_ptr, fst::MATCH_INPUT);
51 root.set_matcher(matcher);
52 }
53}
54
55
56void

Calls 3

is_character_basedMethod · 0.80
set_dictionaryMethod · 0.80
set_matcherMethod · 0.80