2019-11-20 19:25:22 +08:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
from random import random
|
|
|
|
|
|
|
|
n_vocab = 0xffff
|
|
|
|
|
|
|
|
_eos = 1
|
|
|
|
_pad = 0
|
|
|
|
_tagger = None
|
|
|
|
|
|
|
|
|
|
|
|
def text_to_sequence(text, p=0.0):
|
|
|
|
return [ord(c) for c in text] + [_eos] # EOS
|
|
|
|
|
2020-02-26 21:03:51 +08:00
|
|
|
|
2019-11-20 19:25:22 +08:00
|
|
|
def sequence_to_text(seq):
|
|
|
|
return "".join(chr(n) for n in seq)
|