MCPcopy Create free account
hub / github.com/clips/pattern / test_taxonomy

Method test_taxonomy

test/test_search.py:81–114  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

79 pass
80
81 def test_taxonomy(self):
82 # Assert Taxonomy search.
83 t = search.Taxonomy()
84 t.append("King Arthur", type="knight", value=1)
85 t.append("Sir Bedevere", type="knight", value=2)
86 t.append("Sir Lancelot", type="knight", value=3)
87 t.append("Sir Gallahad", type="knight", value=4)
88 t.append("Sir Robin", type="knight", value=5)
89 t.append("John Cleese", type="Sir Lancelot")
90 t.append("John Cleese", type="Basil Fawlty")
91 # Matching is case-insensitive, results are lowercase.
92 self.assertTrue("John Cleese" in t)
93 self.assertTrue("john cleese" in t)
94 self.assertEqual(t.classify("King Arthur"), "knight")
95 self.assertEqual(t.value("King Arthur"), 1)
96 self.assertEqual(t.parents("John Cleese"), ["basil fawlty", "sir lancelot"])
97 self.assertEqual(t.parents("John Cleese", recursive=True), [
98 "basil fawlty",
99 "sir lancelot",
100 "knight"])
101 self.assertEqual(t.children("knight"), [
102 "sir robin",
103 "sir gallahad",
104 "sir lancelot",
105 "sir bedevere",
106 "king arthur"])
107 self.assertEqual(t.children("knight", recursive=True), [
108 "sir robin",
109 "sir gallahad",
110 "sir lancelot",
111 "sir bedevere",
112 "king arthur",
113 "john cleese"])
114 print "pattern.search.Taxonomy"
115
116 def test_classifier(self):
117 # Assert taxonomy classifier + keyword arguments.

Callers

nothing calls this directly

Calls 5

appendMethod · 0.95
classifyMethod · 0.95
valueMethod · 0.95
parentsMethod · 0.95
childrenMethod · 0.95

Tested by

no test coverage detected