Skip to content

Instantly share code, notes, and snippets.

@aparrish
Created April 17, 2015 22:20
Show Gist options
  • Save aparrish/78c23721aeb0e8784615 to your computer and use it in GitHub Desktop.
Save aparrish/78c23721aeb0e8784615 to your computer and use it in GitHub Desktop.
words beginning with fleh, a node example for parsing the CMU pronouncing dictionary
var fs = require('fs');
var dictionary = fs.readFileSync("cmudict-0.7b", {encoding: 'utf8'});
var lines = dictionary.split("\n");
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (/^;/.test(line)) { continue; }
if (line.length == 0) { continue; }
var parts = line.split(" ");
var word = parts[0];
var phones = parts[1];
if (/^F L EH/.test(phones)) {
console.log(line);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment