文本输入转为Paddle输入的Tensor
(self, texts)
| 257 | return result |
| 258 | |
| 259 | def texts2tensor(self, texts): |
| 260 | """文本输入转为Paddle输入的Tensor""" |
| 261 | lod, data, words_length = [0], [], [] |
| 262 | for i, text in enumerate(texts): |
| 263 | |
| 264 | text_inds = self.dataset.word_to_ids(text) |
| 265 | data += text_inds |
| 266 | lod.append(len(text_inds) + lod[i]) |
| 267 | |
| 268 | tensor = self.to_tensor(data, lod) if len(data) != 0 else None |
| 269 | |
| 270 | return tensor, words_length |
| 271 | |
| 272 | def parse_result(self, lines, crf_decode, dataset, words_length): |
| 273 | """将SEG模型输出的Tensor转为明文""" |
nothing calls this directly
no test coverage detected