docs: def train(self, sentences, nr_iter=5):
          """Train a model from sentences.
  
          :param sentences: A list of sentences, each of which is a list of (token, tag) tuples.
          :param nr_iter: Number of training iterations.
          """
          self._make_tagdict(sentences)
          self.perceptron.classes = self.classes
          for iter_ in range(nr_iter):
              c = 0
              n = 0
              for sentence in sentences:
                  prev, prev2 = self.START
                  context = [t[0] for t in sentence]
                  for i, (token, tag) in enumerate(sentence):
                      guess = self.tagdict.get(token)
                      if not guess:
                          feats = self._get_features(i, context, prev, prev2)
                          guess = self.perceptron.predict(feats)
                          self.perceptron.update(tag, guess, feats)
                      prev2 = prev
                      prev = guess
                      c += guess == tag
                      n += 1
              random.shuffle(sentences)
              log.debug('Iter %s: %s/%s=%s' % (iter_, c, n, (float(c) / n) * 100))
          self.perceptron.average_weights()