unified

Project:syntax-tree/nlcst-affix-emoticon-modifier

Package:nlcst-affix-emoticon-modifier@1.1.4

  1. Dependencies:1ยทDependents:2
  2. Merge affix emoticons into the previous sentence in NLCST
  1. nlcst 13
  2. emoticon 2

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