Research Article

Enhancing Text Generation via Parse Tree Embedding

Algorithm 1

Parse tree embedding VAE.
(1)Initialize , , , with random weights , , ,
(2)M = number of Pre-train Parse tree encoder
(3)N = number of training iterations
(4)for each iteration do
(5) Sample a sequence from dataset
(6) Generate a Parse tree for based on by (1)
(7) Given , generate embedding vector based on (2)
(8) Compute the loss based on (3)
(9) Compute the gradient of and
(10) Update and parameters
(11)end for
(12)for each iteration do
(13) Sample a sequence from dataset
(14) Generate a parse tree for based on by (1)
(15) Given generate embedding vector based on (2)
(16) Given and , generate vector using
(17) Compute the loss based on (4)
(18) Computed the gradient of and
(19) Update and parameters
(20)end for