def testTreePos(self): n = DependenciesTree('foo', 1) n.wordList += [Word('eat', 2, 'VB'), Word('bar', 3)] self.assertTrue(n.isVerb()) self.assertFalse(n.isNoun()) n = DependenciesTree('foo', 1) n.wordList += [Word('broomstick', 2, 'NN'), Word('bar', 3)] self.assertFalse(n.isVerb()) self.assertTrue(n.isNoun())
def testBasicTreeConstructor(self): n = DependenciesTree('foo', 1) self.assertEqual(n.wordList, [Word('foo', 1)]) self.assertEqual(n.namedEntityTag, 'undef') self.assertEqual(n.dependency, 'undef') self.assertEqual(n.child, []) self.assertEqual(n.text, "") self.assertEqual(n.parent, None) self.assertEqual(n.subtreeType, 'undef') self.assertEqual(n.dfsTag, 0) self.assertFalse(n.isVerb()) self.assertFalse(n.isNoun()) n.appendWord('bar') self.assertEqual(str(DependenciesTree('foo bar', 1)), str(n))