Esempio n. 1
0
def test_extension_relations():
    # default mode
    assert wn.synset('test-en-0007-v').hypernyms() == [
        wn.synset('test-en-ext-0009-v')
    ]
    assert wn.synset('test-en-ext-0009-v').hyponyms() == [
        wn.synset('test-en-0007-v')
    ]
    assert wn.sense('test-en-information-n-0001-01').get_related(
        'pertainym') == [wn.sense('test-en-ext-info-n-0001-01')]
    assert wn.sense('test-en-ext-info-n-0001-01').get_related('pertainym') == [
        wn.sense('test-en-information-n-0001-01')
    ]

    # restricted to base
    w = wn.Wordnet(lexicon='test-en')
    assert w.synset('test-en-0007-v').hypernyms() == []
    assert w.sense('test-en-information-n-0001-01').get_related(
        'pertainym') == []

    # base and extension
    w = wn.Wordnet(lexicon='test-en test-en-ext')
    assert w.synset('test-en-0007-v').hypernyms() == [
        w.synset('test-en-ext-0009-v')
    ]
    assert w.synset('test-en-ext-0009-v').hyponyms() == [
        w.synset('test-en-0007-v')
    ]
    assert w.sense('test-en-information-n-0001-01').get_related(
        'pertainym') == [w.sense('test-en-ext-info-n-0001-01')]
    assert w.sense('test-en-ext-info-n-0001-01').get_related('pertainym') == [
        w.sense('test-en-information-n-0001-01')
    ]

    # restricted to extension
    w = wn.Wordnet(lexicon='test-en-ext')
    assert w.synset('test-en-ext-0009-v').hyponyms() == []
    assert w.sense('test-en-ext-info-n-0001-01').get_related('pertainym') == []
Esempio n. 2
0
def test_sense_mini():
    assert wn.sense('test-es-información-n-0001-01')
    assert wn.sense('test-es-información-n-0001-01', lang='es')
    assert wn.sense('test-es-información-n-0001-01', lexicon='test-es')
    with pytest.raises(wn.Error):
        assert wn.sense('test-es-información-n-0001-01', lang='en')
    with pytest.raises(wn.Error):
        assert wn.sense('test-es-información-n-0001-01', lexicon='test-en')
    with pytest.raises(wn.Error):
        assert wn.sense('test-es-información-n-0001-01', lang='unk')
    with pytest.raises(wn.Error):
        assert wn.sense('test-es-información-n-0001-01', lexicon='test-unk')
Esempio n. 3
0
def test_sense_translate():
    assert len(
        wn.sense('test-en-information-n-0001-01').translate(lang='es')) == 1
    assert len(
        wn.sense('test-es-información-n-0001-01').translate(lang='en')) == 1
Esempio n. 4
0
def test_sense_frames():
    assert wn.sense('test-en-illustrate-v-0004-01').frames() == [
        'Somebody ----s something',
        'Something ----s something',
    ]
    assert wn.sense('test-es-ilustrar-v-0004-01').frames() == []
Esempio n. 5
0
def test_sense_lexicalized():
    assert wn.sense('test-en-information-n-0001-01').lexicalized()
    assert wn.sense('test-es-información-n-0001-01').lexicalized()
Esempio n. 6
0
def test_sense_examples():
    assert wn.sense('test-en-information-n-0001-01').examples() == []
    assert wn.sense('test-es-información-n-0001-01').examples() == []
Esempio n. 7
0
def test_sense_synset():
    assert (wn.sense('test-en-information-n-0001-01').synset() == wn.synset(
        'test-en-0001-n'))
    assert (wn.sense('test-es-información-n-0001-01').synset() == wn.synset(
        'test-es-0001-n'))
Esempio n. 8
0
def test_sense_word():
    assert (wn.sense('test-en-information-n-0001-01').word() == wn.word(
        'test-en-information-n'))
    assert (wn.sense('test-es-información-n-0001-01').word() == wn.word(
        'test-es-información-n'))
Esempio n. 9
0
def test_sense_empty():
    with pytest.raises(wn.Error):
        assert wn.sense('test-es-información-n-0001-01')