Generate a random paragraph consisting of `n_words` words. If `vocab` is not None, words will be drawn at random from this list. Otherwise, words will be sampled uniformly from a collection of 26 Latin words.
(n_words, vocab=None)
| 97 | |
| 98 | |
| 99 | def random_paragraph(n_words, vocab=None): |
| 100 | """ |
| 101 | Generate a random paragraph consisting of `n_words` words. If `vocab` is |
| 102 | not None, words will be drawn at random from this list. Otherwise, words |
| 103 | will be sampled uniformly from a collection of 26 Latin words. |
| 104 | """ |
| 105 | if vocab is None: |
| 106 | vocab = [ |
| 107 | "at", |
| 108 | "stet", |
| 109 | "accusam", |
| 110 | "aliquyam", |
| 111 | "clita", |
| 112 | "lorem", |
| 113 | "ipsum", |
| 114 | "dolor", |
| 115 | "dolore", |
| 116 | "dolores", |
| 117 | "sit", |
| 118 | "amet", |
| 119 | "consetetur", |
| 120 | "sadipscing", |
| 121 | "elitr", |
| 122 | "sed", |
| 123 | "diam", |
| 124 | "nonumy", |
| 125 | "eirmod", |
| 126 | "duo", |
| 127 | "ea", |
| 128 | "eos", |
| 129 | "erat", |
| 130 | "est", |
| 131 | "et", |
| 132 | "gubergren", |
| 133 | ] |
| 134 | return [np.random.choice(vocab) for _ in range(n_words)] |
| 135 | |
| 136 | |
| 137 | ####################################################################### |
no outgoing calls
no test coverage detected