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

18
LINES

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

Document

Input (grammar) looks like this:

Apology ::= my (cat|mouse|monkey) ate my homework.
Apology ::= our (basement|attic|third floor) collapsed from an overload of school books.

Pseudo-code:

Put the grammar into array "rules".
Choose one of the rules (randomly).
Parse rule: Apology ::= <bla>
Parse bla into:
  #1 (...)
  #2 everything else
With every s in #1 do:
  Split inner part of s at "|" into "options".
  Choose one of the options (randomly).
  Replace s with option.
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: 804 / 178
Referenced in: [show references]