Created
January 7, 2010 14:14
-
-
Save tily/271244 to your computer and use it in GitHub Desktop.
make text stammer
This file contains 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
文字を読みながら、そこに表現されてある音響が、いつまでも耳にこびりついて、離れないことがあるだらう。オセロオであつたか、ほかの芝居であつたか、しらべてみれば、すぐ判るが、いまは、もの憂く、とにかくシエクスピア劇のひとつであることは間違ひない、とだけ言つて置いて、その芝居の人殺しのシイン、寝室でひそかに女をしめ殺して、ヒロオも、われも、瞬時、ほつと重くるしい溜息。額の油汗拭はむと、ぴくとわが硬直の指うごかした折、とん、とん、部屋の外から誰やら、ドアをノツクする。ヒロオは、恐怖のあまり飛びあがつた。ノツクは、無心に、つづけられる。とん、とん、とん、とん、ヒロオは、その場で気が狂つたか、どうか、私はその後の筋書を忘れてしまつた。 |
This file contains 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
も文字を読みながら、そこに表現さされてああああるお音響が、いいいいいいいいいいいつまでも耳にこここびりついて、離れないこことがあるだらう。オセロオであつたか、ほほほほほほかの芝居であああああつたか、しししししししししらべてみれば、すぐ判るが、いまは、ももももももの憂く、とにかくシエクスピアげげげげげ劇のひひとつであることは間違ひない、とだけ言つつつつつつつつて置いて、そのしししししし芝居の人殺しのシイン、寝室でひひひひそかに女をしめ殺して、ヒロオも、われも、瞬時、ほほほほほほほほつとお重くくくくくくるしいたたたたたたたたた溜息。額のあああああああ油ああああああああ汗拭はむと、ぴくとわがこここここ硬直のゆゆゆゆゆゆゆゆ指うごかした折、ととととととととん、ととととととととととん、へへへへへ部屋の外から誰やら、ドアをノツクすすすすすすすすすすする。ヒロオは、きききき恐怖のあまりひひひ飛びあがつた。ノツクは、むむむむむむむむむむ無心に、つつつつつづけられる。ととととととととん、とん、とととととととん、ととととととととん、ヒロオは、その場でききき気がきききききき狂つたか、どうか、わわわわ私はその後の筋書をわわわわわわわ忘れてしまつた。 |
This file contains 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
# -*- coding: utf-8 -*- | |
require 'nkf' | |
require 'rubygems' | |
require 'ja_util' | |
# TODO: recognize complex noun as target to stammerize | |
# not at all intended to encourage discrimination against people who have stammering symptoms | |
STDIN.read.split("\n").each do |line| | |
word_list = JaUtil::WordList.from_text(line) | |
sentence = '' | |
word_list.each do |word| | |
stammer = '' | |
if rand(2) == 1 && word.is_content_word? && word.pronunciation | |
stammer = word.pronunciation.split(//u).first * (rand(10) + 1) | |
if not word.surface.split(//u).first =~ /^[ァ-ン]$/u | |
stammer = NKF.nkf('-h1 -w', stammer) | |
end | |
end | |
sentence += stammer + word.surface | |
end | |
puts sentence | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment