Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # knowledge
- know = {}
- # sense estimulation
- heard = input("What do you want to do? ")
- # naming filename
- def create_filename(name):
- return name.replace(' ', '_') + '.json'
- # naming classname
- def create_class_name(name):
- subnames = []
- if ' ' in name:
- subnames = [subname.capitalize() for subname in name.split()]
- return "".join(subnames)
- return name.capitalize()
- # saving model in memory database
- def create_json_class():
- print('Creating class JSON')
- # stimulus to create a new word associated with the need for current memory
- name = input('What name do I give the class? ')
- # saving model in database
- with open(create_filename(name), 'w+') as f:
- f.write(str({
- 'name': create_class_name(name),
- 'statics': [],
- 'attributes': [],
- 'methods': []
- }))
- f.close()
- print('class JSON created')
- return True
- # rendering idealized model
- def create_file_class():
- print('Creating file of class')
- return True
- # memory indexing of "create class" sequence actions
- class Event:
- def __init__(self):
- self.__eventhandlers = []
- def __iadd__(self, handler):
- self.__eventhandlers.append(handler)
- return self
- def __isub__(self, handler):
- self.__eventhandlers.remove(handler)
- return self
- def __call__(self, *args, **keywargs):
- for eventhandler in self.__eventhandlers:
- eventhandler(*args, **keywargs)
- memory_create_class = Event()
- memory_create_class += create_json_class
- memory_create_class += create_file_class
- # knowledge indexing
- know['create_class'] = memory_create_class
- # converting words in knowledge indexing
- understood = heard.replace(" ", "_")
- # accessing knowledge indexing for searching words
- if understood in know:
- interpreted = know[understood]
- # verifing knowledge memory
- interpreted()
- #for memory in interpreted:
- # executing knowledge actions
- #memory() if callable(memory) else None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement