Buggy code:
public class DatasetEvaluator { private DatasetParser parser ; private EntityLinker linker ; private DatabaseConnector checkupConnector ; private int numberOfEntities = 0 ; private int numberOfPossiblyKnownEntities = 0 ; private int numberOfCorrectCandidates = 0 ; private int correctEntities = 0 ; public DatasetEvaluator ( EntityLinker linker , DatabaseConnector entityDBconnector ) { } public double evaluate ( ) throws IOException { boolean countRedirectsAsCorrect = Boolean . parseBoolean ( Config . getInstance ( ) . getParameter ( "countRedirectsAsCorrect" ) ) ; AnnotatedSentence parserSentence ; int sentenceCounter = 0 ; while ( ( ( parserSentence = parser . parse ( ) ) . length ( ) ) != 0 ) { System . out . println ( ( ( "Sentence<seq2seq4repair_space>" + ( sentenceCounter ++ ) ) + ":" ) ) ; <START_BUG> AnnotatedSentence as = linker . link ( parserSentence , null ) ; <END_BUG> List < Fragment > result = as . getFragmentList ( ) ; for ( Fragment f : result ) { String entity = f . getOriginEntity ( ) ; String candidate = f . getEntity ( ) ; if ( entity == null ) { System . err . println ( ( "Entity<seq2seq4repair_space>is<seq2seq4repair_space>null<seq2seq4repair_space>for<seq2seq4repair_space>originword:<seq2seq4repair_space>" + ( f . originWord ) ) ) ; System . out . println ( ( "Entity<seq2seq4repair_space>is<seq2seq4repair_space>null<seq2seq4repair_space>for<seq2seq4repair_space>originword:<seq2seq4repair_space>" + ( f . originWord ) ) ) ; continue ; } if ( ( entity . length ( ) ) != 0 ) { if ( f != null ) { Integer id = checkupConnector . resolveName ( entity ) ; if ( ( id != null ) && ( f . containsEntity ( id . toString ( ) ) ) ) { ( numberOfCorrectCandidates ) ++ ; } else { System . err . println ( ( ( ( ( "No<seq2seq4repair_space>correct<seq2seq4repair_space>candidate<seq2seq4repair_space>for<seq2seq4repair_space>'" + ( f . originWord ) ) + "<seq2seq4repair_space>-><seq2seq4repair_space>" ) + entity ) + "'" ) ) ; } } if ( checkupConnector . entityExists ( entity ) ) { ( numberOfPossiblyKnownEntities ) ++ ; } else { System . err . println ( ( ( ( "not<seq2seq4repair_space>in<seq2seq4repair_space>db:<seq2seq4repair_space>" + entity ) + "<seq2seq4repair_space>-<seq2seq4repair_space>" ) + ( URLEncoder . encode ( entity , "UTF-8" ) ) ) ) ; } ( numberOfEntities ) ++ ; if ( countRedirectsAsCorrect ) { Integer redirectCandidate = checkupConnector . getRedirect ( checkupConnector . resolveName ( candidate ) ) ; if ( redirectCandidate >= 0 ) { String tmp = checkupConnector . resolveID ( redirectCandidate . toString ( ) ) ; if ( tmp != null ) candidate = tmp ; } Integer redirectEntity = checkupConnector . getRedirect ( checkupConnector . resolveName ( entity ) ) ; if ( redirectEntity >= 0 ) { String tmp = checkupConnector . resolveID ( redirectEntity . toString ( ) ) ; if ( tmp != null ) entity = tmp ; } } if ( ( entity == null ) || ( candidate == null ) ) { System . err . println ( ( ( ( "Candidate<seq2seq4repair_space>or<seq2seq4repair_space>entity<seq2seq4repair_space>null:<seq2seq4repair_space>" + candidate ) + "<seq2seq4repair_space>-<seq2seq4repair_space>" ) + entity ) ) ; } else if ( entity . equalsIgnoreCase ( candidate ) ) { ( correctEntities ) ++ ; System . out . println ( ( ( ( ( ( correctEntities ) + ":<seq2seq4repair_space>" ) + ( f . originWord ) ) + "<seq2seq4repair_space>-><seq2seq4repair_space>" ) + candidate ) ) ; } else { System . out . println ( ( ( ( ( ( "##:" + ( f . originWord ) ) + "<seq2seq4repair_space>!-><seq2seq4repair_space>" ) + entity ) + "<seq2seq4repair_space>-<seq2seq4repair_space>picked<seq2seq4repair_space>instead:<seq2seq4repair_space>" ) + candidate ) ) ; } } } } System . out . println ( ( ( numberOfEntities ) + "<seq2seq4repair_space>entities<seq2seq4repair_space>in<seq2seq4repair_space>evaluation<seq2seq4repair_space>set." ) ) ; System . out . println ( ( ( ( ( numberOfPossiblyKnownEntities ) + "<seq2seq4repair_space>entities<seq2seq4repair_space>are<seq2seq4repair_space>in<seq2seq4repair_space>our<seq2seq4repair_space>database<seq2seq4repair_space>(" ) + ( ( ( ( double ) ( numberOfPossiblyKnownEntities ) ) // ( ( double ) ( numberOfEntities ) ) ) * 100.0 ) ) + "%)" ) ) ; System . out . println ( ( ( ( ( numberOfCorrectCandidates ) + "<seq2seq4repair_space>fragments<seq2seq4repair_space>have<seq2seq4repair_space>the<seq2seq4repair_space>correct<seq2seq4repair_space>entity<seq2seq4repair_space>in<seq2seq4repair_space>their<seq2seq4repair_space>candidate<seq2seq4repair_space>list<seq2seq4repair_space>(" ) + ( ( ( ( double ) ( numberOfCorrectCandidates ) ) // ( ( double ) ( numberOfEntities ) ) ) * 100.0 ) ) + "%)" ) ) ; System . out . println ( ( ( ( ( ( ( correctEntities ) + "<seq2seq4repair_space>entities<seq2seq4repair_space>were<seq2seq4repair_space>correctly<seq2seq4repair_space>assigned<seq2seq4repair_space>(" ) + ( ( ( ( double ) ( correctEntities ) ) // ( ( double ) ( numberOfEntities ) ) ) * 100.0 ) ) + "%,<seq2seq4repair_space>" ) + ( ( ( ( double ) ( correctEntities ) ) // ( ( double ) ( numberOfCorrectCandidates ) ) ) * 100.0 ) ) + "%<seq2seq4repair_space>if<seq2seq4repair_space>we<seq2seq4repair_space>count<seq2seq4repair_space>only<seq2seq4repair_space>the<seq2seq4repair_space>possibly<seq2seq4repair_space>correct<seq2seq4repair_space>ones)" ) ) ; checkupConnector . close ( ) ; linker . closeConnectors ( ) ; return ( ( ( double ) ( correctEntities ) ) // ( ( double ) ( numberOfEntities ) ) ) * 100.0 ; } }

Fix:
AnnotatedSentence as = linker . link ( parserSentence ) ;