コード例 #1
0
 def testStr2(self):
     tree=computeTree(data.give_john_smith())
     NamedEntityMerging(tree).merge()
     PrepositionMerging(tree).merge()
     self.maxDiff=None
     tree.sort()
     self.assertEqual(str(tree), data.give_john_smith_stringMerge())
コード例 #2
0
 def testNamedEntity1(self):
     tree=computeTree(data.give_john_smith())
     NamedEntityMerging(tree).merge()
     tree.sort()
     root=tree
     # Root
     self.assertEqual(root.wordList, [Word("ROOT", 0)])
     self.assertEqual(root.namedEntityTag, 'undef')
     self.assertEqual(root.dependency, 'undef')
     self.assertEqual(root.parent, None)
     self.assertEqual(len(root.child), 1)
     self.assertEqual(root.subtreeType, 'undef')
     self.assertEqual(root.dfsTag, 0)
     # Lives
     lives=root.child[0]
     self.assertEqual(lives.wordList, [Word("lives", 3, 'VBZ')])
     self.assertEqual(lives.namedEntityTag, 'undef')
     self.assertEqual(lives.dependency, 'ROOT')
     self.assertEqual(lives.parent, tree)
     self.assertEqual(len(lives.child), 2)
     self.assertEqual(lives.subtreeType, 'undef')
     self.assertEqual(lives.dfsTag, 0)
     # John Smith
     smith=lives.child[0]
     self.assertEqual(smith.wordList, [Word("John", 1, 'NNP'), Word("Smith", 2, 'NNP')])
     self.assertEqual(smith.namedEntityTag, 'PERSON')
     self.assertEqual(smith.dependency, 'nsubj')
     self.assertEqual(smith.parent, lives)
     self.assertEqual(len(smith.child), 0)
     self.assertEqual(smith.subtreeType, 'undef')
     self.assertEqual(smith.dfsTag, 0)
     # United Kingdom
     kingdom=lives.child[1]
     self.assertEqual(kingdom.wordList, [Word("United", 6, 'NNP'), Word("Kingdom", 7, 'NNP')])
     self.assertEqual(kingdom.namedEntityTag, 'LOCATION')
     self.assertEqual(kingdom.dependency, 'prep_in')
     self.assertEqual(kingdom.parent, lives)
     self.assertEqual(len(kingdom.child), 1)
     self.assertEqual(kingdom.subtreeType, 'undef')
     self.assertEqual(kingdom.dfsTag, 0)
     # The
     the=kingdom.child[0]
     self.assertEqual(the.wordList, [Word("the", 5, 'DT')])
     self.assertEqual(the.namedEntityTag, 'undef')
     self.assertEqual(the.dependency, 'det')
     self.assertEqual(the.parent, kingdom)
     self.assertEqual(len(the.child), 0)
     self.assertEqual(the.subtreeType, 'undef')
     self.assertEqual(the.dfsTag, 0)
コード例 #3
0
 def testStr1(self):
     tree = computeTree(data.give_john_smith())
     self.maxDiff = None
     tree.sort()
     self.assertEqual(str(tree), data.give_john_smith_string())
コード例 #4
0
 def testStr1(self):
     tree=computeTree(data.give_john_smith()['sentences'][0])
     self.maxDiff=None
     tree.sort()
     self.assertEqual(str(tree), data.give_john_smith_string())