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

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