(self, s: str, bos: bool, eos: bool)
| 50 | ) |
| 51 | |
| 52 | def encode(self, s: str, bos: bool, eos: bool) -> List[int]: |
| 53 | assert type(s) is str |
| 54 | if self.tokenizer_type == "transformers": |
| 55 | t = self.tokenizer.encode(s, truncation=False, add_special_tokens=False) |
| 56 | else: |
| 57 | t = self.tokenizer.encode(s) |
| 58 | if bos: |
| 59 | t = [self.bos_id] + t |
| 60 | if eos: |
| 61 | t = t + [self.eos_id] |
| 62 | return t |
| 63 | |
| 64 | def encode_segment(self, s:str): |
| 65 | s = s.lstrip(' ') |
no outgoing calls
no test coverage detected