Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/duplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,18 @@ pub fn beam_search<D: Data<Elem = f32>, E: Data<Elem = usize>>(
}
}

let mut sequence = String::new();
let mut tokens: Vec<&str> = Vec::new();

if beam[0].node != ROOT_NODE {
for label in suffix_tree.iter_from_no_data(beam[0].node) {
sequence.push_str(&alphabet[label + 1]);
tokens.push(&alphabet[label + 1]);
}
}

Ok(sequence.chars().rev().collect())
tokens.reverse();
let sequence = tokens.concat();

Ok(sequence)
}

pub fn crf_beam_search<D: Data<Elem = f32>, E: Data<Elem = usize>>(
Expand Down
10 changes: 7 additions & 3 deletions src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,21 @@ pub fn beam_search<D: Data<Elem = f32>>(
}

let mut path = Vec::new();
let mut sequence = String::new();
let mut tokens: Vec<&str> = Vec::new();

if beam[0].node != ROOT_NODE {
for (label, &time) in suffix_tree.iter_from(beam[0].node) {
path.push(time);
sequence.push_str(&alphabet[label + 1]);
tokens.push(&alphabet[label + 1]);
}
}

path.reverse();
Ok((sequence.chars().rev().collect::<String>(), path))
tokens.reverse();

let sequence = tokens.concat();

Ok((sequence, path))
}

fn find_max(
Expand Down