-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.lua
More file actions
32 lines (27 loc) · 680 Bytes
/
Copy pathutil.lua
File metadata and controls
32 lines (27 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local _M = {}
function _M:pad(sentence,padding_size)
local sent_with_padding = {}
local j = 1
for i = 1,padding_size do
sent_with_padding[j] = "<PAD>"
j = j + 1
end
for i = 1, #sentence do
sent_with_padding[j] = sentence[i]
j = j + 1
end
for i = 1,padding_size do
sent_with_padding[j] = "</PAD>"
j = j + 1
end
result = {}
for i = padding_size + 1, #sentence + padding_size do
local temp = {}
for k = -padding_size,padding_size do
table.insert(temp,sent_with_padding[i+k])
end
table.insert(result, temp)
end
return result
end
return _M