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') == []
def test_synset_mini(): assert wn.synset('test-es-0001-n') assert wn.synset('test-es-0001-n', lang='es') assert wn.synset('test-es-0001-n', lexicon='test-es') with pytest.raises(wn.Error): assert wn.synset('test-es-0001-n', lang='en') with pytest.raises(wn.Error): assert wn.synset('test-es-0001-n', lexicon='test-en') with pytest.raises(wn.Error): assert wn.synset('test-es-0001-n', lang='unk') with pytest.raises(wn.Error): assert wn.synset('test-es-0001-n', lexicon='test-unk')
def test_synset_examples(): assert wn.synset('test-en-0001-n').examples() == ['"this is information"'] assert wn.synset('test-es-0001-n').examples() == [ '"este es la informaciĆ³n"' ]
def test_synset_definition(): assert wn.synset('test-en-0001-n').definition() == 'something that informs' assert wn.synset('test-es-0001-n').definition() == 'algo que informa'
def test_synset_lemmas(): assert wn.synset('test-en-0003-v').lemmas() == ['exemplify', 'illustrate'] assert wn.synset('test-es-0003-v').lemmas() == ['ejemplificar', 'ilustrar']
def test_synset_words(): assert len(wn.synset('test-en-0003-v').words()) == 2 assert len(wn.synset('test-es-0003-v').words()) == 2
def test_synset_senses(): assert len(wn.synset('test-en-0003-v').senses()) == 2 assert len(wn.synset('test-es-0003-v').senses()) == 2
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'))
def test_synset_translate(): assert len(wn.synset('test-en-0001-n').translate(lang='es')) == 1 assert len(wn.synset('test-es-0001-n').translate(lang='en')) == 1
def test_synset_lexicalized(): assert wn.synset('test-en-0001-n').lexicalized() assert wn.synset('test-es-0001-n').lexicalized()
def test_synset_hypernyms_expand_default(): assert wn.synset('test-es-0002-n').hypernyms() == [ wn.synset('test-es-0001-n') ] assert wn.synset('test-es-0001-n').hypernyms() == []
def test_synset_hypernyms(): assert wn.synset('test-en-0002-n').hypernyms() == [ wn.synset('test-en-0001-n') ] assert wn.synset('test-en-0001-n').hypernyms() == []
def test_synset_empty(): with pytest.raises(wn.Error): assert wn.synset('test-es-0001-n')