def test_spans_override_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])
 doc.user_span_hooks[u'sentiment'] = (lambda span: 10.0)
 assert (doc[:2].sentiment == 10.0)
 assert (doc[(-2):].sentiment == 10.0)
 assert (doc[:(-1)].sentiment == 10.0)

def test_spans_override_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 ] ) doc . user_span_hooks [ u'sentiment' ] = ( lambda span : 10.0 ) assert ( doc [ : 2 ] . sentiment == 10.0 ) assert ( doc [ ( - 2 ) : ] . sentiment == 10.0 ) assert ( doc [ : ( - 1 ) ] . sentiment == 10.0 )
test span .