All pastes #1221700 Raw Edit

webeconomy2.lisp

public text v1 · immutable
#1221700 ·published 2008-10-07 13:33 UTC
rendered paste body
;;;; Common Lisp implementation of the Web Economy Bullshit Generator.
;;;; See http://dack.com/web/bullshit.html for the original.
;;;; This edition was enhanced to also generate sentences, paragraphs or
;;;; HTML pages.
;;;;
;;;; Examples:
;;;;
;;;; CL-USER> (bullshit-list)
;;;; (TARGET MAGNETIC INFOMEDIARIES)
;;;;
;;;; CL-USER> (bullshit-item)
;;;; "Exploit sexy initiatives."
;;;;
;;;; CL-USER> (bullshit-sentence)
;;;; "We guarantee to engage enterprise relationships to reintermediate
;;;;  cross-media vortals."
;;;;
;;;; CL-USER> (bullshit-paragraph)
;;;; "It is imperative that we productize cross-media e-markets or enable
;;;;  compelling applications.  We engineer holistic methodologies in order
;;;;  to embrace 24/7 infrastructures to monetize impactful niches.  We
;;;;  guarantee to expedite sexy mindshare and redefine 24/7 e-business.
;;;;  This makes it possible to orchestrate killer technologies to e-enable
;;;;  best-of-breed bandwidth to be able to utilize compelling
;;;;  infrastructures."
;;;;
;;;; (bullshit-page) may also be used to generate bullshit HTML pages :)

(defparameter *verbs*
  '#(
     aggregate
     architect
     benchmark
     brand
     cultivate
     deliver
     deploy
     disintermediate
     drive
     e-enable
     embrace
     empower
     enable
     engage
     engineer
     enhance
     envisioneer
     evolve
     expedite
     exploit
     extend
     facilitate
     generate
     grow
     harness
     implement
     incentivize
     incubate
     innovate
     integrate
     iterate
     leverage
     matrix
     maximize
     mesh
     monetize
     morph
     optimize
     orchestrate
     productize
     recontextualize
     redefine
     reintermediate
     reinvent
     repurpose
     revolutionize
     scale
     seize
     strategize
     streamline
     syndicate
     synergize
     synthesize
     target
     transform
     transition
     unleash
     utilize
     visualize
     whiteboard)
  "Verb patterns to be returned as first symbol by BULLSHIT-LIST.")

(defparameter *adjectives*
  '#(
     24/365
     24/7
     B2B
     B2C
     back-end
     best-of-breed
     bleeding-edge
     bricks-and-clicks
     clicks-and-mortar
     collaborative
     compelling
     cross-platform
     cross-media
     customized
     cutting-edge
     distributed
     dot-com
     dynamic
     e-business
     efficient
     end-to-end
     enterprise
     extensible
     frictionless
     front-end
     global
     granular
     holistic
     impactful
     innovative
     integrated
     interactive
     intuitive
     killer
     leading-edge
     magnetic
     mission-critical
     next-generation
     one-to-one
     open-source
     out-of-the-box
     plug-and-play
     proactive
     real-time
     revolutionary
     rich
     robust
     scalable
     seamless
     sexy
     sticky
     strategic
     synergistic
     transparent
     turn-key
     ubiquitous
     user-centric
     value-added
     vertical
     viral
     virtual
     visionary
     web-enabled
     wireless
     world-class)
  "Adjective patterns to be returned as second symbol by BULLSHIT-LIST.")

(defparameter *nouns*
  '#(
     action-items
     applications
     architectures
     bandwidth
     channels
     communities
     content
     convergence
     deliverables
     e-business
     e-commerce
     e-markets
     e-services
     e-tailers
     experiences
     eyeballs
     functionalities
     infomediaries
     infrastructures
     initiatives
     interfaces
     markets
     methodologies
     metrics
     mindshare
     models
     networks
     niches
     paradigms
     partnerships
     platforms
     portals
     relationships
     ROI
     synergies
     web-readiness
     schemas
     solutions
     supply-chains
     systems
     technologies
     users
     vortals
     web-services)
  "Noun patterns to be returned as third symbol from BULLSHIT-LIST.")

(defparameter *sentence-starts*
  '#(
     we
     |we guarantee to|
     |it is important to|
     |it is imperative that we|
     |we ensure to|
     |this makes it possible to|
     |this enables us to|
     |this allows us to|
     |always remember that we|
     |moreover, we|
     |basically, we|
     |we seize the opportunity to|
     |our company aims to|
     |we aim to|
     |our expertise permits us to|
     |we work together to|
     |our experts|
     |for starters, we|
     |as leaders, we|
     |never forget that we work hard to|
     |our array of services|
     |our leading strategies|
     |our customers can be assured that we|
     |microsoft products are deprecated because our software|
     |our superior software|
     |our turn-key customized solutions|
     |our customized software|)
  "Sentence prefix patterns to be used by SENTENCE-LIST.")

(defparameter *sentence-separators*
  '#(
     and
     or
     to
     |to thus|
     |in order to|
     |to be able to|
     |which enable us to|
     |allowing us to|
     |permitting to|
     |making possible to|
     |enabling to|
     |prioritizing tasks to|
     |rendering possibilities to|
     |defining methods to|)
  "Pattern to be inserted in-between BULLSHIT-LIST generated lists in order 
to form a sentence by SENTENCE-LIST.")

(defun random-symbol (vector)
  "Returns a random symbol from specified VECTOR."
  (svref vector (random (array-dimension vector 0))))

(defun bullshit-list ()
  "Returns a list consisting of three randomly chosen symbols."
  (list (random-symbol *verbs*)
	(random-symbol *adjectives*)
	(random-symbol *nouns*)))

(defun sentence-list ()
  "Returns a list consisting of random symbols forming a sentence, 
internally using BULLSHIT-LIST."
  (let ((r (1+ (random 3))))
    (nconc
     (list (random-symbol *sentence-starts*))
     (reduce #'nconc
	     (loop repeat r
		collect (nconc (bullshit-list)
			       (list (random-symbol *sentence-separators*)))))
     (bullshit-list))))

(defun paragraph-list ()
  "Returns a list consisting of SENTENCE-LIST lists."
  (let ((r (+ 3 (random 3))))
    (loop repeat r collect (sentence-list))))

(defun list-print (list &optional (stream nil))
  (let ((str (lists-print list)))
    (format stream "~A" (subseq str 0 (- (length str) 2)))))

(defun lists-print (lists &optional (stream nil))
  "Creates a string holding properly formatted sentences for each list of
LISTS, optionally printing it if STREAM is specified.  Also works for non-
nested list."
  (let ((str (make-array '(0) :element-type 'character
			      :fill-pointer 0 :adjustable t)))
    (with-output-to-string (s str)
      (if (listp (first lists))
	  (mapcar #'(lambda (l)
		      (lists-print l s))
		  lists)
	  (format s "~@(~{~A~^ ~}~).  " lists)))
    (format stream "~A" str)))

;;; XXX Simple imperfect string wrapper function.
(defun print-wrap (string &optional (stream nil) (columns 66))
  "Wraps supplied STRING to be printable within COLUMNS, optionally printing 
the result if STREAM is supplied."
  (let ((s "")
	(col 0))
    (declare (type fixnum col))
    (loop for c across string do
	 (if (and (char= c #\Space)
		  (> col columns))
	     (setf s (concatenate 'string s (list #\Newline))
		   col 0)
	     (setf s (concatenate 'string s (list c))
		   col (1+ col))))
    (format stream "~A" s)))


;;;; General user functions

(defun bullshit-item (&optional (stream nil))
  "Prints a formatted single bullshit item."
  (print-wrap (list-print (bullshit-list)) stream))

(defun bullshit-sentence (&optional (stream nil))
  "Prints a formatted bullshit sentence."
  (print-wrap (list-print (sentence-list)) stream))

(defun bullshit-paragraph (&optional (stream nil))
  "Prints a formatted bullshit paragraph."
  (print-wrap (list-print (paragraph-list)) stream))

(defun bullshit-page (&optional (stream nil))
  "Prints a bullshit HTML page."
  (let ((s "")
	(r (+ 3 (random 3)))
	(bsi (bullshit-item)))
    (loop repeat r do
	 (setf s (concatenate 'string s
			      "<p>"
			      (bullshit-paragraph)
			      "</p>"
			      (list #\Newline))))
    (format stream
	    "<html><head><title>~A</title></head><body>
<h1>~A</h1>
~A</body></html>"
	    bsi bsi s)))