NLP For Poets

Pygmal

Pygmal is a Perl script I wrote for Dragomir Radev's Natural Language Processing class.

Pygmal is a program that generates variations on a sentence and ranks them according to their poetic meter. To do this, it uses the Charniak parser, the CMU Pronouncing Dictionary, and WordNet.

pygmal-0.0.2 is available under the Perl License.

pygmal takes the following arguments:

Pygmal returns some sentences (variations on the original) together with a number from 0 to 1. This number gives a measure of how well the sentence fits the meter.

Pygmal gets this number by attempting to fit the metric pattern against the meter of the line. It takes the starting position that gives the greatest proportion of fits. E.g., 0.5 means that for some starting position of the metric, half the syllables had the stress they should have. (There is one starting position for each syllable in the given pattern.)

Pygmal first parses a file with the Charniak parser. It then queries WordNet for synonyms of the nouns, verbs, adjectives, and adverbs. It takes the first N senses (ordered in WordNet by frequency). It next creates further variations by removing some of the syntactic components, removes the parsing, and ranks them according to how well they fit the specified meter.

BUGS:

HISTORY:

(12/22/2004) 0.0.2

TODO:

OLD VERSIONS:

pygmal-0.0.1

Valid HTML 4.01!