Skip to content

Commit

Permalink
Merge pull request lexi-sh#12 from Roughsketch/ngram
Browse files Browse the repository at this point in the history
Fix right padding on padded ngrams
  • Loading branch information
Chris Jones authored Aug 16, 2017
2 parents 062a948 + 1d96e47 commit 941c928
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ngram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ impl<'a> NGram<'a> {

//right-padding
if !self.pad.is_empty() {
for i in 1..self.n {
let num_blanks = i;
for num_blanks in 1..self.n {
let num_tokens = self.n - num_blanks;
let last_entry = tokenized_sequence.len();
let mut tc = Vec::new();
tc.extend_from_slice(&tokenized_sequence[(last_entry - num_blanks) .. last_entry]);
tc.extend_from_slice(&tokenized_sequence[(last_entry - num_tokens) .. last_entry]);
for _ in 0..num_blanks {
tc.push(self.pad);
}
Expand Down

0 comments on commit 941c928

Please sign in to comment.