Skip to content

Commit e714450

Browse files
committed
Comment out broken grammar_mask.
Unfortunately, the basic implementation of reference counting introduced in the previous commit means that we can't mutate the value pointed to. The solution might be to implement to DerefMut trait for DFAState. I'm still not totally happy with the API here, but I'm beginning to accept that it must be so. It's very Java to have the factory class (DFABuilder) for the actual class (DFAState). I'll have to think of a more Rustacean way to implement this abstraction.
1 parent 6ae7636 commit e714450

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,24 @@ impl Masker {
155155
store
156156
}
157157

158-
/// Implement algorithm 2 from the paper.
159-
fn grammar_mask(
160-
&mut self,
161-
accept_sequences: Vec<Vec<&str>>,
162-
remainder: &str,
163-
model_vocabulary: Vec<&str>,
164-
) -> Vec<bool> {
165-
let mut res_mask: Vec<bool> = vec![false; model_vocabulary.len()];
166-
for accept_sequence in accept_sequences {
167-
let mut dfa = self.dfa_builder.build_dfa(accept_sequence[0]);
168-
dfa.advance(remainder);
169-
let mask = self.dfa_mask(&dfa, &accept_sequence[1..].to_vec(), &model_vocabulary);
170-
for (i, (cur, new)) in zip(res_mask.clone(), mask.clone()).enumerate() {
171-
res_mask[i] = cur | new;
172-
}
173-
}
174-
res_mask
175-
}
158+
// /// Implement algorithm 2 from the paper.
159+
// fn grammar_mask(
160+
// &mut self,
161+
// accept_sequences: Vec<Vec<&str>>,
162+
// remainder: &str,
163+
// model_vocabulary: Vec<&str>,
164+
// ) -> Vec<bool> {
165+
// let mut res_mask: Vec<bool> = vec![false; model_vocabulary.len()];
166+
// for accept_sequence in accept_sequences {
167+
// let dfa = self.dfa_builder.build_dfa(accept_sequence[0]);
168+
// dfa.advance(remainder);
169+
// let mask = self.dfa_mask(&dfa, &accept_sequence[1..].to_vec(), &model_vocabulary);
170+
// for (i, (cur, new)) in zip(res_mask.clone(), mask.clone()).enumerate() {
171+
// res_mask[i] = cur | new;
172+
// }
173+
// }
174+
// res_mask
175+
// }
176176

177177
}
178178

0 commit comments

Comments
 (0)