Esempio n. 1
0
def test_cat_and_dog_reduced_to_animal():
    c1 = Classification(0.4, Label('02096294-n', 'australian terrier', ''))
    c2 = Classification(0.4, Label('02123045-n', 'tabby, tabby cat', ''))

    node = Hierarchy(0.7).place([c1, c2])

    assert node == animal_node
Esempio n. 2
0
def test_terrier_reduced_to_dog():
    c1 = Classification(0.4, Label('02096294-n', 'australian terrier', ''))
    # toy terrier is not actually a terrier breed, so does not exist as a 'terrier'
    c2 = Classification(0.4, Label('02087046-n', 'toy terrier', ''))

    node = Hierarchy(0.7).place([c1, c2])

    assert node == dog_node
Esempio n. 3
0
def test_terrier_groups_terrier_combination():
    # multiple classifications of terrier breeds should sum
    # to be 80% accuracy, result should be 'terrier'
    c1 = Classification(0.4, Label('02096294-n', 'australian terrier', ''))
    c2 = Classification(0.35, Label('02097658-n', 'silky terrier', ''))
    c3 = Classification(0.05, Label('02094433-n', 'yorkshire terrier', ''))

    node = Hierarchy(0.7).place([c1, c2, c3])

    assert node == terrier_node
Esempio n. 4
0
def test_terrier_groups_terrier():
    # 80% accuracy on 70% hierarchy should group in 'terrier'
    label = Label('02096294-n', 'australian terrier', '')
    c = Classification(0.8, label)
    node = Hierarchy(0.7).place([c])

    assert node == terrier_node
Esempio n. 5
0
def test_non_matching_group():
    c = Classification(0.8, Label('04465501-n', 'tractor', ''))

    node = Hierarchy(0.7).place([c])

    assert node is None
Esempio n. 6
0
def test_high_accuracy_hierarchy():
    c = Classification(0.85, Label('02096294-n', 'australian terrier', ''))

    node = Hierarchy(0.9).place([c])

    assert node is None
Esempio n. 7
0
def test_piano_is_instrument():
    piano = Label('04515003-n', 'upright, upright piano', '')
    instrument = wordnet.synsets('musical_instrument')[0]

    assert piano.is_a(instrument)
Esempio n. 8
0
def test_dog_is_cat():
    dog = Label('02099601-n', 'golden retriever', '')
    cat = wordnet.of2ss('02123045-n')

    assert not dog.is_a(cat)
Esempio n. 9
0
def test_cat_is_animal():
    cat = Label('02123045-n', 'tabby, tabby cat', '')
    animal = wordnet.synsets('animal')[0]

    assert cat.is_a(animal)