Giter Site home page Giter Site logo

pun-gan's Introduction

Pun-GAN: Generative Adversarial Network for Pun Generation

This repo contains code for the following paper.

"Pun-GAN: Generative Adversarial Network for Pun Generation". Fuli Luo, Shunyao Li, Pengcheng Yang, Lei Li, Baobao Chang, Zhifang Sui and Xu SUN. EMNLP 2019.

In this paper, we focus on the task of generating a pun sentence given a pair of word senses. A major challenge for pun generation is the lack of large-scale pun corpus to guide the supervised learning. To remedy this, we propose an adversarial generative network for pun generation (Pun-GAN). It consists of a generator to produce pun sentences, and a discriminator to distinguish between the generated pun sentences and the real sentences with specific word senses. The output of the discriminator is then used as a reward to train the generator via reinforcement learning, encouraging it to produce pun sentences which can support two word senses simultaneously.

model

Quick Start

  1. Pretrain pun generation model, which can be divided into two parts: backward and forward.
# pretrain backward model
cd ./Pun_Generation/code

python -u nmt.py
--infer_batch_size=64
--out_dir=backward_model_path
--sampling_temperature=0
--pretrain=1 > output_backward.txt
# pretrain forward model
cd ./Pun_Generation_Forward/code

python -u nmt.py
--infer_batch_size=64
--out_dir=forward_model_path
--sampling_temperature=0
--pretrain=1 > output_forward.txt
  1. Pretain word sense disambiguation(WSD) model.
cd ./WSD/BiLSTM

python train.py
  1. Train Pun-GAN.
sh train.sh
  1. Inference.
sh inf.sh

Data Format

Sense pairs are required for pun generation. We prepare senses by keys in WordNet and store them in /Pun_Generation/data/samples.

rich%3:00:00::
rich%5:00:00:unwholesome:00
pump%1:06:01::
pump%2:32:00::
cleanly%4:02:00::
cleanly%4:02:02::
umbrella%1:06:00::
umbrella%1:04:01::
revealing%5:00:00:informative:00
reveal%2:39:00::
partial%5:00:00:inclined:02
partial%5:00:00:incomplete:00

Dependencies

python2.7
tensorflow_gpu==1.4.1
numpy==1.14.2
nltk==3.2.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.