Coder Social home page Coder Social logo

stevenlol / phonetic-similarity-vectors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aparrish/phonetic-similarity-vectors

0.0 3.0 0.0 25.2 MB

Source code to accompany my paper "Poetic sound similarity vectors using phonetic features"

License: MIT License

Jupyter Notebook 97.88% Python 2.12%

phonetic-similarity-vectors's Introduction

Poetic sound similarity vectors using phonetic features

This is the source code used to implement the algorithms, experiments and applications in my forthcoming paper, "Poetic sound similarity vectors using phonetic features." The source code is written in Python.

Dependencies

Almost everything should be covered in a standard Anaconda install, i.e.:

  • pandas
  • matplotlib
  • numpy
  • scikit-learn

You'll also need spaCy and Annoy for some of the applications, which you can install with pip or through conda-forge. For spaCy:

conda config --add channels conda-forge
conda install spacy
python -m spacy download en_core_web_md

For Annoy:

conda config --add channels conda-forge
conda install python-annoy

(Note: You don't need any of this stuff if you just want to play around with the pre-computed vectors! Though I definitely recommend using a fast nearest-neighbor search library like Annoy.)

Files

CMU Dict and pre-computed vectors

The file cmudict-0.7b-with-vitz-nonce contains the most current (as of this writing) version of the CMU Pronouncing Dictionary, edited to include the "nonce" words from Vitz and Winkler (1973).

The file cmudict-0.7b-simvecs contains pre-computed vectors for all of the words in cmudict-0.7b-with-vitz-nonce. This is probably the file you want if you just want to play around with the vectors! The vectors are formatted just like the CMU Pronouncing Dictionary (i.e., word in all caps, two spaces, then space-separated values per dimension).

Python source

Run generate.py to create your own set of vectors from a CMU Pronouncing Dictionary source file. Pass the dictionary as input and redirect the output to your desired file, e.g.:

PYTHONIOENCODING=latin1 python generate.py <cmudict-0.7b-with-vitz-nonce >cmudict-0.7b-simvecs

Note that you must specify latin1 encoding when running this script (unless your dictionary uses some other character set).

The similarity.py script is a quick script for checking your vectors. Pass the file with your similarity vectors as a command line argument, and the program will respond to every line of standard input with the most similar items from the embedding:

$ python similarity.py cmudict-0.7b-simvecs
loading...
done.
ELEPHANT
['ELEPHANT', "ELEPHANT'S", 'ELEPHANTS', "ELEPHANTS'", 'ENTOFFEN', 'UFFELMAN', 'UNRUFFLED', 'MUFFLE', "ENTOFFEN'S", 'KALAFUT']
AARDVARK
['AARDVARK', 'AARDVARKS', 'AARGH', 'ARGH', 'ARC', 'ARK', 'ARB', 'ARTCARVED', 'ALSGAARD', 'ARCHARD']
BADGER
['BADGER', 'BADER', 'BATHER(1)', 'BADGERED', 'BISER', "BADGER'S", 'BADGERS', 'BADDERS', 'MADAR', 'MADDER']
DOLPHIN
['DOLPHIN', 'DOLPHINS', "DOLPHINS'", 'DALFEN', 'GALVEN', 'DONELSON', 'GALVAN', 'JARVIS', 'GALVESTON', 'DARTH']

Hit ^D when you're done.

Finally, featurephone.py contains a few helper functions that help build the bigram analysis of the dictionary.

Jupyter notebooks

  • experiment.ipynb contains the code to run the experiments comparing the phonetic similarity reported by the embeddings in my paper to the similarity scores obtained from human subjects in Vitz and Winkler (1973).
  • some-applications.ipynb contains a number of playful and poetic experimental applications of the phonetic similarity embeddings (including sound analogies, averages, symbolism tinting, etc.)

Still forthcoming: An example of how to use the embeddings for longer stretches of text, as in the "random walk" example in the paper.

License

See LICENSE, which applies to everything in this repository except the copy of the CMU Pronouncing Dictionary, which is used under the terms of their license (included in the header of the file), and the data from Vitz and Winkler, for which I claim fair use.

phonetic-similarity-vectors's People

Contributors

aparrish avatar

Watchers

 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.