Racket Slideshow Japanese Poems
It was a good exercise to make slides that show Japanese characters going from top to bottom and the lines going from right to left.
都城の詩人、 富松良夫は「南九州の宮沢賢治」と呼ばれているようです。興味深い人です。
The motivation for the exercise came from last week's opportunity to see a talk about a local poet. Paul Goodman wrote somewhere about the importance of “incidental poetry.” His example was the dedication of a local monument or park. The comment about incidental poetry came to mind again when the speaker said that the local poet Tomimatu Yoshia wrote the local school's song. The writers Ueno Hidenobu and Kawahara Kazuyuki are known for singing a school song by Miyazawa Kenji.
Unless I get a chance to read Practical Typography (by the writer who also did Beautiful Racket)the troubles with punctuation will make me display these poems with html and css3. But in the meantime this code works for the contemplation of simple Japanese poems on a screen.
I had to write an extra utility, character->string
and then kept acclimating myself to naming conventions with string-separate
. It was while working on these poems that I saw the similarities among the empty list '()
and (blank 0)
along with cons
and vc-append
. There never seems to be a need for iteration loops once you get used to recursive procedures, aux or helper functions, and accumulator or keep expressions. Maybe I can use this approach as part of a Ogden's Basic English-style approach to a Basic Scheme (or Basic Racket) that gives humanities students the most widely useful expressions for programming tasks on computers.
code
#! /usr/bin/env racket
#lang slideshow
(define poem-list '("秋と霧島.txt" "山によせて.txt" "秋.txt" "呼ぶ.txt"))
;;(define poem-list (vector->list (current-command-line-arguments)))
;; slideshow: expects [<slide-module-file>] on the command line, given 2 arguments: 秋と霧島.txt 山によせて.txt
;; text-imput
(define text-file (car poem-list))
(define (str->path str)
(build-path (current-directory-for-user) str))
(define (get-text str)
(define inp (open-input-file (str->path str)))
(port->string inp))
;; slideshow settings
(define text-size 30)
;;(define t-style (cons 'italic 'roman))
(define t-style 'roman)
(define (char-style s)
(text s t-style text-size))
(define (character->string c)
(list->string (list c)))
(define (string-separate s)
(map character->string
(string->list s)))
(define (text-ttb s) ; top to bottom
(define l (string-separate s))
(define (helper str-chrs kept-pics)
(cond
((empty? str-chrs) kept-pics)
((string=? "、" (car str-chrs))
(helper (cdr str-chrs) (vc-append kept-pics
(rotate (char-style (car str-chrs))
(/ pi 1)) )))
((string=? "-" (car str-chrs))
(helper (cdr str-chrs) (vc-append kept-pics
(vline 1 90))))
; (rotate (char-style "---")
; (/ pi 2)) )))
;; later to string=? "(" and ")"
(#t (helper (cdr str-chrs) (vc-append kept-pics
(char-style (car str-chrs)))))))
(helper (string-separate s) (blank 0)))
(define title-body-gap (blank 40))
(define sect-sect-gap (blank 20))
(define line-line-gap (blank 12))
(define (text-ttb-rtl s) ; right to left
(define sl (string-split s "\n"))
(define p-title (car sl))
(define p-body (cdr sl))
(define (helper p-lines kept-pics)
(cond
((empty? p-lines) kept-pics)
((= 0 (string-length (car p-lines)))
(helper (cdr p-lines) (ht-append sect-sect-gap kept-pics)))
(#t (helper (cdr p-lines)
(ht-append
(ht-append line-line-gap (text-ttb (car p-lines)))
kept-pics)))))
(helper p-body (ht-append title-body-gap (text-ttb p-title))))
#;(define Kirishima-Poem
(get-text text-file))
(define (make-slide str)
(define poem (get-text str))
(slide
(text-ttb-rtl poem)))
(map make-slide poem-list)
#;(slide
(text-ttb-rtl Kirishima-Poem))
Poems
呼ぶ.txt
呼ぶ - 亡き妹に
冬ぞらの 雲のはてなる死
かすかなるほのほでもあらば
かえてくるにいいときだ
凍てついた白い椿
そなたが残していった たったひとりの僕
秋.txt
秋
銀河はるばる帯にまいて
あの人は嫁入ってしまった
桔梗いろの封筒が
きれぎれな雲影を封じてよこした
山によせて.txt
山によせて
ひかりの箭をはなつ朝
山は霧のなかに生れ
むらさきの山体は
こんじきの匂ひをもつ
あたらしい日を信じ
あたらしい世界のきたるを信じ
にんげんの哀しさも
国の面する悲運のかげも
世界の精神的下降の現実も
わすれはてるわけではないが
いまこのあざやかな
朝のひかりにおぼれ
悠々と非情の勁さにそびえている
山にまなぼう
秋と霧島.txt
秋と霧島
風に洗われるので
山も痩せてきた
おまえも旅人、 わたしも旅人
空にいんえいのない深い時がきた
その胸のうちには冷たい水
口にふくむのはわたしひとり
岩石をななめに削り
掘っても掘っても炎にはとどかぬ
ここは山のもろ腰だ
もう少しわけ入って見よう
しきよくの世界のおそろしさ
純血精のように紅葉の谷
風におそわれるので
山も痩せてきた
ただことでないその痩せかた
だれかのきようの似すがただ
おまえも旅人、 わたし旅人
さっさっと何を急ごう
山膚をなで、 山の根をさすり
わが胸の底の炎は消されはせぬ
#Racket #DrRacket #slideshow #poem #poetry #富松良夫 #都城市 #宮崎県 #CKOgden #BasicEnglish #BasicScheme #BasicProgramming