'Tests the HiddenMarkovModelTagger instance.
:param test_sequence: a sequence of labeled test instances
:type test_sequence: list(list)
:param verbose: boolean flag indicating whether training should be
verbose or include printed output
:type verbose: bool'

def test(self, test_sequence, verbose=False, **kwargs):

    def words(sent):
        return [word for (word, tag) in sent]
    def tags(sent):
        return [tag for (word, tag) in sent]
    def flatten(seq):
        return list(itertools.chain(*seq))
    test_sequence = self._transform(test_sequence)
    predicted_sequence = list(map(self._tag, map(words, test_sequence)))
    if verbose:
        for (test_sent, predicted_sent) in zip(test_sequence, predicted_sequence):
            print(u'Test:', u'    '.join(((u'%s/%s' % (token, tag)) for (token, tag) in test_sent)))
            print()
            print(u'Untagged:', u'    '.join(((u'%s' % token) for (token, tag) in test_sent)))
            print()
            print(u'HMM-tagged:', u'    '.join(((u'%s/%s' % (token, tag)) for (token, tag) in predicted_sent)))
            print()
            print(u'Entropy:', self.entropy([(token, None) for (token, tag) in predicted_sent]))
            print()
            print((u'-' * 60))
    test_tags = flatten(map(tags, test_sequence))
    predicted_tags = flatten(map(tags, predicted_sequence))
    acc = accuracy(test_tags, predicted_tags)
    count = sum((len(sent) for sent in test_sequence))
    print((u'accuracy    over    %d    tokens:    %.2f' % (count, (acc * 100))))
