Skip to content
Browse files

Add char_quantize for AAPD (#173)

  • Loading branch information...
Ashutosh-Adhikari authored and Impavidity committed Jan 29, 2019
1 parent aec0826 commit 84225d208c15b41e07616f5c681e258fe309846b
Showing with 7 additions and 0 deletions.
  1. +7 −0 datasets/
@@ -9,6 +9,13 @@

from datasets.reuters import clean_string, clean_string_fl, split_sents

def char_quantize(string, max_length=1000):
identity = np.identity(len(AAPDCharQuantized.ALPHABET))
quantized_string = np.array([identity[AAPDCharQuantized.ALPHABET[char]] for char in list(string.lower()) if char in AAPDCharQuantized.ALPHABET], dtype=np.float32)
if len(quantized_string) > max_length:
return quantized_string[:max_length]
return np.concatenate((quantized_string, np.zeros((max_length - len(quantized_string), len(AAPDCharQuantized.ALPHABET)), dtype=np.float32)))

def process_labels(string):

0 comments on commit 84225d2

Please sign in to comment.
You can’t perform that action at this time.