GithubHelp home page GithubHelp logo

project's Introduction

AI Project - Text Generation

The project is about investigating how the use of different n-gram affects the performance of a language model for different languages. In this particular project models for English, Swedish and Greek will be evaluated. The SRI Language Modeling Toolkit is used to create the language models, and the models are trained on corpuses made of posts/comments from reddit.

Files included in this directory are:

  • comments.py - retrieves posts from reddit and writes the data to a file
  • cleaner.py - removes unwanted sentences from the corpus files, for example sentences in the wrong language
  • Files for the language models and n-grams
  • One corpus for each language

###Prerequisites

  • Python 2.7
  • Python Reddit API Wrapper
  • SRI Language Modeling Toolkit

Create corpus

Run python comments.py subreddit > corpus_file.txt

subreddit is the subreddit you want to retrieve posts from and corpus_file is the file you want to save the data to. comments.py is configured to retrieve the top 100 posts from the subreddit, but this can be changed.

Clean the corpus

Run python cleaner.py

Requires that you have files called corpus_el.txt, corpus_en.txt and corpus_sv.txt. Cleaning will create 3 files for each language, clean_lang, clean_lang_tokenized and dirty_lang. clean_lang removes lines that appear to be written in another language, and removes some cruft. clean_lang_tokenized splits word punctuation into their own words, but is otherwise the same as clean_lang.

Train the model

Run ngram-count -text clean_lang_tokenized -lm model_lang -order n -write ngram_lang

You will generally only be using model_lang, but ngram_lang is good to look at for understanding.

Generate posts

Run ngram -order n -gen k -lm model_lang

n is the order of the markov chain. k is the number of sentences you want to generate.

project's People

Contributors

limbero avatar bill-kalog avatar rhellgren avatar annicaal avatar

Watchers

 avatar James Cloos avatar  avatar  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.