MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / preprocess

Function preprocess

samples/python/engine_refit_onnx_bidaf/data_processing.py:25–37  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

23
24
25def preprocess(text):
26 try:
27 nltk.data.find("tokenizers/punkt")
28 except LookupError:
29 nltk.download("punkt")
30 tokens = word_tokenize(text)
31 # split into lower-case word tokens, in numpy array with shape of (seq, 1)
32 words = np.asarray([w.lower() for w in tokens]).reshape(-1, 1)
33 # split words into chars, in numpy array with shape of (seq, 1, 1, 16)
34 chars = [[c for c in t][:16] for t in tokens]
35 chars = [cs + [""] * (16 - len(cs)) for cs in chars]
36 chars = np.asarray(chars).reshape(-1, 1, 1, 16)
37 return words, chars
38
39
40def get_map_func(filepath):

Callers 5

mainFunction · 0.90
load_test_caseFunction · 0.90
mainFunction · 0.90
get_inputsFunction · 0.85
rn50_preprocessFunction · 0.85

Calls 1

findMethod · 0.45

Tested by

no test coverage detected