Code Monkey home page Code Monkey logo

phonetics's Introduction

Phonetics

This library currently provides three utilities for anyone working with the International Phonetic Alphabet:

  • An index of vowels and consonants with their linguistic features
  • A phonetic implementation of the Levenshtein distance calculation
  • English transcriptions for ~140,000 words from a variety of sources

Exploring vowels and consonants

Vowels are sounds with unimpeded airflow. We categorize them by the resonant frequencies they make in our vocal tract. When a person changes their tongue position or the rounding of their lips they change the way the sound reverberates in their skull.

The primary classification for vowels is the frequency of their lowest two resonant frequencies (called 'formants'). When we plot these on an x/y axis we get a vowel chart like this:

IPA vowel chart with 'b' words

Phonetic Levenshtein Distance

Using a typical 'edit distance' algorithm, we can calculate how many orthographic changes are needed to transform one string into another.

require 'damerau-levenshtein'
Levenshtein.distance('coorslight', 'budlight')
=> 5

The phonetics gem provides a (very fast) implementation of an edit distance algorithm that uses phonetic feature sets (for consonants) and precise formant measurements (for vowels) as weights. It's a modified version of Using Phonologically Weighted Levenshtein Distances for the Prediction of Microscopic Intelligibility by Lionel Fontan, Isabelle Ferrané, Jérôme Farinas, Julien Pinquier, Xavier Aumont, 2016

With this, the input strings must be valid IPA notation and the output is a phonetic-weighted distance:

require 'phonetics'
Phonetics::Levenshtein.distance('kuɹzlɑɪt', 'bədlɑɪt')
=> 1.388384

Contributing

Patches welcome, forks celebrated.

Everyone interacting in the Phonetics project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

License

The gem is available as open source under the wide-open terms of the MIT License.

phonetics's People

Contributors

jackdanger 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.