def test_spans_default_sentiment(en_tokenizer):
 text = u'good stuff bad stuff'
 tokens = en_tokenizer(text)
 tokens.vocab[tokens[0].text].sentiment = 3.0
 tokens.vocab[tokens[2].text].sentiment = (-2.0)
 doc = get_doc(tokens.vocab, [t.text for t in tokens])
 assert (doc[:2].sentiment == (3.0 / 2))
 assert (doc[(-2):].sentiment == ((-2.0) / 2))
 assert (doc[:(-1)].sentiment == ((3.0 + (-2)) / 3.0))

def test_spans_default_sentiment ( en_tokenizer ) : text = u'good stuff bad stuff' tokens = en_tokenizer ( text ) tokens . vocab [ tokens [ 0 ] . text ] . sentiment = 3.0 tokens . vocab [ tokens [ 2 ] . text ] . sentiment = ( - 2.0 ) doc = get_doc ( tokens . vocab , [ t . text for t in tokens ] ) assert ( doc [ : 2 ] . sentiment == ( 3.0 / 2 ) ) assert ( doc [ ( - 2 ) : ] . sentiment == ( ( - 2.0 ) / 2 ) ) assert ( doc [ : ( - 1 ) ] . sentiment == ( ( 3.0 + ( - 2 ) ) / 3.0 ) )
test span .