chomsky.py 5.1 KB

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