#!/usr/bin/python import random # Title is generated from a tree of lists [] and tuples () . A list means # 'choose one of the elements'; a tuple means 'output all of these in # sequence'. Sentence structure is formed through recursion. It's sort of # like a context-free grammar but less powerful. objects = [ 'DRAM', 'CMP', 'Interconnect', 'Shared Cache', 'Coherence', 'Routers', 'Topology', 'Power', 'Congestion', 'Throughput', 'Latency', 'Core', 'Engine', 'Reorder Buffer', 'Arbiter', 'Prioritization Scheme', 'Register File', 'ISA', 'Critical Path', 'Scheduler', 'Pipeline', 'Branch Predictor', 'Cache', 'Memory', 'DRAM', 'Off-Chip Storage', 'On-Chip Storage', 'Sea of Logic', 'Random Logic' ] adjectives = ['Livelock-free', 'Extensible', 'Energy-Efficient', 'Complexity-Effective', 'Reduced', 'Increased', 'Negligible', 'Partial', 'On-Chip', 'Architectural', 'Decoupled', 'Canonical', 'Marginal', 'Extreme', 'Non-blocking', 'Dynamic', 'Static', 'Dynamically-scheduled' ] actions = [ 'Optimizing', 'Deriving', 'Providing', 'Removing', 'Batching', 'Reconciling', 'Extending', 'Building', 'Optimizing', 'Architecting', 'Decoupling', 'Improving' ] connectors = [ 'for', 'without', 'despite', 'using', 'based on' ] subordinate = [ 'while', 'instead of', 'in addition to', 'in order to', 'despite', 'in lieu of'] techniques = [ 'Aggregation', 'Optimization', 'Reduction' ] adj_obj = [ objects, (adjectives, objects), (adjectives, objects, connectors, techniques) ] phrase = [ ( connectors, adj_obj ), (connectors, techniques) ] phrase_2 = [ phrase, (subordinate, actions, phrase) ] #form1 = ( actions, adj_obj ) form2 = ( actions, adj_obj, phrase ) #form3 = ( actions, adj_obj, phrase, phrase ) #forms = [form1, form2, form3] forms = [form2] vowels = ['A', 'E', 'I', 'O', 'U'] consonants = ['B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z'] names = [ (consonants, vowels, consonants), (consonants, vowels, vowels, consonants) ] named_paper = ( names, ':', forms ) #paper_title = [ forms, named_paper ] paper_title = [ forms ] def process_tree(x): if type(x) == type( [] ): r = int(random.random() * len(x)) if r >= len(x): r = len(x) return process_tree(x[r]) elif type(x) == type( () ): return ' '.join(map(process_tree, x)) else: return x print "Content-type: text/html\n" print "Paper title: ", process_tree(paper_title), "

" print "generate another
" print "source
" print "
paper title generator v0.1 by Chris Fallin"