nlcst-affix-emoticon-modifier
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. :unamused:
Implemented by retext-emoji, but
separated for use by standalone (non-retext)
processing.
Installation
npm:
npm install nlcst-affix-emoticon-modifier
nlcst-affix-emoticon-modifier is also available for bower,
component, and
duo, and as an AMD, CommonJS, and globals
module, uncompressed and compressed.
Usage
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
affixEmoticonModifier(paragraph)
Merge affix emoticons into the previous sentence.
Parameters
Throws
Error
— When not given a parent node.
Related
License
MIT © Titus Wormer