Package nltk :: Package misc :: Module chomsky
[hide private]
[frames] | no frames]

Source Code for Module nltk.misc.chomsky

  1  # Chomsky random text generator, version 1.1, Raymond Hettinger, 2005/09/13  
  2  # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440546 
  3   
  4  import string 
  5   
  6  """CHOMSKY is an aid to writing linguistic papers in the style 
  7      of the great master.  It is based on selected phrases taken 
  8      from actual books and articles written by Noam Chomsky. 
  9      Upon request, it assembles the phrases in the elegant 
 10      stylistic patterns that Chomsky is noted for. 
 11      To generate n sentences of linguistic wisdom, type 
 12          (CHOMSKY n)  -- for example 
 13          (CHOMSKY 5) generates half a screen of linguistic truth.""" 
 14   
 15  leadins = """To characterize a linguistic level L, 
 16      On the other hand, 
 17      This suggests that 
 18      It appears that 
 19      Furthermore, 
 20      We will bring evidence in favor of the following thesis: 
 21      To provide a constituent structure for T(Z,K), 
 22      From C1, it follows that 
 23      For any transformation which is sufficiently diversified in \ 
 24  application to be of any interest, 
 25      Analogously, 
 26      Clearly, 
 27      Note that 
 28      Of course, 
 29      Suppose, for instance, that 
 30      Thus 
 31      With this clarification, 
 32      Conversely, 
 33      We have already seen that 
 34      By combining adjunctions and certain deformations, 
 35      I suggested that these results would follow from the assumption that 
 36      If the position of the trace in (99c) were only relatively \ 
 37  inaccessible to movement, 
 38      However, this assumption is not correct, since 
 39      Comparing these examples with their parasitic gap counterparts in \ 
 40  (96) and (97), we see that 
 41      In the discussion of resumptive pronouns following (81), 
 42      So far, 
 43      Nevertheless, 
 44      For one thing, 
 45      Summarizing, then, we assume that 
 46      A consequence of the approach just outlined is that 
 47      Presumably, 
 48      On our assumptions, 
 49      It may be, then, that 
 50      It must be emphasized, once again, that 
 51      Let us continue to suppose that 
 52      Notice, incidentally, that """ 
 53  # List of LEADINs to buy time. 
 54   
 55  subjects = """ the notion of level of grammaticalness 
 56      a case of semigrammaticalness of a different sort 
 57      most of the methodological work in modern linguistics 
 58      a subset of English sentences interesting on quite independent grounds 
 59      the natural general principle that will subsume this case 
 60      an important property of these three types of EC 
 61      any associated supporting element 
 62      the appearance of parasitic gaps in domains relatively inaccessible \ 
 63  to ordinary extraction 
 64      the speaker-hearer's linguistic intuition 
 65      the descriptive power of the base component 
 66      the earlier discussion of deviance 
 67      this analysis of a formative as a pair of sets of features 
 68      this selectionally introduced contextual feature 
 69      a descriptively adequate grammar 
 70      the fundamental error of regarding functional notions as categorial 
 71      relational information 
 72      the systematic use of complex symbols 
 73      the theory of syntactic features developed earlier""" 
 74  # List of SUBJECTs chosen for maximum professorial macho. 
 75   
 76  verbs = """can be defined in such a way as to impose 
 77      delimits 
 78      suffices to account for 
 79      cannot be arbitrary in 
 80      is not subject to 
 81      does not readily tolerate 
 82      raises serious doubts about 
 83      is not quite equivalent to 
 84      does not affect the structure of 
 85      may remedy and, at the same time, eliminate 
 86      is not to be considered in determining 
 87      is to be regarded as 
 88      is unspecified with respect to 
 89      is, apparently, determined by 
 90      is necessary to impose an interpretation on 
 91      appears to correlate rather closely with 
 92      is rather different from""" 
 93  #List of VERBs chosen for autorecursive obfuscation. 
 94   
 95  objects = """ problems of phonemic and morphological analysis. 
 96      a corpus of utterance tokens upon which conformity has been defined \ 
 97  by the paired utterance test. 
 98      the traditional practice of grammarians. 
 99      the levels of acceptability from fairly high (e.g. (99a)) to virtual \ 
100  gibberish (e.g. (98d)). 
101      a stipulation to place the constructions into these various categories. 
102      a descriptive fact. 
103      a parasitic gap construction. 
104      the extended c-command discussed in connection with (34). 
105      the ultimate standard that determines the accuracy of any proposed grammar. 
106      the system of base rules exclusive of the lexicon. 
107      irrelevant intervening contexts in selectional rules. 
108      nondistinctness in the sense of distinctive feature theory. 
109      a general convention regarding the forms of the grammar. 
110      an abstract underlying order. 
111      an important distinction in language use. 
112      the requirement that branching is not tolerated within the dominance \ 
113  scope of a complex symbol. 
114      the strong generative capacity of the theory.""" 
115  # List of OBJECTs selected for profound sententiousness. 
116   
117  import textwrap, random 
118  from itertools import chain, islice, izip 
119   
120 -def chomsky(times=1, line_length=72):
121 parts = [] 122 for part in (leadins, subjects, verbs, objects): 123 phraselist = map(str.strip, part.splitlines()) 124 random.shuffle(phraselist) 125 parts.append(phraselist) 126 output = chain(*islice(izip(*parts), 0, times)) 127 return textwrap.fill(string.join(output), line_length)
128 129 print chomsky(5) 130