Giter Club home page Giter Club logo

chinese-poetry-generation's Introduction

RNN-Based Poem Generator

A classical Chinese quatrain generator based on the RNN encoder-decoder framework.

Two 4-layer LSTM networks are used as encoder and decoder respectively. The encoder takes as input four keywords provided by a poem planner, and the decoder generates a quatrain character by character.

The original repository is here, where there are also a bunch of raw data files necessary to train the model. The raw data files were downloaded from the Internet, mostly from similar open source projects.

raw/
├── ming.all
├── pinyin.txt
├── qing.all
├── qsc_tab.txt
├── qss_tab.txt
├── qtais_tab.txt
├── qts_tab.txt
├── shixuehanying.txt
├── stopwords.txt
└── yuan.all

Dependencies

Python 2.7

TensorFlow 1.0

Jieba 0.38

Gensim 2.0.0

Training

To begin with, you should process the raw data to generate the training data:

python data_utils.py

The TextRank algorithm may take many hours to run. Instead, you could choose to stop it early by typing ctrl+c to interrupt the iterations, when the progress shown in the terminal has remained stationary for a long time.

Then, generate the word embedding data using gensim Word2Vec model:

python word2vec.py

Now, type the following command and wait for several hours:

python train.py

train

Run Tests

Start the user interaction program in a terminal once the training has finished:

python main.py

Type in an input sentence each time and the poem generator will create a poem for you.

main

chinese-poetry-generation's People

Contributors

devinz1993 avatar

Watchers

James Cloos avatar chunyue zhang avatar

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.