pfeyz / mw-ipa-transcriber

Merriam-Webster IPA Transcriber

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Merriam-Webster IPA Transcriber

A simple script for querying Merriam-Webster's Dictionary API for IPA transcriptions. Also includes part-of-speech functionality. To use it you'll need to get API keys from Merriam-Webster's Developer Center and populate the KEYS dictionary with them. The script is written to work with the collegiate and learner's dictionary, but you should know that it looks like the collegiate dictionary uses its own non-ipa pronunciation notation.

Use of the Merriam Webster Dictionary API is subject to their terms of service.

>>> from mwipa import get_ipa
>>> for ipa in get_ipa("tomato"):
...     print ipa
...
təˈmeɪtoʊ
təˈmɑ:təʊ

The script can also be used as a command line program for batch transcription.

$ python mwipa.py -h
usage: mwipa.py [-h] (-i | -p) infile outfile

Query merriam-webster.com for IPA or POS data

positional arguments:
  infile      Text file without punctuation to use as input
  outfile     Output file to write tab-seperated data to

optional arguments:
  -h, --help  show this help message and exit
  -i, --ipa   Retrive IPA translations
  -p, --pos   Retrieve POS information

For example,

$ python mwipa.py -i in.txt out.csv
1/2
2/2

will result in the following "out.csv" given this "in.txt". Words unable to be transcribed are indicated like <<this>> and words with alternative transcriptions are [ listed | like | this ] . (Example text excerpts taken from Wikipedia's list of common misconceptions which is a great read if you're into correcting people constantly.)

<in.txt>
lemmings do not engage in mass suicidal dives off cliffs when migrating
this misconception was popularized by the Disney film White wilderness
<out.csv>
lemmings do not engage in mass suicidal dives off cliffs when migrating       <<lemmings>> [ ˈdu: | ˈdoʊ ] ˈnɑ:t ɪnˈgeɪʤ [ ˈɪn | ən | ˈɪn | ˈɪn | ˈɪn ] ˈmæs ˌsu:wəˈsaɪdl̟ <<dives>> ˈɑ:f <<cliffs>> ˈwɛn <<migrating>>
this misconception was popularized by the Disney film White wilderness        [ ˈðɪs | ðəs | ˈðɪs ] ˌmɪskənˈsɛpʃən <<was>> <<popularized>> [ ˈbaɪ | bə | ˈbaɪ ] [ ðə | ði | ˈði: ] <<Disney>> ˈfɪlm <<White>> ˈwɪldɚnəs

As you can see, inflected forms aren't currently recognized.

About

Merriam-Webster IPA Transcriber


Languages

Language:Python 100.0%