From 7441ca30eeb9e57a65ffc59ad9f31bbbe167cd5f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 5 May 2016 01:31:58 +0200 Subject: [PATCH] * Add tests for Issue #361: Lexeme rich comparison --- spacy/tests/vocab/test_lexeme.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spacy/tests/vocab/test_lexeme.py diff --git a/spacy/tests/vocab/test_lexeme.py b/spacy/tests/vocab/test_lexeme.py new file mode 100644 index 000000000..7c5c5d27d --- /dev/null +++ b/spacy/tests/vocab/test_lexeme.py @@ -0,0 +1,33 @@ +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'] + + cat2 = en_vocab['cat'] + + assert cat1 == cat2 + +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'] + + print(noun.orth, opera.orth) + assert noun < opera + assert opera > noun +