Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random walk through syntax tree space #139

Open
serin-delaunay opened this issue Nov 30, 2019 · 11 comments
Open

Random walk through syntax tree space #139

serin-delaunay opened this issue Nov 30, 2019 · 11 comments

Comments

@serin-delaunay
Copy link

serin-delaunay commented Nov 30, 2019

I don't know if I'll have time to finish this during the 11 hours remaining (it has been a busy November), but I plan to modify https://github.com/aparrish/pytracery so that I can save a tracery-generated syntax tree and randomly modify a single node (and generate any necessary descendants). Then I'll generate a sequence of phrases randomly walking around the state space of a tracery grammar. Not sure which grammar, probably something recursive!

I might also generate an independent random sequence of punctuation and intersperse that to break up the sentences and exploit any ambiguities in the text.

No repo yet!

=====================

Repository: https://github.com/serin-delaunay/mutatery-nngm-2019
Plain: https://github.com/serin-delaunay/mutatery-nngm-2019/blob/master/story.txt
Punctuated: https://github.com/serin-delaunay/mutatery-nngm-2019/blob/master/story_punctuated.txt

@serin-delaunay
Copy link
Author

First step is getting pytracery to assign a unique path to each choice made in expanding the grammar. This is mostly done, but some assignment syntaxes produce an empty path for some reason. The code's jumping around in one file a lot, so I'm going to have to debug this in pycharm.

@serin-delaunay
Copy link
Author

Fixed! I wasn't passing path information through grammar.flatten()

@serin-delaunay
Copy link
Author

serin-delaunay commented Nov 30, 2019

I've got a basic version working! Due to laptop issues I'm coding on an offline device, so no preview for now. To-do list:

  • exclude 1-option choices from the possibilities for mutation
  • clean up unused choices after each mutation
  • always choose a different option when mutating a choice
  • exclude choices with large subtrees from possibilities for mutation (how to detect these?)
  • (optional) add randomly placed independent punctuation sequence

@serin-delaunay
Copy link
Author

serin-delaunay commented Nov 30, 2019

Preview after the easier tasks above are completed, using the grammar from https://twitter.com/BokuWaKinoDesu :

A Lovely Country.
An Awful Country.
A Country That Longs For Favoritism.
A Country That Longs For Determination.
A Country Where Tournaments Age.
A Country Where Tournaments Walk.
A Country Where Wars Walk.
A Country Where Everything Is Destroyed.
The Country Of The Indefatigable.
The Country Of Shopkeepers That Read.
A Country Where Everyone Is Registered.
A Country Where Everyone Tells Hysterical Aristocrats That Normal Soldiers Must Oppress Rabbits Who Are Popular.
A Country Where Everything Is Registered.
A Country That Longs For Forgiveness.
An Indolent Country.
A Flaky Country.

I think this is a reasonably-themed grammar to use for this concept, but I have some different plans (and this grammar has some bugs and other undesirable qualities because I was still learning tracery).

@hugovk hugovk added the preview label Nov 30, 2019
@serin-delaunay
Copy link
Author

I've got a grammar written and it's looking good!

Preview without weird punctuation:


they dash under a grammar pyramid despite you boulder
they trudge under a grammar pyramid despite you boulder
they trudge to a grammar pyramid despite you boulder
they trudge to a grammar pyramid despite you trudge
they trudge to a grammar pyramid despite you trudge or we and me slide through birmingham
they trudge to a grammar pyramid despite you trudge or Kelsey and me slide through birmingham
they trudge to a grammar pyramid despite you trudge or Kelsey and me slide through here
they trudge to the word tree despite you trudge or Kelsey and me slide through here
they trudge to the word tree despite you trudge following them or Kelsey and me slide through here
they trudge to a phrase structure despite you trudge following them or Kelsey and me slide through here
they trudge to a phrase structure despite you trudge following them or Kelsey and me slide through a word tree
they trudge to a phrase structure despite you trudge following them unless I bumble through the phrase diagram
they trudge to a phrase structure despite you trudge following them unless you bumble through the phrase diagram
they trudge to a phrase structure despite you trudge following them unless you sprint through the phrase diagram
they trudge to a phrase structure despite you trudge following them unless you sprint past the phrase diagram
they trudge to a phrase structure
we and you and Kaden trudge to a phrase structure
we and you and Kaden trudge with Evelyn
we and you and Kaden trudge
we and them and Kaden trudge
we and them and us trudge
we and you and you and Giovanni trudge
Antonio and us trudge
Alex and us trudge

with weird punctuation:


Alicia and me swagger next to, the parse structure unless you backpack far. from the sentence structure or. Kevin and us. paddle through there but. they stroll or we traipse like you and you and them you. ride and. Alicia and me! swagger next (to the parse) structure unless you (backpack far from the sentence structure or Kevin and us paddle through there but they stroll or we traipse like "you" and me and them you ride and Alicia and me swagger next to a phrase pyramid unless you backpack far from the) sentence structure. or Kevin and. us paddle. through there.

but they "stroll or we traipse like you and" me and them you. ride and Alicia and me swagger next to (a phrase pyramid (unless you backpack far from) the sentence) structure - or Kevin and us paddle through there but they stroll or I and Johnathan traipse like, you. and me and them, you ride and Alicia and me swagger next to a phrase pyramid unless?

@serin-delaunay
Copy link
Author

I think I prefer the weird punctuation one, but there's no reason not to generate both.

They need a bit of capitalisation.

@serin-delaunay
Copy link
Author

It's done! Before the deadline! Just gotta get it uploaded :)

@serin-delaunay
Copy link
Author

@serin-delaunay
Copy link
Author

Grammar: https://github.com/serin-delaunay/mutatery-nngm-2019/blob/master/definite_actual_grammar.json

It's a bit weird for a Tracery grammar - It generates sentences from the inside out, starting with a basic SP VP phrase and wrapping layers around it. Ordinarily this wouldn't be necessary, but doing this affects the structure of the syntax tree space that this generator randomly walks in, allowing the inner words to be preserved when the surrounding phrase elements are mutated.

@serin-delaunay
Copy link
Author

Being in a rush, I forgot to use the nice capitaliser on the unpunctuated version or add full stops. Whoops!

@serin-delaunay
Copy link
Author

I like the way https://www.naturalreaders.com/online/ attempts to interpret the punctuated version! Might work for other NNGM entries as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants