Exemple #1
0
    def test_pos(self):

        self.assertEqual(len(POS.list()), 2)
        for n in ('tnt', 'stanford'):
            self.assertEqual(isinstance(POS.pos(n), POS), True)

        txt = "This is center of Amsterdam !"
        n = POS.pos("stanford", 'en')(txt)
        
        self.assertEqual(len(n), len(txt.split()))
        self.validate_tokens(txt, n)
        self.assertEqual((n[-1][3] & Token.POS_PUNCT) > 0, True)
        self.assertEqual((n[-2][3] & Token.POS_NOUN) > 0, True)
        self.assertEqual((n[-2][3] & Token.POS_PUNCT) > 0, False)
    
        import platform
        if platform.platform().lower().find("linux") >= 0:
            txt = "Dat is de center."
            def test_lang(): POS.pos("tnt", 'en')
            self.assertRaises(AssertionError, test_lang)
            n = POS.pos("tnt", 'nl')(txt)
            self.assertEqual(len(n), 5)
            self.validate_tokens(txt, n)
            self.assertEqual((n[-1][3] & Token.POS_PUNCT) > 0, True)
            self.assertEqual((n[-2][3] & Token.POS_NOUN) > 0, True)
            self.assertEqual((n[-2][3] & Token.POS_PUNCT) > 0, False)
            self.assertEqual((n[-3][3] & Token.POS_ART) > 0, True)
        else:
            print "Skip testing TNT POS tagger. It is possible on Linux platform only."
Exemple #2
0
 def test_lang(): POS.pos("tnt", 'en')
 self.assertRaises(AssertionError, test_lang)