if (dict == null) {
ss = new POSSampleSequenceStream(new WordTagSampleStream(
new InputStreamReader(new FileInputStream(inFile))));
}
else {
POSContextGenerator cg = new DefaultPOSContextGenerator(new Dictionary(new FileInputStream(dict)));
ss = new POSSampleSequenceStream(new WordTagSampleStream((
new InputStreamReader(new FileInputStream(inFile)))),
cg);
}
}
else {
if (dict == null) {
ss = new POSSampleSequenceStream(new WordTagSampleStream((
new InputStreamReader(new FileInputStream(inFile), encoding))));
}
else {
POSContextGenerator cg = new DefaultPOSContextGenerator(new Dictionary(new FileInputStream(dict)));
ss = new POSSampleSequenceStream(new WordTagSampleStream((
new InputStreamReader(new FileInputStream(inFile), encoding))), cg);
}
}
mod = new SimplePerceptronSequenceTrainer().trainModel(iterations, ss, cutoff, true);
System.out.println("Saving the model as: " + outFile);
new SuffixSensitivePerceptronModelWriter(mod, outFile).persist();
}
else {
POSSampleEventStream es;
if (encoding == null) {
if (dict == null) {
es = new POSSampleEventStream(new WordTagSampleStream((
new InputStreamReader(new FileInputStream(inFile)))));
}
else {
POSContextGenerator cg = new DefaultPOSContextGenerator(new Dictionary(new FileInputStream(dict)));
es = new POSSampleEventStream(new WordTagSampleStream((
new InputStreamReader(new FileInputStream(inFile)))),
cg);
}
}
else {
if (dict == null) {
es = new POSSampleEventStream(new WordTagSampleStream((
new InputStreamReader(new FileInputStream(inFile), encoding))));
}
else {
POSContextGenerator cg = new DefaultPOSContextGenerator(new Dictionary(new FileInputStream(dict)));
es = new POSSampleEventStream(new WordTagSampleStream((
new InputStreamReader(new FileInputStream(inFile), encoding))), cg);
}
}