I have a file called my-training.train
. (.train is the extension for the training files in open-nlp
). The file is already populated with some data:
Refund What is the refund status for my order #342? Can I place a refund request for electronics?
NewOffers Are there any new offers for your products? Is there any new offer on buying worth 5000?
Refund Can I place a refund request for electronics?
NewOffers Is there any new offer on buying worth 5000?
Refund What is the refund status for my order #343? Can I place a refund request for electronics?
NewOffers Are there any new offers for your products? Is there any new offer on buying worth 5000?
Refund Can I place a refund request for electronics?
NewOffers Are there any new offers?
I want to append a sentence to it on the very next line, programmatically. This is the code that I have written:
Writer output;
output = new BufferedWriter(new FileWriter("my-training.train",true));
output.append("NewOffers Please inform me of the new offers");
output.close();
the sentence gets inserted as intended. Showing the last three lines of the training file:
Refund Can I place a refund request for electronics?
NewOffers Are there any new offers?
NewOffers Please inform me of the new offers
But when I run the code again, the sentence gets inserted to the next of the previous sentence instead of the new line. (The last three lines):
Refund Can I place a refund request for electronics?
NewOffers Are there any new offers?
NewOffers Please inform me of the new offersNewOffers Please inform me of the new offers
In the above code, I replace the line output.append("NewOffers Please inform me of the new offers");
with output.append("\nNewOffers Please inform me of the new offers");
, but using that it creates a problem for the very first time append.
Getting the initial file my-training.train
, this is how the last three lines become:
Refund Can I place a refund request for electronics?
NewOffers Are there any new offers?
NewOffers Please inform me of the new offers
The empty line gets inserted. This makes the training file invalid. There should be no empty line, and each sentence should be inserted in the new line.
Why is this discriminating behavior between the first line and the others.? What wrong am I doing?