From bc460de171cd66bfab47d79a3a2f64842524a32d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 25 Sep 2014 18:29:42 +0200 Subject: [PATCH] * Add extra tests --- tests/test_lexeme_flags.py | 25 +++++++++++++++++++++++++ tests/test_string_loading.py | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/test_lexeme_flags.py create mode 100644 tests/test_string_loading.py diff --git a/tests/test_lexeme_flags.py b/tests/test_lexeme_flags.py new file mode 100644 index 000000000..4818c33b1 --- /dev/null +++ b/tests/test_lexeme_flags.py @@ -0,0 +1,25 @@ +from __future__ import unicode_literals + +import pytest + +from spacy.en import * + + +def test_is_alpha(): + the = EN.lookup('the') + assert the.check_flag(EN.fl_is_alpha) + year = EN.lookup('1999') + assert not year.check_flag(EN.fl_is_alpha) + mixed = EN.lookup('hello1') + assert not mixed.check_flag(EN.fl_is_alpha) + + +def test_is_digit(): + the = EN.lookup('the') + assert not the.check_flag(EN.fl_is_digit) + year = EN.lookup('1999') + assert year.check_flag(EN.fl_is_digit) + mixed = EN.lookup('hello1') + assert not mixed.check_flag(EN.fl_is_digit) + + diff --git a/tests/test_string_loading.py b/tests/test_string_loading.py new file mode 100644 index 000000000..5efcf7f9b --- /dev/null +++ b/tests/test_string_loading.py @@ -0,0 +1,16 @@ +"""Test suspected freeing of strings""" +from __future__ import unicode_literals + +import pytest + +from spacy.en import EN + + +def test_one(): + tokens = EN.tokenize('Betty Botter bought a pound of butter.') + assert tokens.string(0) == 'Betty' + tokens2 = EN.tokenize('Betty also bought a pound of butter.') + assert tokens2.string(0) == 'Betty' + + +