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.
link |
Stars: 1 |
Last commit: 3 weeks ago |
Fixed problem that KaomojiParser
doesn't have any public initializer.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics