initial commit
This commit is contained in:
commit
7d4e3908c2
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.png
|
||||
phonetics-feature-tree
|
115
phonetics-feature-tree.scm
Normal file
115
phonetics-feature-tree.scm
Normal file
@ -0,0 +1,115 @@
|
||||
(define (left-child tree)
|
||||
(cadr tree))
|
||||
(define (left-child-name tree)
|
||||
(car (left-child tree)))
|
||||
(define (right-child tree)
|
||||
(caddr tree))
|
||||
(define (right-child-name tree)
|
||||
(car (right-child tree)))
|
||||
(define (cur-name tree)
|
||||
(car tree))
|
||||
|
||||
(define (to-string phon-tree node-nbr child next-nbr)
|
||||
(let ((this-name (string-append "node"
|
||||
(number->string node-nbr)))
|
||||
(child-name (string-append "node"
|
||||
(number->string next-nbr))))
|
||||
(string-append child-name
|
||||
"[label=\""
|
||||
(cur-name child)
|
||||
"\"];"
|
||||
this-name
|
||||
"--"
|
||||
child-name
|
||||
";\n"
|
||||
(to-dot-main child next-nbr))))
|
||||
|
||||
(define (to-dot-main phon-tree node-nbr)
|
||||
(let* ((this-name (string-append (number->string node-nbr)
|
||||
"node")))
|
||||
(if (null? (left-child phon-tree))
|
||||
""
|
||||
(let ((x (* 2 (+ 1 node-nbr)))
|
||||
(y (* 2 (+ 2 node-nbr))))
|
||||
(string-append (to-string phon-tree node-nbr
|
||||
(left-child phon-tree)
|
||||
x)
|
||||
(to-string phon-tree node-nbr
|
||||
(right-child phon-tree)
|
||||
y))))))
|
||||
|
||||
(define (to-dot phon-tree)
|
||||
(if (null? phon-tree)
|
||||
"\n"
|
||||
(string-append
|
||||
"graph{\n"
|
||||
"node[shape=plaintext];\n"
|
||||
"graph[bgcolor=\"transparent\"];\n"
|
||||
"node1[label=\""
|
||||
(cur-name phon-tree)
|
||||
"\"];\n"
|
||||
|
||||
(to-dot-main phon-tree 1)
|
||||
"}")))
|
||||
|
||||
(define vowel-tree
|
||||
'("[vowel]"
|
||||
("[back]"
|
||||
("[tense]" () ())
|
||||
("{tense}" () ()))
|
||||
("{back}"
|
||||
("[rnd]"
|
||||
("[tense]" () ())
|
||||
("{tense}"
|
||||
("[high]" ())
|
||||
("{high}" ())))
|
||||
("{rnd}"
|
||||
("[tense]"
|
||||
("[high]" () ())
|
||||
("{high}" () ()))
|
||||
("{tense}"
|
||||
("[low]" () ())
|
||||
("{low}" () ()))))))
|
||||
(define vowel2-tree
|
||||
'("[vowel]"
|
||||
("[back]"
|
||||
("[tense]"
|
||||
("[high]" () ())
|
||||
("{high}" () ()))
|
||||
("{tense}"
|
||||
("[high]" () ())
|
||||
("{high}" () ())))
|
||||
("{back}"
|
||||
("[tense]"
|
||||
("[high]" () ())
|
||||
("{high}" () ()))
|
||||
("{tense}"
|
||||
("[high]" () ())
|
||||
("{high}" () ())))))
|
||||
|
||||
(define cons-tree
|
||||
'("[cons]"
|
||||
("[son]"
|
||||
("[dor]"
|
||||
("[high]" () ())
|
||||
("{high}" () ()))
|
||||
("{dor}"
|
||||
("[cor]" () ())
|
||||
("{cor}" () ())))
|
||||
("{son}"
|
||||
("[dor]"
|
||||
("[voice]"
|
||||
("[high]" () ())
|
||||
("{high}" () ()))
|
||||
("{voice}"
|
||||
("[high]" () ())
|
||||
("{high}" () ())))
|
||||
("{dor}"
|
||||
("[voice]"
|
||||
("[cor]" () ())
|
||||
("{cor}" () ()))
|
||||
("{voice}"
|
||||
("[cor]" () ())
|
||||
("{cor}" () ()))))))
|
||||
|
||||
(display (to-dot cons-tree)) (newline)
|
Reference in New Issue
Block a user