Buggy code:
Map < String , Float > clusterWeights = new HashMap < String , Float > ( ) ; for ( Map . Entry < Integer , Set < Integer > > entry : clusterEvents . entrySet ( ) ) { if ( CollectionUtils . isEmpty ( entry . getValue ( ) ) ) { continue ; } Set < String > filenames4ClusterWeight = new HashSet < String > ( ) ; List < Double [ ] > vectorsInCluster = new ArrayList < Double [ ] > ( ) ; for ( Integer eventNum : entry . getValue ( ) ) { NumedEventWithPhrase numedEventWithPhrase = eventWithNums . get ( eventNum ) ; vectorsInCluster . add ( numedEventWithPhrase . getVec ( ) ) ; filenames4ClusterWeight . add ( numedEventWithPhrase . getEvent ( ) . getFilename ( ) ) ; } clusterWeights . put ( ( ( ChineseWhispersCluster . CLASS_PREFIX ) + ( entry . getKey ( ) ) ) , ( ( float ) ( filenames4ClusterWeight . size ( ) ) ) ) ; Double [ ] centralVec = VectorOperator . centralVector ( vectorsInCluster ) ; if ( centralVec == null ) { this . log . error ( ( ( "[" + ( entry . getKey ( ) ) ) + "]Calculate<seq2seq4repair_space>central<seq2seq4repair_space>vector<seq2seq4repair_space>error!" ) ) ; continue ; } Integer clusterId = entry . getKey ( ) ; List < List < Word > > subSentences = new ArrayList < List < Word > > ( ) ; List < List < Word > > subSynSentences = new ArrayList < List < Word > > ( ) ; List < Pair < NumedEventWithPhrase , Double > > eventWeights = new ArrayList < Pair < NumedEventWithPhrase , Double > > ( ) ; for ( Integer eventId : entry . getValue ( ) ) { NumedEventWithPhrase numedEventWithPhrase = eventWithNums . get ( eventId ) ; EventWithPhrase eventWithPhrase = numedEventWithPhrase . getEvent ( ) ; double eventWeight = VectorOperator . cosineDistence ( centralVec , numedEventWithPhrase . getVec ( ) ) ; eventWeights . add ( new Pair < NumedEventWithPhrase , Double > ( numedEventWithPhrase , eventWeight ) ) ; Tree tree = syntacticTrees . get ( eventWithPhrase . getFilename ( ) ) . get ( ( ( eventWithPhrase . getSentNum ( ) ) - 1 ) ) ; List < String > subSentList = new ArrayList < String > ( ) ; this . subSentences ( tree , subSentList ) ; String subSentence = this . eventToSubSentence ( eventWithPhrase , subSentList ) ; List < Word > words = texts . get ( eventWithPhrase . getFilename ( ) ) . get ( ( ( eventWithPhrase . getSentNum ( ) ) - 1 ) ) ; List < Word > subObjSentence = this . sentenceObjectified ( subSentence , words ) ; if ( CollectionUtils . isNotEmpty ( subObjSentence ) ) { subSentences . add ( subObjSentence ) ; } List < Word > subSynObjSentence = this . synonymReplacement ( subObjSentence , selectedWordsKey ) ; if ( CollectionUtils . isNotEmpty ( subSynObjSentence ) ) { subSynSentences . add ( subSynObjSentence ) ; } } clusterEventWeihts . put ( clusterId , eventWeights ) ; clusterSubSentence . put ( clusterId , subSentences ) ; clusterSubSentenceAfterSynonymReplacement . put ( clusterId , subSynSentences ) ; } String workDir = this . nodeFilePath . substring ( 0 , this . nodeFilePath . indexOf ( DIR_NODES ) ) ; String filename = this . nodeFilePath . substring ( Math . max ( this . nodeFilePath . lastIndexOf ( "//" ) , this . nodeFilePath . lastIndexOf ( "\\" ) ) ) . replace ( "node.obj" , "txt" ) ; <START_BUG> File clusterWeightsFile = FileUtils . getFile ( ( ( workDir + '//' ) + ( SystemConstant . DIR_CLUSTER_WEIGHT ) ) , ( ( filename + "." ) + ( SystemConstant . OBJ ) ) ) ; <END_BUG> try { this . log . info ( ( ( "Serilizing<seq2seq4repair_space>cluster<seq2seq4repair_space>weight<seq2seq4repair_space>to<seq2seq4repair_space>file[" + ( clusterWeightsFile . getAbsolutePath ( ) ) ) + "]" ) ) ; SerializeUtil . writeObj ( clusterWeights , clusterWeightsFile ) ; } catch ( IOException e ) { this . log . error ( ( ( "Serilizing<seq2seq4repair_space>cluster<seq2seq4repair_space>weight<seq2seq4repair_space>to<seq2seq4repair_space>file[" + ( clusterWeightsFile . getAbsolutePath ( ) ) ) + "]<seq2seq4repair_space>error!" ) , e ) ; throw e ; } StringBuilder sbClustedSentences = new StringBuilder ( ) ; StringBuilder taggedClustedSentences = new StringBuilder ( ) ; StringBuilder taggedWeightedClustedSentences = new StringBuilder ( ) ; for ( Map . Entry < Integer , List < List < Word > > > entry : clusterSubSentence . entrySet ( ) ) { if ( ( CollectionUtils . isEmpty ( entry . getValue ( ) ) ) || ( ( entry . getValue ( ) . size ( ) ) < 5 ) ) { continue ; } List < Pair < NumedEventWithPhrase , Double > > pairs = clusterEventWeihts . get ( entry . getKey ( ) ) ; sbClustedSentences . append ( ( ( ( ( ChineseWhispersCluster . CLASS_PREFIX ) + ( entry . getKey ( ) ) ) + ":" ) + ( SystemConstant . LINE_SPLITER ) ) ) ; taggedClustedSentences . append ( ( ( ( ( ChineseWhispersCluster . CLASS_PREFIX ) + ( entry . getKey ( ) ) ) + ":" ) + ( SystemConstant . LINE_SPLITER ) ) ) ; taggedWeightedClustedSentences . append ( ( ( ( ( ChineseWhispersCluster . CLASS_PREFIX ) + ( entry . getKey ( ) ) ) + ":" ) + ( SystemConstant . LINE_SPLITER ) ) ) ; for ( List < Word > words : entry . getValue ( ) ) { StringBuilder inner = new StringBuilder ( ) ; StringBuilder tagged = new StringBuilder ( ) ; StringBuilder weighted = new StringBuilder ( ) ; for ( Word word : words ) { Vector wordVec = vecDict . get ( word . dictKey ( ) ) ; double wordWeight = 0.0 ;

Fix:
File clusterWeightsFile = FileUtils . getFile ( ( ( workDir + '//' ) + ( SystemConstant . DIR_CLUSTER_WEIGHT ) ) , filename . replaceAll ( "txt" , OBJ ) ) ;