GithubHelp home page GithubHelp logo

wvtm's Introduction

Word Vector Text Modulator

Based on a contribution to 2016 NaNoGenMo.

This repository contains the code and data necessary to modulate any text with word vectors derived from over 1,300 nineteenth-century French texts.

The following command will produce an interesting variation on the description of Charles Bovary's hat in the first chapter of Madame Bovary:

./modulateText.py maladroit adroit FlaubertBovary01.txt

Prerequisites

A quick explanation of what's under the hood

Vector space models of vocabularies offer promising techniques for exploring the semantic relationships between words. Using gensim to build such a model, the code presented here takes a pair of words (e.g. "homme" and "femme") and a given text as parameters to generate a new text based on computationally derived analogies. Each word in the original text is replaced by a word that is "most similar" to it according to the word pair. For instance, if "roi" is a word in the original text, it would be replaced like this:

>>> model.most_similar(positive=['femme', 'roi'], negative=['homme'], topn=1)
[(u'reine', 0.8085041046142578)]

The vector space model is able to complete the analogy: "reine" is to "femme" as "roi" is to "homme". Handling verb conjugations and adjective agreements computationally in French is tricky but the code produces a mostly readable text needing occasional grammatical polishing (a good exercise for students). The code can modulate any text against any pair of words. The quality of the result depends on the corpus for the vector space model and the word pair chosen by the user.

wvtm's People

Contributors

mbwolff avatar

Watchers

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