Skip to content

Commit

Permalink
Add improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 31, 2022
1 parent 793ded5 commit f6dc253
Showing 1 changed file with 79 additions and 14 deletions.
93 changes: 79 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,56 @@
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

Easy access to [afinn-111][afinn111].
[afinn-111][afinn111].

## Install
## Contents

* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`afinn111`](#afinn111)
* [Notes](#notes)
* [Types](#types)
* [Compatibility](#compatibility)
* [Related](#related)
* [Contribute](#contribute)
* [Security](#security)
* [License](#license)

## What is this?

This package gives you easy access to [afinn-111][afinn111].

This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
## When should I use this?

You’re probably dealing with natural language, and know you need this, if
you’re here!

## Install

[npm][]:
This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, 16.0+), install with [npm][]:

```sh
npm install afinn-111
```

In Deno with [`esm.sh`][esmsh]:

```js
import {afinn111} from 'https://esm.sh/afinn-111@2'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
import {afinn111} from 'https://esm.sh/afinn-111@2?bundle'
</script>
```

## Use

```js
Expand All @@ -29,34 +66,45 @@ afinn111['self-deluded'] //=> -2

## API

This package exports the following identifiers: `afinn111`.
This package exports the identifier `afinn111`.
There is no default export.

### `afinn111`

`afinn-111` maps entries to valence ratings (`Object.<string, number>`).

> Note!
> 👉 **Note**:
> Be careful when accessing unknown properties on the `afinn-111` object, words
> such as “constructor” or “toString” might occur.
> It’s recommended to use a `hasOwnProperty` check beforehand.
## Musings
## Notes

Note the AFINN entries are:

* All lower case
* Can contain numbers (only case: `n00b`)
* Can contain spaces (cases: `can't stand`, `cashing in`,
* all lower case
* can contain numbers (only case: `n00b`)
* can contain spaces (cases: `can't stand`, `cashing in`,
`cool stuff`, `does not work`, `dont like`, `fed up`, `green wash`,
`green washing`, `messing up`, `no fun`, `not good`, `not working`,
`right direction`, `screwed up`, `some kind`)
* Can contain apostrophes (only case: `can't stand`)
* Can contain diaeresis (only case: `naïve`)
* Can contain dashes (cases: `cover-up`, `made-up`,
* can contain apostrophes (only case: `can't stand`)
* can contain diaeresis (only case: `naïve`)
* can contain dashes (cases: `cover-up`, `made-up`,
`once-in-a-lifetime`, `self-confident`, `self-deluded`,
`short-sighted`, `short-sightedness`, `son-of-a-bitch`)

## Types

This package is fully typed with [TypeScript][].
It exports no additional types.

## Compatibility

This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 14.14+, 16.0+, and 18.0+.
It also works in Deno and modern browsers.

## Related

* [`afinn-96`](https://github.com/words/afinn-96)
Expand All @@ -68,6 +116,15 @@ Note the AFINN entries are:
* [`polarity`](https://github.com/words/polarity)
— Detect the polarity of text, based on `afinn-165` and `emoji-emotion`

## Contribute

Yes please!
See [How to Contribute to Open Source][contribute].

## Security

This package is safe.

## License

[MIT][license] © [Titus Wormer][author]
Expand All @@ -92,8 +149,16 @@ Note the AFINN entries are:

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

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[esmsh]: https://esm.sh

[license]: license

[author]: https://wooorm.com

[typescript]: https://www.typescriptlang.org

[contribute]: https://opensource.guide/how-to-contribute/

[afinn111]: https://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6010

0 comments on commit f6dc253

Please sign in to comment.