Last active
January 23, 2016 10:05
-
-
Save yamasushi/47c5496ba69eb26d0599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gosh | |
; https://gist.github.com/yamasushi/47c5496ba69eb26d0599 | |
(use srfi-13) | |
(use srfi-14) | |
(use gauche.lazy) | |
(use gauche.collection) | |
(define cs-kanji #[々〇〻\x3400;-\x9FFF;\xF900;-\xFAFF;\x20000;-\x2FFFF;] ) | |
(define cs-hirakana #[ぁ-ん]) | |
(define cs-katakana #[ァ-ン]) | |
(define cs-kana (char-set-union cs-hirakana cs-katakana) ) | |
(define cs-kankana (char-set-union cs-kanji cs-kana) ) | |
(define cs-tweet | |
(char-set-union | |
cs-kankana | |
#[・~〜ー、…!!??,,..。] | |
) ) | |
($ print $ string-concatenate | |
$ lfilter ($ string-any cs-kankana $) | |
$ lmap (^s (regexp-replace-all #/[.,、・]{2,}/ s "…") ) | |
$ lmap (^s (regexp-replace-all #/[~〜・!!??,,..。]/ s "、") ) | |
$ lmap (^s (regexp-replace-all #/[.,、・]{2,}/ s "…") ) | |
$ lmap (^s | |
(if (#/^.*[、!!??,,..。]$/ s) | |
s | |
(string-append s "、") ) ) | |
$ lmap ($ string-filter cs-tweet $) | |
$ lfilter ($ string-any cs-kankana $) | |
$ port->string-lseq $ standard-input-port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment