Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 25, 2020
1 parent 46cbe64 commit fcfba86
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 137 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
*.log
node_modules/
yarn.lock
1 change: 0 additions & 1 deletion .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- lts/dubnium
- node
76 changes: 0 additions & 76 deletions README.md

This file was deleted.

17 changes: 7 additions & 10 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
const fs = require('fs')
var fs = require('fs')
var words = {}

fs.readFileSync('cmudict-0.7b.txt', 'utf8')
String(fs.readFileSync('cmudict-0.7b.txt'))
.split('\n')
// .slice(0,150)
.filter(function (line) {
.filter(function(line) {
return line.charAt(0).match(/[a-z]/i)
})
.forEach(function (line) {
// var [a,b] = line.split(" ")
.forEach(function(line) {
var parts = line.split(' ')

if (parts.length === 2) {
var word = parts[0].toLowerCase()
var transcription = parts[1]
words[word] = transcription
words[parts[0].toLowerCase()] = parts[1]
}
})

process.stdout.write(JSON.stringify(words, null, 2))
fs.writeFileSync('index.json', JSON.stringify(words, null, 2) + '\n')
9 changes: 0 additions & 9 deletions example.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
Expand Up @@ -133778,4 +133778,4 @@
"zyuganov's": "Z Y UW1 G AA0 N AA0 V Z",
"zyuganov's(1)": "Z UW1 G AA0 N AA0 V Z",
"zywicki": "Z IH0 W IH1 K IY0"
}
}
15 changes: 15 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2015 Zeke Sikelianos <zeke@sikelianos.com>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
60 changes: 44 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"name": "cmu-pronouncing-dictionary",
"version": "1.0.3",
"description": "All the 134,000+ words in the CMU pronouncing dictionary as a simple JSON object",
"main": "index.json",
"scripts": {
"test": "standard --format && mocha",
"build": "npm test && node build.js > index.json"
},
"repository": "zeke/cmu-pronouncing-dictionary",
"description": "The 134,000+ words and their pronunciations in the CMU pronouncing dictionary",
"license": "ISC",
"keywords": [
"english",
"language",
Expand All @@ -19,15 +14,48 @@
"dictionary",
"rhyme"
],
"author": "zeke",
"license": "ISC",
"bugs": {
"url": "https://github.com/zeke/cmu-pronouncing-dictionary/issues"
},
"homepage": "https://github.com/zeke/cmu-pronouncing-dictionary",
"repository": "words/cmu-pronouncing-dictionary",
"bugs": "https://github.com/words/cmu-pronouncing-dictionary/issues",
"author": "Zeke Sikelianos <zeke@sikelianos.com> (http://zeke.sikelianos.com)",
"contributors": [
"Zeke Sikelianos <zeke@sikelianos.com> (http://zeke.sikelianos.com)",
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"main": "index.json",
"files": [
"index.json"
],
"dependencies": {},
"devDependencies": {
"code": "^1.4.0",
"mocha": "^2.2.5",
"standard": "^4.0.1"
"bail": "^1.0.0",
"concat-stream": "^2.0.0",
"prettier": "^1.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"xo": "^0.25.0"
},
"scripts": {
"generate": "node build",
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"test-api": "node test",
"test": "npm run format && npm run test-api"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"esnext": false
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
]
}
}
87 changes: 87 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# `cmu-pronouncing-dictionary`

[![Build][build-badge]][build]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

The 134,000+ words and their pronunciations in the CMU pronouncing dictionary.

> The CMU Pronouncing Dictionary (also known as cmudict) is a public domain
> pronouncing dictionary created by Carnegie Mellon University (CMU).
> It defines a mapping from English words to their North American
> pronunciations, and is commonly used in speech processing applications.
## Install

[npm][]:

```sh
npm install cmu-pronouncing-dictionary
```

## Use

```js
var cmu = require('cmu-pronouncing-dictionary')

console.log(cmu)
```

Yields:

```js
{
a: 'AH0',
'a(1)': 'EY1',
"a's": 'EY1 Z',
'a.': 'EY1',
"a.'s": 'EY1 Z',
'a.s': 'EY1 Z',
a42128: 'EY1 F AO1 R T UW1 W AH1 N T UW1 EY1 T',
aa: 'EY2 EY1',
aaa: 'T R IH2 P AH0 L EY1',
aaberg: 'AA1 B ER0 G',
aachen: 'AA1 K AH0 N',
aachener: 'AA1 K AH0 N ER0',
aah: 'AA1',
aaker: 'AA1 K ER0',
aaliyah: 'AA2 L IY1 AA2',
aalseth: 'AA1 L S EH0 TH',
aamodt: 'AA1 M AH0 T',
aancor: 'AA1 N K AO2 R',
// …and many more
}
```

## API

### `cmuPronouncingDictionary`

`Object.<string>` — Map of English words to [ARPABET][] phonetic transcription
codes.

## License

[ISC][license] © [Zeke Sikelianos][author]

<!-- Definition -->

[build-badge]: https://img.shields.io/travis/words/cmu-pronouncing-dictionary.svg

[build]: https://travis-ci.org/words/cmu-pronouncing-dictionary

[downloads-badge]: https://img.shields.io/npm/dm/cmu-pronouncing-dictionary.svg

[downloads]: https://www.npmjs.com/package/cmu-pronouncing-dictionary

[size-badge]: https://img.shields.io/bundlephobia/minzip/cmu-pronouncing-dictionary.svg

[size]: https://bundlephobia.com/result?p=cmu-pronouncing-dictionary

[npm]: https://docs.npmjs.com/cli/install

[license]: license

[author]: http://zeke.sikelianos.com

[arpabet]: https://en.wikipedia.org/wiki/ARPABET
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var test = require('tape')
var cmu = require('.')

test('cmu-pronouncing-dictionary', function(t) {
t.ok(typeof cmu === 'object', 'should be an object')

t.ok(typeof cmu.fun === 'string', 'there should be a fun,')
t.ok(typeof cmu.perilous === 'string', 'perilous,')
t.ok(typeof cmu.monkey === 'string', 'monkey.')
t.equal(cmu.bought, 'B AA1 T', 'should have arpabet transcriptions')
t.ok(Object.keys(cmu).length > 130000, 'should have loads of words')

t.end()
})
24 changes: 0 additions & 24 deletions test/index.js

This file was deleted.

0 comments on commit fcfba86

Please sign in to comment.