2014-09-02 01:27:31 +04:00
|
|
|
import py.test
|
|
|
|
|
|
|
|
from spacy.orth import non_sparse
|
|
|
|
import math
|
|
|
|
|
|
|
|
|
|
|
|
def test_common_case_upper():
|
2014-10-29 15:19:38 +03:00
|
|
|
cases = {'u': 0.7, 'l': 0.2, 't': 0.1}
|
2014-09-02 01:27:31 +04:00
|
|
|
prob = math.log(0.1)
|
2014-10-29 15:19:38 +03:00
|
|
|
assert non_sparse('usa', prob, 0, cases['u'], cases['t'], cases['l']) == 'USA'
|
2014-09-02 01:27:31 +04:00
|
|
|
|
|
|
|
def test_same():
|
2014-10-29 15:19:38 +03:00
|
|
|
cases = {'u': 0.01, 't': 0.09, 'l': 0.9}
|
2014-09-02 01:27:31 +04:00
|
|
|
prob = math.log(0.5)
|
2014-10-29 15:19:38 +03:00
|
|
|
assert non_sparse('the', prob, 0, cases['u'], cases['t'], cases['l']) == 'the'
|
2014-09-02 01:27:31 +04:00
|
|
|
|
|
|
|
def test_common_case_lower():
|
|
|
|
prob = math.log(0.5)
|
2014-10-29 15:19:38 +03:00
|
|
|
cases = {'u': 0.01, 't': 0.09, 'l': 0.9}
|
|
|
|
assert non_sparse('The', prob, 0, cases['u'], cases['t'], cases['l']) == 'the'
|
2014-09-02 01:27:31 +04:00
|
|
|
|
|
|
|
def test_shape():
|
|
|
|
prob = math.log(0.00001)
|
2014-10-29 15:19:38 +03:00
|
|
|
cases = {'u': 0.0, 't': 0.0, 'l': 0.0}
|
|
|
|
assert non_sparse('1999', prob, 0, cases['u'], cases['t'], cases['l']) == 'dddd'
|