Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

nlcst-affix-emoticon-modifier

1.1.4 • Public • Published

nlcst-affix-emoticon-modifier

Build Coverage Downloads Size Sponsors Backers Chat

nlcst utility to move initial emoticons into the previous sentence. Useful because many people place an emoticon, representing emotion related to the previous sentence, after a terminal marker. 😒

Note: You probably want to use retext-emoji.

Install

npm:

npm install nlcst-affix-emoticon-modifier

Use

var affixEmoticon = require('nlcst-affix-emoticon-modifier')
var emoticon = require('nlcst-emoticon-modifier')
var inspect = require('unist-util-inspect')
var english = require('parse-english')()
 
english.useFirst('tokenizeSentence', emoticon)
english.useFirst('tokenizeParagraph', affixEmoticon)
 
console.log(inspect(english.parse('Hey. :) How is it going?')))

Yields:

RootNode[1]
└─ ParagraphNode[3]
   ├─ SentenceNode[4]
   │  ├─ WordNode[1]
   │  │  └─ TextNode: 'Hey'
   │  ├─ PunctuationNode: '.'
   │  ├─ WhiteSpaceNode: ' '
   │  └─ EmoticonNode: ':)'
   ├─ WhiteSpaceNode: ' '
   └─ SentenceNode[8]
      ├─ WordNode[1]
      │  └─ TextNode: 'How'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1]
      │  └─ TextNode: 'is'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1]
      │  └─ TextNode: 'it'
      ├─ WhiteSpaceNode: ' '
      ├─ WordNode[1]
      │  └─ TextNode: 'going'
      └─ PunctuationNode: '?'

API

affixEmoticon(paragraph)

Merge affix emoticons (EmoticonNode) into the previous sentence.

Parameters
paragraph

The node to process (Paragraph).

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, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Install

npm i nlcst-affix-emoticon-modifier

DownloadsWeekly Downloads

2,763

Version

1.1.4

License

MIT

Unpacked Size

7.99 kB

Total Files

4

Last publish

Collaborators

  • avatar
  • avatar