New Features: Pronunciation & Syllables

Just added pronunciation and syllables to the API results.  They'll show up if you ask for the "everything" about a word, but not if you ask for word details like "synonyms".

The source for both new features is the Moby Project. According to Wikipedia:

As of 2007, it contains the largest free phonetic database, with 177,267 words and corresponding pronunciations"
The format for the files is a bit archaic, so it was interesting converting it into something that could be easily consumed via the Words API.  The pronunciation file doesn't use the International Phonetic Alphabet, which is what I wanted the API to have, but luckily Wikipedia has a mapping.

Please note that these pronunciations are in American English.  Event with that in mind, it was interesting to learn that there apparently isn't a definitive guide to how to pronounce a word.  During testing I found that some words would vary depending on which source I checked.

The format for the result will look something like the example below, if you requested "lexicographer":
{
  "results": [
    ...
  ],
  "syllables": {
    "count": 5,
    "list": [
      "lex",
      "i",
      "cog",
      "ra",
      "pher"
    ]
  },
  "pronunciation": {
    "all": ",lɛksə'kɑgrəfər"
  }
}

Watchout for the stress indicators in the pronunciation. The single quote indicates primary stress in a word, but if you're using JavaScript and aren't careful you may end up with an escape character in front of it.

1 comment: