import random
import json
# Prototype for testing of tree generative poetry structure.
POEM_TYPE = 'poem'
COUPLET_TYPE = 'couplet'
COUP_LINE_TYPE = 'coup-line'
OBJECT_TYPE = 'object'
ACTION_TYPE = 'action'
SING_OBJECT_TYPE = 'sing-object'
NON_GROW_TYPES = set(['noun', 'act_sing'])
class PoemPart(object):
"""
Class that acts as a backbone structure generated to compose a poem.
"""
def __init__(self, type_info):
self.type_info = type_info
self.children = []
def to_dict(self):
return {
'type_info':self.type_info,
'children':[child.to_dict() for child in self.children]
}
def __repr__(self):
return json.dumps(self.to_dict(), indent=4)
def create_child(self, type_info):
#creates and appends a new child to the part
self.children.append(PoemPart(type_info))
def grow(self):
pass