KaomojiParser is a Swift Package to deal with texts that contain Japanese kaomoji. KaomojiParser supports removing kaomoji from texts and extracting kaomoji from texts.
Implementation notes are available at Qiita(Japanese).
This project aims to search kaomoji in texts. There are various kaomoji, and whether a character is contained in kaomoji or not is not obvious.
ホームランキタ━━━━(゚∀゚)━━━━‼︎
This is one of popular kaomoji, but the range of kaomoji depends on the definition. Perhaps there are three candidates:
(゚∀゚)
is kaomoji, andホームランキタ━━━━━━━━‼︎
is the main text.キタ━━━━(゚∀゚)━━━━
is kaomoji, andホームラン!!
is the main text.キタ━━━━(゚∀゚)━━━━!!
is kaomoji, andホームラン
is the main text.
At first, this project uses the third way to parse texts. Maybe first and second ways can be added in the future.
Currently, KaomojiParser works well with kaomoji that uses un-common characters. However, for kaomoji that use common characters like (- -;)
, (..)
, (*_*)
, or (TT)
, KaomojiParser doesn't work well.
Use Swift Package Manager to use KaomojiParser.
Once you enabled it, KaomojiParser can be used like this.
import KaomojiParser
let parser = KaomojiParser()
let target = "嬉しいです(≧▽≦)"
print(parser.removeKaomoji(from: target)) // "嬉しいです"
print(parser.search(in: target)) // ["(≧▽≦)"]
This implementation relys on this paper. Thanks to the authors.
- 風間一洋, 水木栄, & 榊剛史. (2016). Twitter における顔文字を用いた感情分析の検討. In 人工知能学会全国大会論文集 第 30 回全国大会 (2016) (pp. 3H3OS17a4-3H3OS17a4). 一般社団法人 人工知能学会.