Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #231 // Executor for apology generator

Document

1  
Input (grammar) looks like this:
2  
3  
Apology ::= my (cat|mouse|monkey) ate my homework.
4  
Apology ::= our (basement|attic|third floor) collapsed from an overload of school books.
5  
6  
Pseudo-code:
7  
8  
Put the grammar into array "rules".
9  
Choose one of the rules (randomly).
10  
Parse rule: Apology ::= <bla>
11  
Parse bla into:
12  
  #1 (...)
13  
  #2 everything else
14  
With every s in #1 do:
15  
  Split inner part of s at "|" into "options".
16  
  Choose one of the options (randomly).
17  
  Replace s with option.
18  
Print bla (with the replacements made).

Author comment

It's some great pseudo-code!

(Note to renderer: "#1" and "#2" above are not snippet links!)

download  show line numbers   

Relations

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 530 [visualize]

Snippet ID: #231
Snippet name: Executor for apology generator
Eternal ID of this version: #231/1
Text MD5: 30720edef91db4ed7dca7f4772a4dec1
Author: stefan
Category: Apology generators
Type: Document
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2014-02-03 22:41:22
Source code size: 530 bytes / 18 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 815 / 181
Referenced in: [show references]