https://github.com/pmcelhaney/higram
https://github.com/pmcelhaney/higram
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pmcelhaney/higram
- Owner: pmcelhaney
- Created: 2017-11-16T04:20:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-19T18:49:27.000Z (over 7 years ago)
- Last Synced: 2024-12-27T19:17:52.260Z (4 months ago)
- Language: JavaScript
- Size: 64.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Patrick McElhaney's Coding Exercise (higram)
## Installation
You should have Node.js installed.
```sh
npm install -g /path/to/directory/containing/this/readme/file
```(Normally installation would just be `npm install higram`, but this package is not published to npm and you most likely have the code on your local machine.)
## Usage
Call higram and pass it a text file.
```sh
higram message.txt
```Or pipe a stream into STDIN.
```sh
curl http://norvig.com/big.txt | higram
```### Example
```sh
$ echo "The quick brown fox and the quick blue hare." | higram
2 the quick
1 quick brown
1 brown fox
1 fox and
1 and the
1 quick blue
1 blue hare
```The output uses the same format as UNIX's [`uniq -c`](https://en.wikipedia.org/wiki/Uniq).
## Development
To run the tests:
```sh
npm test # run the tests once
npm run tdd # run the tests continuously while developing
```
See also [CONTRIBUTING.md](./CONTRIBUTING.md).## Assumptions
- The input is ASCII text.
- The input is case-insenstiive ("The quick" matches "the quick").
- A word consists of letters, numbers, and hyphen (-). Anything else is a delimiter.
- Consecutive delimiters are collapsed to one ("the quick" matches "the quick").
- Two consecutive words always make a higram, even if they cross a boundary such as a sentence or paragraph.