worked example: random-sentence
description:
learn some sentence fragments, and then produce a valid sentence
motivated by this: http://write-up.semantic-db.org/221-generating-random-grammatically-correct-sentences.html
in gm notation:
A = {the.woman.saw}
B = {through.the.telescope}
C = {{}, young}
D = {girl, boy}
E = {{}, old, other}
F = {man, woman, lady}
G = E.F
H = {the}
I = H.C.D
J = H.E.F
K = {{},I,J}
L = A.K.B
M = {I,J}
N = {saw}
O = M.N.K.B
P = {through.the}
Q = {telescope, binoculars, night.vision.goggles}
R = M.N.K.P.Q
code:
frag |A> => |the woman saw>
frag |B> => |through the telescope>
frag |C> #=> spick-elt (|> . |young>)
frag |D> #=> spick-elt (|girl> . |boy>)
frag |E> #=> spick-elt (|> . |old> . |other>)
frag |F> #=> spick-elt (|man> . |woman> . |lady>)
frag |G> #=> frag (|E> . |F>)
frag |H> => |the>
frag |I> #=> frag (|H> . |C> . |D>)
frag |J> #=> frag (|H> . |E> . |F>)
frag |K> #=> frag spick-elt (|> . |I> . |J>)
frag |L> #=> frag (|A> . |K> . |B>)
frag |M> #=> frag spick-elt (|I> . |J>)
frag |N> => |saw>
frag |O> #=> frag (|M> . |N> . |K> . |B>)
frag |P> => |through the>
frag |Q> #=> spick-elt (|telescope> . |binoculars> . |night vision goggles>)
frag |R> #=> frag (|M> . |N> . |K> . |P> . |Q>)
sentence |*> #=> to-upper[1] smerge[" "] sdrop frag |R> _ |.>
examples:
sentence
|The other lady saw the old woman through the telescope.>
sentence
|The young boy saw the young girl through the binoculars.>
sentence
|The old woman saw the other man through the telescope.>
sentence
|The young boy saw the young girl through the night vision goggles.>
future:
scale it up, and maybe write a gm-to-code converter?
source code:
load the-woman-saw.sw
Home