# mishear-phrase

> This module is like `mishear`, but it works on a phrase instead of just a word.

Latest version **1.2.1** (published 2015-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install mishear-phrase
pnpm add mishear-phrase
yarn add mishear-phrase
bun add mishear-phrase
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2015-10-11 |
| First published | 2015-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jim Kang |
| Maintainers | jimkang |

## Links

- npm: https://www.npmjs.com/package/mishear-phrase
- Repository: https://github.com/jimkang/mishear-phrase
- Issues: https://github.com/jimkang/mishear-phrase/issues
- npm.io page: https://npm.io/package/mishear-phrase

## Dependencies (7)

- [async](https://npm.io/package/async.md) ^1.4.2
- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [mishear](https://npm.io/package/mishear.md) ^2.1.2
- [capitalize](https://npm.io/package/capitalize.md) ^1.0.0
- [queue-async](https://npm.io/package/queue-async.md) ^1.0.7
- [call-next-tick](https://npm.io/package/call-next-tick.md) ^1.1.2
- [profile-capitalization](https://npm.io/package/profile-capitalization.md) ^1.0.0

## Recent versions

- 1.2.1 (latest) — 2015-10-11
- 1.2.0 — 2015-10-05
- 1.1.2 — 2015-10-05
- 1.1.1 — 2015-10-05
- 1.1.0 — 2015-10-05
- 1.0.8 — 2015-10-05
- 1.0.7 — 2015-09-28
- 1.0.6 — 2015-09-28
- 1.0.5 — 2015-09-26
- 1.0.4 — 2015-09-26
- 1.0.2 — 2015-09-26
- 1.0.1 — 2015-09-26

## README

mishear-phrase
==============

This module is like [mishear](https://github.com/jimkang/mishear), but it works on a phrase instead of just a word.

Installation
------------

    npm install mishear-phrase

(This can take a while because its dependencies need to build a few databases.)

Usage
-----

    var MishearPhrase = require('mishear-phrase');

    var mishearPhrase = MishearPhrase({
      shouldMishearWord: function shouldMishearWord(word, done) {
        getPartOfSpeech(word, decide);

        function decide(partOfSpeech) {
          done(
            null, 
            ['noun', 'verb', 'adjective'].indexOf(partOfSpeech) !== -1
          );
        }
      },
      pickMishearing: function pickMishearing(mishearings, done) {
        callNextTick(done, null, mishearings[0]);
      }
    });

    mishearPhrase(
      'The quick brown fox jumped over the lazy dog', logMisheardPhrase
    );

    function logMisheardPhrase(error, phrase) {
      if (error) {
        console.log(error);
      }
      else {
        console.log(phrase);
      }
    }

Output:

    The quack crown vox jumped over the lousy bog.

**shouldMishearWord** is a function that tells mishearPhrase whether it should mishear a particular word. It can be used to limit how many mishearings there are in a phrase, e.g.:

    function shouldMishearWord(word, done) {
      // Only mishear one in every three words.
      callNextTick(done, null, ~~(Math.random() * 3) === 0);
    }

It could also be used to restrict mishearing to certain parts of speech only:

    function shouldMishearWord(word, partOfSpeech, done) {
      getPartOfSpeech(word, decide);

      function decide(partOfSpeech) {
        done(
          null, 
          ['noun', 'verb', 'adjective'].indexOf(partOfSpeech) !== -1
        );
      }
    }

The default is a function that always passes back `true`.

**pickMishearing** is a function that picks from an array of the possible mishearings for a word. You can use this to pick words at random or via whatever heuristic you like. The default is a function that always picks the first element of the array.

Tests
-----

Run tests with `make test`.

Note: Because `homophonizer` is not deterministic, the tests sometimes pass and sometimes fail. (That needs to be changed.) But you can tell if it failed legitimately or not.

License
-------

The MIT License (MIT)

Copyright (c) 2015 Jim Kang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

---
_Source: https://npm.io/package/mishear-phrase · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
