public static void filterFields ( File trainingCorpus , File newRawFile , int [ ] fieldsToKeep ) throws IOException { FileTrainingCorpus ftc = new FileTrainingCorpus ( trainingCorpus ) ; Writer writer = new BufferedWriter ( new FileWriter ( newRawFile ) ) ; Iterator < Document > iterator = ftc . iterator ( ) ; while ( iterator . hasNext ( ) ) { MultiFieldDocument doc = ( MultiFieldDocument ) iterator . next ( ) ; String representation = doc . getStringSerialization ( fieldsToKeep ) ; writer . write ( representation ) ; } writer . close ( ) ; }
rewrite a raw file so that only a subset of the fields are kept