#NEWLINE# def features( sentence , i ) : #NEWLINE# #INDENT# "Features for i'th token in sentence.\n\n    Currently baseline named-entity recognition features, but these can\n    easily be changed to do POS tagging or chunking.\n    " #NEWLINE# word = sentence [ i ] #NEWLINE# ( yield ( 'word:{}' + word . lower ( ) ) ) #NEWLINE# if word [ 0 ] . isupper ( ) : #NEWLINE# #INDENT# ( yield 'CAP' ) #NEWLINE# #UNINDENT# if ( word > 0 ) : #NEWLINE# #INDENT# ( yield ( 'word-1:{}' + sentence [ ( i - 1 ) ] . lower ( ) ) ) #NEWLINE# if ( i > 1 ) : #NEWLINE# #INDENT# ( yield ( 'word-2:{}' + sentence [ ( i - 2 ) ] . lower ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( i + 1 ) < len ( sentence ) ) : #NEWLINE# #INDENT# ( yield ( 'word+1:{}' + sentence [ ( i + 1 ) ] . lower ( ) ) ) #NEWLINE# if ( ( i + 2 ) < len ( sentence ) ) : #NEWLINE# #INDENT# ( yield ( 'word+2:{}' + sentence [ ( i + 2 ) ] . lower ( ) ) )