MCPcopy Index your code
hub / github.com/clips/pattern / test_synset

Method test_synset

test/test_en.py:981–1003  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

979 print "pattern.en.wordnet.synsets()"
980
981 def test_synset(self):
982 v = en.wordnet.synsets("puma")[0]
983 # Assert Synset(id).
984 self.assertEqual(v, en.wordnet.Synset(v.id))
985 self.assertEqual(v.pos, en.wordnet.NOUN)
986 self.assertAlmostEqual(v.ic, 9.7, places=1)
987 self.assertTrue("cougar" in v.synonyms) # ["cougar", "puma", "catamount", ...]
988 self.assertTrue("feline" in v.gloss) # "large American feline resembling a lion"
989 # Assert WordNet relations.
990 s = en.wordnet.synsets
991 v = s("tree")[0]
992 self.assertTrue(v.hypernym in v.hypernyms())
993 self.assertTrue(s("woody plant")[0] in v.hypernyms())
994 self.assertTrue(s("entity")[0] in v.hypernyms(recursive=True))
995 self.assertTrue(s("beech")[0] in v.hyponyms())
996 self.assertTrue(s("red beech")[0] in v.hyponyms(recursive=True))
997 self.assertTrue(s("trunk")[0] in v.meronyms())
998 self.assertTrue(s("forest")[0] in v.holonyms())
999 # Assert Lin-similarity.
1000 self.assertTrue(
1001 v.similarity(s("flower")[0]) <
1002 v.similarity(s("teapot")[0]))
1003 print "pattern.en.wordnet.Synset"
1004
1005 def test_ancenstor(self):
1006 # Assert least-common-subsumer algorithm.

Callers

nothing calls this directly

Calls 6

sFunction · 0.85
hypernymsMethod · 0.80
hyponymsMethod · 0.80
meronymsMethod · 0.80
holonymsMethod · 0.80
similarityMethod · 0.45

Tested by

no test coverage detected