Python - Improve mappings on Encoding

This commit is contained in:
Anthony MOI
2020-04-14 22:03:12 -04:00
parent 3fb347b453
commit c5e22c14cb
2 changed files with 45 additions and 24 deletions

View File

@ -96,20 +96,24 @@ impl Encoding {
.collect()
}
fn char_to_word_offsets(&self, pos: usize) -> Option<Offsets> {
self.encoding.char_to_word_offsets(pos)
fn word_to_tokens(&self, word_index: u32) -> Option<(usize, usize)> {
self.encoding.word_to_tokens(word_index)
}
fn char_to_token_offsets(&self, pos: usize) -> Option<Offsets> {
self.encoding.char_to_token_offsets(pos)
fn word_to_chars(&self, word_index: u32) -> Option<Offsets> {
self.encoding.word_to_chars(word_index)
}
fn token_to_word_offsets(&self, index: usize) -> Option<Offsets> {
self.encoding.token_to_word_offsets(index)
fn token_to_chars(&self, token_index: usize) -> Option<Offsets> {
self.encoding.token_to_chars(token_index)
}
fn char_to_token(&self, pos: usize) -> Option<usize> {
self.encoding.char_to_token(pos)
fn token_to_word(&self, token_index: usize) -> Option<u32> {
self.encoding.token_to_word(token_index)
}
fn char_to_token(&self, char_pos: usize) -> Option<usize> {
self.encoding.char_to_token(char_pos)
}
#[args(kwargs = "**")]