I read a text file containing list of words with their tags and put them as an ArrayList in an a wrapping ArrayList (ArrayList).
[[1, that, that, that, DT, DT], [2, table, table, table, NN, NN]]
Now I want to write the in a text file in a same format as follows:
1 that that that DT DT
2 table table table NN NN
each of the above rows is an ArrayList with 6 columns.
the following code return a file with Ԁ inside.
public void setPPOSOfWordInDevelopmentList(ArrayList<ArrayList> trainingList){
try{
FileOutputStream streamFile = new FileOutputStream("developmentFile.txt");
ObjectOutputStream streamFileWriter = new ObjectOutputStream(streamFile);
for(ArrayList word: developmentWordsList){
String inputWord = (String)word.get(1);
extractTag(inputWord,trainingList);
String extractedPPOSofWord =(String)findMaxTag().get(1);
word.set(5, extractedPPOSofWord);
}
streamFileWriter.close();
System.out.println(developmentWordsList);
}
catch(Exception e){
System.out.println("Something went wrong, check the code");
}
}
this code is coupled with some others so it is not easy to change the format of objects returned by the functions.