title: Read randomly sentences from nltk corpus
body: <p>I'm working on my university project and I have to read randomly 50 sentences from a NLTK Corpus (SemCor).</p>
  <p>Currently I was only able to read the first 50 sentences as following:</p>
  <pre><code>from nltk.corpus import semcor as corpus
  
  def get_sentence_from_semcor(sentence_num):
     sentence = &quot; &quot;.join(corpus.sents()[sentence_num])
     tags = corpus.tagged_sents(tag=&quot;sem&quot;)[sentence_num]
     for curr_word in range(len(tags)):
           if isinstance(tags[curr_word], nltk.Tree) and isinstance(tags[curr_word][0], str) and isinstance(tags[curr_word].label(), nltk.corpus.reader.wordnet.Lemma):
               word = tags[curr_word][0]
               target = tags[curr_word].label().synset()
               sentence_no_word = sentence.replace(word, &quot;&quot;)
     return word, sentence_no_word, target
  
     corpus_sentences = [get_sentence_from_semcor(i) for i in range(50)]
  </code></pre>
  <p>Any Help on how I could select randomly 50 sentences of the corpus?</p>