2016-05-04 23:31:58 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from spacy.attrs import *
|
|
|
|
|
|
|
|
|
|
|
|
def test_lexeme_eq(en_vocab):
|
|
|
|
'''Test Issue #361: Equality of lexemes'''
|
|
|
|
cat1 = en_vocab['cat']
|
|
|
|
|
2016-09-30 18:11:01 +00:00
|
|
|
cat2 = en_vocab['cat']
|
2016-05-04 23:31:58 +00:00
|
|
|
|
2016-09-30 18:11:01 +00:00
|
|
|
assert cat1 == cat2
|
2016-05-04 23:31:58 +00:00
|
|
|
|
|
|
|
def test_lexeme_neq(en_vocab):
|
|
|
|
'''Inequality of lexemes'''
|
|
|
|
cat = en_vocab['cat']
|
|
|
|
|
|
|
|
dog = en_vocab['dog']
|
|
|
|
|
|
|
|
assert cat != dog
|
|
|
|
|
|
|
|
def test_lexeme_lt(en_vocab):
|
|
|
|
'''More frequent is l.t. less frequent'''
|
|
|
|
noun = en_vocab['NOUN']
|
|
|
|
|
|
|
|
opera = en_vocab['opera']
|
|
|
|
|
|
|
|
assert noun < opera
|
|
|
|
assert opera > noun
|
|
|
|
|
2016-09-27 11:22:30 +00:00
|
|
|
|
|
|
|
def test_lexeme_hash(en_vocab):
|
|
|
|
'''Test that lexemes are hashable.'''
|
|
|
|
phantom = en_vocab['phantom']
|
|
|
|
|
|
|
|
opera = en_vocab['opera']
|
|
|
|
|
|
|
|
lexes = {phantom: phantom, opera: opera}
|
|
|
|
assert lexes[phantom].orth_ == 'phantom'
|
|
|
|
assert lexes[opera].orth_ == 'opera'
|