unified

Project: syntax-tree/nlcst-emoticon-modifier

Package: nlcst-emoticon-modifier@2.1.0

  1. Dependents: 2
  2. nlcst utility to support emoticons in nlcst
  1. util 143
  2. utility 139
  3. unist 127
  4. nlcst 14
  5. nlcst-util 9
  6. emoticon 4

nlcst-emoticon-modifier

Build Coverage Downloads Size Sponsors Backers Chat

nlcst utility to classify ASCII emoticons as EmoticonNodes.

Note: You probably want to use retext-emoji.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install nlcst-emoticon-modifier

Use

import {emoticonModifier} from 'nlcst-emoticon-modifier'
import {inspect} from 'unist-util-inspect'
import {ParseEnglish} from 'parse-english'

const sentence = new ParseEnglish().parse('This makes me feel :).').children[0].children[0]

emoticonModifier(sentence)

console.log(inspect(sentence))

Yields:

SentenceNode[10]
├─ WordNode[1]
│  └─ TextNode: 'This'
├─ WhiteSpaceNode: ' '
├─ WordNode[1]
│  └─ TextNode: 'makes'
├─ WhiteSpaceNode: ' '
├─ WordNode[1]
│  └─ TextNode: 'me'
├─ WhiteSpaceNode: ' '
├─ WordNode[1]
│  └─ TextNode: 'feel'
├─ WhiteSpaceNode: ' '
├─ EmoticonNode: ':)'
└─ PunctuationNode: '.'

API

This package exports the following identifiers: emoticonModifier. There is no default export.

emoticonModifier(sentence)

Classify ASCII emoticons as EmoticonNodes.

Parameters
sentence

Node to process (Sentence).

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer