You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2017/01/06 21:07:37 UTC
[8/9] opennlp git commit: Correct indentation and white spaces
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTool.java
index 6e8b86f..92a846a 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTool.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.cmdline.namefind;
import java.io.File;
@@ -59,8 +60,8 @@ public final class TokenNameFinderTool extends BasicCmdLineTool {
nameFinders[i] = new NameFinderME(model);
}
-// ObjectStream<String> untokenizedLineStream =
-// new PlainTextByLineStream(new InputStreamReader(System.in));
+ // ObjectStream<String> untokenizedLineStream =
+ // new PlainTextByLineStream(new InputStreamReader(System.in));
ObjectStream<String> untokenizedLineStream;
PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent");
perfMon.start();
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTrainerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTrainerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTrainerTool.java
index b2ccfc5..f75f976 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTrainerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/namefind/TokenNameFinderTrainerTool.java
@@ -60,7 +60,7 @@ public final class TokenNameFinderTrainerTool
}
static byte[] openFeatureGeneratorBytes(String featureGenDescriptorFile) {
- if(featureGenDescriptorFile != null) {
+ if (featureGenDescriptorFile != null) {
return openFeatureGeneratorBytes(new File(featureGenDescriptorFile));
}
return null;
@@ -108,7 +108,7 @@ public final class TokenNameFinderTrainerTool
// TODO: Improve error handling!
e.printStackTrace();
}
-
+
try (InputStream inputStreamXML = CmdLineUtil.openInFile(featureGenDescriptor)) {
elements = GeneratorFactory.getDescriptorElements(inputStreamXML);
} catch (IOException e) {
@@ -164,7 +164,7 @@ public final class TokenNameFinderTrainerTool
super.run(format, args);
mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), true);
- if(mlParams == null) {
+ if (mlParams == null) {
mlParams = ModelUtil.createDefaultTrainingParameters();
}
@@ -207,7 +207,7 @@ public final class TokenNameFinderTrainerTool
NameSampleCountersStream counters = new NameSampleCountersStream(sampleStream);
sampleStream = counters;
-
+
TokenNameFinderModel model;
try {
model = opennlp.tools.namefind.NameFinderME.train(
@@ -225,12 +225,12 @@ public final class TokenNameFinderTrainerTool
// sorry that this can fail
}
}
-
+
System.out.println();
counters.printSummary();
System.out.println();
-
+
CmdLineUtil.writeModel("name finder", modelOutFile, model);
-
+
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/CVParams.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/CVParams.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/CVParams.java
index 6cf30ea..2fe16d6 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/CVParams.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/CVParams.java
@@ -29,11 +29,11 @@ public interface CVParams {
@ParameterDescription(valueName = "true|false",
description = "if true will print false negatives and false positives.")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getMisclassified();
@ParameterDescription(valueName = "num", description = "number of folds, default is 10.")
- @OptionalParameter(defaultValue="10")
+ @OptionalParameter(defaultValue = "10")
Integer getFolds();
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/DetailedFMeasureEvaluatorParams.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/DetailedFMeasureEvaluatorParams.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/DetailedFMeasureEvaluatorParams.java
index abd0359..4040e79 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/DetailedFMeasureEvaluatorParams.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/DetailedFMeasureEvaluatorParams.java
@@ -30,7 +30,7 @@ public interface DetailedFMeasureEvaluatorParams {
@ParameterDescription(valueName = "true|false",
description = "if true will print detailed FMeasure results.")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getDetailedF();
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/EvaluatorParams.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/EvaluatorParams.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/EvaluatorParams.java
index 29a3264..3629ea2 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/EvaluatorParams.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/params/EvaluatorParams.java
@@ -34,7 +34,7 @@ public interface EvaluatorParams {
@ParameterDescription(valueName = "true|false",
description = "if true will print false negatives and false positives.")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getMisclassified();
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
index fe98725..ce30f3b 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/BuildModelUpdaterTool.java
@@ -40,19 +40,19 @@ public final class BuildModelUpdaterTool extends ModelUpdaterTool {
ObjectStream<Parse> parseSamples, ModelUpdaterParams parameters)
throws IOException {
- Dictionary mdict = ParserTrainerTool.buildDictionary(parseSamples, originalModel.getHeadRules(), 5);
+ Dictionary mdict = ParserTrainerTool.buildDictionary(parseSamples, originalModel.getHeadRules(), 5);
- parseSamples.reset();
+ parseSamples.reset();
- // TODO: training individual models should be in the chunking parser, not here
- // Training build
- System.out.println("Training builder");
- ObjectStream<Event> bes = new ParserEventStream(parseSamples,
- originalModel.getHeadRules(), ParserEventTypeEnum.BUILD, mdict);
- AbstractModel buildModel = Parser.train(bes, 100, 5);
+ // TODO: training individual models should be in the chunking parser, not here
+ // Training build
+ System.out.println("Training builder");
+ ObjectStream<Event> bes = new ParserEventStream(parseSamples,
+ originalModel.getHeadRules(), ParserEventTypeEnum.BUILD, mdict);
+ AbstractModel buildModel = Parser.train(bes, 100, 5);
- parseSamples.close();
+ parseSamples.close();
- return originalModel.updateBuildModel(buildModel);
+ return originalModel.updateBuildModel(buildModel);
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
index f0d75a8..1103e66 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/CheckModelUpdaterTool.java
@@ -41,20 +41,20 @@ public final class CheckModelUpdaterTool extends ModelUpdaterTool {
ObjectStream<Parse> parseSamples, ModelUpdaterParams parameters)
throws IOException {
- Dictionary mdict = ParserTrainerTool.buildDictionary(parseSamples, originalModel.getHeadRules(), 5);
+ Dictionary mdict = ParserTrainerTool.buildDictionary(parseSamples, originalModel.getHeadRules(), 5);
- parseSamples.reset();
+ parseSamples.reset();
- // TODO: Maybe that should be part of the ChunkingParser ...
- // Training build
- System.out.println("Training check model");
- ObjectStream<Event> bes = new ParserEventStream(parseSamples,
- originalModel.getHeadRules(), ParserEventTypeEnum.CHECK, mdict);
- AbstractModel checkModel = Parser.train(bes,
- 100, 5);
+ // TODO: Maybe that should be part of the ChunkingParser ...
+ // Training build
+ System.out.println("Training check model");
+ ObjectStream<Event> bes = new ParserEventStream(parseSamples,
+ originalModel.getHeadRules(), ParserEventTypeEnum.CHECK, mdict);
+ AbstractModel checkModel = Parser.train(bes,
+ 100, 5);
- parseSamples.close();
+ parseSamples.close();
- return originalModel.updateCheckModel(checkModel);
+ return originalModel.updateCheckModel(checkModel);
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserConverterTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserConverterTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserConverterTool.java
index 182f288..63b2123 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserConverterTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserConverterTool.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.cmdline.parser;
import opennlp.tools.cmdline.AbstractConverterTool;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java
index dddaf94..690e3c0 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTool.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.cmdline.parser;
import java.io.File;
@@ -55,6 +56,7 @@ public final class ParserTool extends BasicCmdLineTool {
+ "-k n: Show the top n parses. This will also display their log-probablities.\n"
+ "-tk tok_model: Use the specified tokenizer model to tokenize the sentences. Defaults to a WhitespaceTokenizer.";
}
+
private static Pattern untokenizedParenPattern1 = Pattern.compile("([^ ])([({)}])");
private static Pattern untokenizedParenPattern2 = Pattern.compile("([({)}])([^ ])");
@@ -121,7 +123,7 @@ public final class ParserTool extends BasicCmdLineTool {
Tokenizer tokenizer = WhitespaceTokenizer.INSTANCE;
String tokenizerModelName = CmdLineUtil.getParameter( "-tk", args );
- if( tokenizerModelName != null ){
+ if (tokenizerModelName != null ) {
TokenizerModel tokenizerModel = new TokenizerModelLoader().load( new File( tokenizerModelName ) );
tokenizer = new TokenizerME( tokenizerModel );
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTrainerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTrainerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTrainerTool.java
index 10cf7c4..928ea29 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTrainerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/parser/ParserTrainerTool.java
@@ -70,9 +70,9 @@ public final class ParserTrainerTool extends AbstractTrainerTool<Parse, TrainerT
static ParserType parseParserType(String typeAsString) {
ParserType type = null;
- if(typeAsString != null && typeAsString.length() > 0) {
+ if (typeAsString != null && typeAsString.length() > 0) {
type = ParserType.parse(typeAsString);
- if(type == null) {
+ if (type == null) {
throw new TerminateToolException(1, "ParserType training parameter '" + typeAsString +
"' is invalid!");
}
@@ -140,7 +140,7 @@ public final class ParserTrainerTool extends AbstractTrainerTool<Parse, TrainerT
}
}
- if(mlParams == null) {
+ if (mlParams == null) {
mlParams = ModelUtil.createDefaultTrainingParameters();
}
@@ -152,8 +152,8 @@ public final class ParserTrainerTool extends AbstractTrainerTool<Parse, TrainerT
HeadRules rules = creaeHeadRules(params);
ParserType type = parseParserType(params.getParserType());
- if(params.getFun()){
- Parse.useFunctionTags(true);
+ if (params.getFun()) {
+ Parse.useFunctionTags(true);
}
if (ParserType.CHUNKING.equals(type)) {
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSModelLoader.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSModelLoader.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSModelLoader.java
index 40632cf..6e2a010 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSModelLoader.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSModelLoader.java
@@ -27,7 +27,7 @@ import opennlp.tools.postag.POSModel;
* <p>
* <b>Note:</b> Do not use this class, internal use only!
*/
-public final class POSModelLoader extends ModelLoader<POSModel>{
+public final class POSModelLoader extends ModelLoader<POSModel> {
public POSModelLoader() {
super("POS Tagger");
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTool.java
index 2c4c661..61e3225 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTool.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.cmdline.postag;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTrainerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTrainerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTrainerTool.java
index c04b5ef..d19ea5e 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTrainerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/postag/POSTaggerTrainerTool.java
@@ -61,7 +61,7 @@ public final class POSTaggerTrainerTool
"' is invalid!");
}
- if(mlParams == null) {
+ if (mlParams == null) {
mlParams = ModelUtil.createDefaultTrainingParameters();
mlParams.put(TrainingParameters.ALGORITHM_PARAM, getModelType(params.getType()).toString());
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java
index 666e864..b0d554f 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorEvaluatorTool.java
@@ -58,7 +58,7 @@ public final class SentenceDetectorEvaluatorTool
System.out.print("Evaluating ... ");
try {
- evaluator.evaluate(sampleStream);
+ evaluator.evaluate(sampleStream);
}
catch (IOException e) {
throw new TerminateToolException(-1, "IO error while reading training data or indexing data: " +
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorTrainerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorTrainerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorTrainerTool.java
index d468c28..9e493b8 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorTrainerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/sentdetect/SentenceDetectorTrainerTool.java
@@ -70,7 +70,7 @@ public final class SentenceDetectorTrainerTool
}
}
- if(mlParams == null) {
+ if (mlParams == null) {
mlParams = ModelUtil.createDefaultTrainingParameters();
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/CommandLineTokenizer.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/CommandLineTokenizer.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/CommandLineTokenizer.java
index 4c81d93..8eb5004 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/CommandLineTokenizer.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/CommandLineTokenizer.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.cmdline.tokenizer;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/DictionaryDetokenizerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/DictionaryDetokenizerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/DictionaryDetokenizerTool.java
index 4c379b2..57176ae 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/DictionaryDetokenizerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/DictionaryDetokenizerTool.java
@@ -43,15 +43,15 @@ public final class DictionaryDetokenizerTool extends BasicCmdLineTool {
if (args.length != 1) {
System.out.println(getHelp());
} else {
- try {
- Detokenizer detokenizer = new DictionaryDetokenizer(
- new DetokenizationDictionaryLoader().load(new File(args[0])));
+ try {
+ Detokenizer detokenizer = new DictionaryDetokenizer(
+ new DetokenizationDictionaryLoader().load(new File(args[0])));
- ObjectStream<String> tokenizedLineStream =
- new PlainTextByLineStream(new SystemInputStreamFactory(), SystemInputStreamFactory.encoding());
+ ObjectStream<String> tokenizedLineStream =
+ new PlainTextByLineStream(new SystemInputStreamFactory(), SystemInputStreamFactory.encoding());
- PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent");
- perfMon.start();
+ PerformanceMonitor perfMon = new PerformanceMonitor(System.err, "sent");
+ perfMon.start();
String tokenizedLine;
@@ -64,7 +64,7 @@ public final class DictionaryDetokenizerTool extends BasicCmdLineTool {
perfMon.incrementCounter();
}
- perfMon.stopAndPrintFinalResult();
+ perfMon.stopAndPrintFinalResult();
}
catch (IOException e) {
CmdLineUtil.handleStdinIoError(e);
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java
index 77ff79e..0c26807 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/SimpleTokenizerTool.java
@@ -41,7 +41,7 @@ public final class SimpleTokenizerTool extends BasicCmdLineTool {
} else {
CommandLineTokenizer tokenizer =
- new CommandLineTokenizer(opennlp.tools.tokenize.SimpleTokenizer.INSTANCE);
+ new CommandLineTokenizer(opennlp.tools.tokenize.SimpleTokenizer.INSTANCE);
tokenizer.process();
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerMETool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerMETool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerMETool.java
index eff9272..27176a1 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerMETool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerMETool.java
@@ -41,7 +41,7 @@ public final class TokenizerMETool extends BasicCmdLineTool {
TokenizerModel model = new TokenizerModelLoader().load(new File(args[0]));
CommandLineTokenizer tokenizer =
- new CommandLineTokenizer(new opennlp.tools.tokenize.TokenizerME(model));
+ new CommandLineTokenizer(new opennlp.tools.tokenize.TokenizerME(model));
tokenizer.process();
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerTrainerTool.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerTrainerTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerTrainerTool.java
index 7ec5825..ba619c3 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerTrainerTool.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/tokenizer/TokenizerTrainerTool.java
@@ -73,7 +73,7 @@ public final class TokenizerTrainerTool
}
}
- if(mlParams == null) {
+ if (mlParams == null) {
mlParams = ModelUtil.createDefaultTrainingParameters();
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java b/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java
index 4961741..7258b4b 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/dictionary/Dictionary.java
@@ -68,7 +68,7 @@ public class Dictionary implements Iterable<StringList> {
else {
result = this.stringList.compareToIgnoreCase(other.getStringList());
}
- }
+ }
else {
result = false;
}
@@ -139,9 +139,9 @@ public class Dictionary implements Iterable<StringList> {
* @param tokens the new entry
*/
public void put(StringList tokens) {
- entrySet.add(new StringListWrapper(tokens));
- minTokenCount = Math.min(minTokenCount, tokens.size());
- maxTokenCount = Math.max(maxTokenCount, tokens.size());
+ entrySet.add(new StringListWrapper(tokens));
+ minTokenCount = Math.min(minTokenCount, tokens.size());
+ maxTokenCount = Math.max(maxTokenCount, tokens.size());
}
/**
@@ -149,7 +149,7 @@ public class Dictionary implements Iterable<StringList> {
* @return minimum token count in the dictionary
*/
public int getMinTokenCount() {
- return minTokenCount;
+ return minTokenCount;
}
/**
@@ -157,7 +157,7 @@ public class Dictionary implements Iterable<StringList> {
* @return maximum token count in the dictionary
*/
public int getMaxTokenCount() {
- return maxTokenCount;
+ return maxTokenCount;
}
/**
@@ -167,7 +167,7 @@ public class Dictionary implements Iterable<StringList> {
* @return true if it contains the entry otherwise false
*/
public boolean contains(StringList tokens) {
- return entrySet.contains(new StringListWrapper(tokens));
+ return entrySet.contains(new StringListWrapper(tokens));
}
/**
@@ -176,7 +176,7 @@ public class Dictionary implements Iterable<StringList> {
* @param tokens
*/
public void remove(StringList tokens) {
- entrySet.remove(new StringListWrapper(tokens));
+ entrySet.remove(new StringListWrapper(tokens));
}
/**
@@ -199,7 +199,8 @@ public class Dictionary implements Iterable<StringList> {
public void remove() {
entries.remove();
- }};
+ }
+ };
}
/**
@@ -220,25 +221,25 @@ public class Dictionary implements Iterable<StringList> {
public void serialize(OutputStream out) throws IOException {
Iterator<Entry> entryIterator = new Iterator<Entry>()
- {
- private Iterator<StringList> dictionaryIterator = Dictionary.this.iterator();
+ {
+ private Iterator<StringList> dictionaryIterator = Dictionary.this.iterator();
- public boolean hasNext() {
- return dictionaryIterator.hasNext();
- }
+ public boolean hasNext() {
+ return dictionaryIterator.hasNext();
+ }
- public Entry next() {
+ public Entry next() {
- StringList tokens = dictionaryIterator.next();
+ StringList tokens = dictionaryIterator.next();
- return new Entry(tokens, new Attributes());
- }
+ return new Entry(tokens, new Attributes());
+ }
- public void remove() {
- throw new UnsupportedOperationException();
- }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
- };
+ };
DictionarySerializer.serialize(out, entryIterator, isCaseSensitive);
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionarySerializer.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionarySerializer.java b/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionarySerializer.java
index a0b3dcb..13f8927 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionarySerializer.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/dictionary/serializer/DictionarySerializer.java
@@ -45,8 +45,8 @@ import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.XMLReaderFactory;
/**
- * This class is used by for reading and writing dictionaries of all kinds.
- */
+ * This class is used by for reading and writing dictionaries of all kinds.
+ */
public class DictionarySerializer {
// TODO: should check for invalid format, make it save
@@ -54,8 +54,8 @@ public class DictionarySerializer {
private EntryInserter mInserter;
-// private boolean mIsInsideDictionaryElement;
-// private boolean mIsInsideEntryElement;
+ // private boolean mIsInsideDictionaryElement;
+ // private boolean mIsInsideEntryElement;
private boolean mIsInsideTokenElement;
private boolean mIsCaseSensitiveDictionary;
@@ -69,121 +69,122 @@ public class DictionarySerializer {
mInserter = inserter;
mIsCaseSensitiveDictionary = true;
}
+
+ /**
+ * Not implemented.
+ */
+ public void processingInstruction(String target, String data)
+ throws SAXException {
+ }
+
/**
* Not implemented.
*/
- public void processingInstruction(String target, String data)
- throws SAXException {
- }
-
- /**
- * Not implemented.
- */
- public void startDocument() throws SAXException {
- }
-
- public void startElement(String uri, String localName, String qName,
- org.xml.sax.Attributes atts) throws SAXException {
- if (DICTIONARY_ELEMENT.equals(localName)) {
-
- mAttributes = new Attributes();
-
- for (int i = 0; i < atts.getLength(); i++) {
- mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
- }
- /* get the attribute here ... */
- if (mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE) != null) {
- mIsCaseSensitiveDictionary = Boolean.valueOf(mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE));
- }
- mAttributes = null;
- }
- else if (ENTRY_ELEMENT.equals(localName)) {
-
- mAttributes = new Attributes();
-
- for (int i = 0; i < atts.getLength(); i++) {
- mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
- }
- }
- else if (TOKEN_ELEMENT.equals(localName)) {
- mIsInsideTokenElement = true;
- }
- }
-
- public void characters(char[] ch, int start, int length)
- throws SAXException {
- if (mIsInsideTokenElement) {
- token.append(ch, start, length);
- }
- }
-
- /**
- * Creates the Profile object after processing is complete
- * and switches mIsInsideNgramElement flag.
- */
- public void endElement(String uri, String localName, String qName)
- throws SAXException {
-
- if (TOKEN_ELEMENT.equals(localName)) {
- mTokenList.add(token.toString().trim());
- token.setLength(0);
- mIsInsideTokenElement = false;
- }
- else if (ENTRY_ELEMENT.equals(localName)) {
-
- String[] tokens = mTokenList.toArray(
- new String[mTokenList.size()]);
-
- Entry entry = new Entry(new StringList(tokens), mAttributes);
-
- try {
- mInserter.insert(entry);
- } catch (InvalidFormatException e) {
- throw new SAXException("Invalid dictionary format!", e);
- }
-
- mTokenList.clear();
- mAttributes = null;
- }
- }
-
- /**
- * Not implemented.
- */
- public void endDocument() throws SAXException {
- }
-
- /**
- * Not implemented.
- */
- public void endPrefixMapping(String prefix) throws SAXException {
- }
-
- /**
- * Not implemented.
- */
- public void ignorableWhitespace(char[] ch, int start, int length)
- throws SAXException {
- }
-
- /**
- * Not implemented.
- */
- public void setDocumentLocator(Locator locator) {
- }
-
- /**
- * Not implemented.
- */
- public void skippedEntity(String name) throws SAXException {
- }
-
- /**
- * Not implemented.
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- }
+ public void startDocument() throws SAXException {
+ }
+
+ public void startElement(String uri, String localName, String qName,
+ org.xml.sax.Attributes atts) throws SAXException {
+ if (DICTIONARY_ELEMENT.equals(localName)) {
+
+ mAttributes = new Attributes();
+
+ for (int i = 0; i < atts.getLength(); i++) {
+ mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
+ }
+ /* get the attribute here ... */
+ if (mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE) != null) {
+ mIsCaseSensitiveDictionary = Boolean.valueOf(mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE));
+ }
+ mAttributes = null;
+ }
+ else if (ENTRY_ELEMENT.equals(localName)) {
+
+ mAttributes = new Attributes();
+
+ for (int i = 0; i < atts.getLength(); i++) {
+ mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
+ }
+ }
+ else if (TOKEN_ELEMENT.equals(localName)) {
+ mIsInsideTokenElement = true;
+ }
+ }
+
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
+ if (mIsInsideTokenElement) {
+ token.append(ch, start, length);
+ }
+ }
+
+ /**
+ * Creates the Profile object after processing is complete
+ * and switches mIsInsideNgramElement flag.
+ */
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
+
+ if (TOKEN_ELEMENT.equals(localName)) {
+ mTokenList.add(token.toString().trim());
+ token.setLength(0);
+ mIsInsideTokenElement = false;
+ }
+ else if (ENTRY_ELEMENT.equals(localName)) {
+
+ String[] tokens = mTokenList.toArray(
+ new String[mTokenList.size()]);
+
+ Entry entry = new Entry(new StringList(tokens), mAttributes);
+
+ try {
+ mInserter.insert(entry);
+ } catch (InvalidFormatException e) {
+ throw new SAXException("Invalid dictionary format!", e);
+ }
+
+ mTokenList.clear();
+ mAttributes = null;
+ }
+ }
+
+ /**
+ * Not implemented.
+ */
+ public void endDocument() throws SAXException {
+ }
+
+ /**
+ * Not implemented.
+ */
+ public void endPrefixMapping(String prefix) throws SAXException {
+ }
+
+ /**
+ * Not implemented.
+ */
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException {
+ }
+
+ /**
+ * Not implemented.
+ */
+ public void setDocumentLocator(Locator locator) {
+ }
+
+ /**
+ * Not implemented.
+ */
+ public void skippedEntity(String name) throws SAXException {
+ }
+
+ /**
+ * Not implemented.
+ */
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException {
+ }
}
private static final String CHARSET = "UTF-8";
@@ -222,7 +223,7 @@ public class DictionarySerializer {
}
catch (SAXException e) {
throw new InvalidFormatException("The profile data stream has " +
- "an invalid format!", e);
+ "an invalid format!", e);
}
return profileContentHandler.mIsCaseSensitiveDictionary;
}
@@ -241,8 +242,8 @@ public class DictionarySerializer {
*/
@Deprecated
public static void serialize(OutputStream out, Iterator<Entry> entries)
- throws IOException {
- DictionarySerializer.serialize(out, entries, true);
+ throws IOException {
+ DictionarySerializer.serialize(out, entries, true);
}
/**
@@ -259,8 +260,7 @@ public class DictionarySerializer {
* @throws IOException If an I/O error occurs
*/
public static void serialize(OutputStream out, Iterator<Entry> entries,
- boolean casesensitive)
- throws IOException {
+ boolean casesensitive) throws IOException {
StreamResult streamResult = new StreamResult(out);
SAXTransformerFactory tf = (SAXTransformerFactory)
SAXTransformerFactory.newInstance();
@@ -285,7 +285,7 @@ public class DictionarySerializer {
AttributesImpl dictionaryAttributes = new AttributesImpl();
dictionaryAttributes.addAttribute("", "", ATTRIBUTE_CASE_SENSITIVE,
- "", String.valueOf(casesensitive));
+ "", String.valueOf(casesensitive));
hd.startElement("", "", DICTIONARY_ELEMENT, dictionaryAttributes);
while (entries.hasNext()) {
@@ -304,7 +304,7 @@ public class DictionarySerializer {
}
private static void serializeEntry(TransformerHandler hd, Entry entry)
- throws SAXException{
+ throws SAXException {
AttributesImpl entryAttributes = new AttributesImpl();
@@ -312,7 +312,7 @@ public class DictionarySerializer {
String key = it.next();
entryAttributes.addAttribute("", "", key,
- "", entry.getAttributes().getValue(key));
+ "", entry.getAttributes().getValue(key));
}
hd.startElement("", "", ENTRY_ELEMENT, entryAttributes);
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DoccatFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DoccatFactory.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DoccatFactory.java
index b95671a..76c8176 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DoccatFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DoccatFactory.java
@@ -98,7 +98,7 @@ public class DoccatFactory extends BaseToolFactory {
}
public static DoccatFactory create(String subclassName, Tokenizer tokenizer,
- FeatureGenerator[] featureGenerators) throws InvalidFormatException {
+ FeatureGenerator[] featureGenerators) throws InvalidFormatException {
if (subclassName == null) {
// will create the default factory
return new DoccatFactory(tokenizer, featureGenerators);
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizer.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizer.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizer.java
index edd7b13..31b9780 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizer.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizer.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.doccat;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerContextGenerator.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerContextGenerator.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerContextGenerator.java
index 737b9d1..b1da3e3 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerContextGenerator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerContextGenerator.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.doccat;
import java.util.Collection;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEvaluator.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEvaluator.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEvaluator.java
index ad5b493..d2307e3 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEvaluator.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEvaluator.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.doccat;
import opennlp.tools.tokenize.TokenSample;
@@ -28,7 +29,7 @@ import opennlp.tools.util.eval.Mean;
* @see DocumentCategorizer
* @see DocumentSample
*/
-public class DocumentCategorizerEvaluator extends Evaluator<DocumentSample>{
+public class DocumentCategorizerEvaluator extends Evaluator<DocumentSample> {
private DocumentCategorizer categorizer;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEventStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEventStream.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEventStream.java
index 18084c0..77da891 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEventStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerEventStream.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.doccat;
import java.util.Iterator;
@@ -23,8 +24,8 @@ import opennlp.tools.util.AbstractEventStream;
import opennlp.tools.util.ObjectStream;
/**
-* Iterator-like class for modeling document classification events.
-*/
+ * Iterator-like class for modeling document classification events.
+ */
public class DocumentCategorizerEventStream extends AbstractEventStream<DocumentSample> {
private DocumentCategorizerContextGenerator mContextGenerator;
@@ -40,7 +41,7 @@ public class DocumentCategorizerEventStream extends AbstractEventStream<Document
super(data);
mContextGenerator =
- new DocumentCategorizerContextGenerator(featureGenerators);
+ new DocumentCategorizerContextGenerator(featureGenerators);
}
/**
@@ -52,13 +53,13 @@ public class DocumentCategorizerEventStream extends AbstractEventStream<Document
super(samples);
mContextGenerator =
- new DocumentCategorizerContextGenerator(new BagOfWordsFeatureGenerator());
+ new DocumentCategorizerContextGenerator(new BagOfWordsFeatureGenerator());
}
@Override
protected Iterator<Event> createEvents(final DocumentSample sample) {
- return new Iterator<Event>(){
+ return new Iterator<Event>() {
private boolean isVirgin = true;
@@ -76,6 +77,7 @@ public class DocumentCategorizerEventStream extends AbstractEventStream<Document
public void remove() {
throw new UnsupportedOperationException();
- }};
+ }
+ };
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerME.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerME.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerME.java
index d2ad651..cb6daeb 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerME.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentCategorizerME.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.doccat;
import java.io.IOException;
@@ -94,7 +95,7 @@ public class DocumentCategorizerME implements DocumentCategorizer {
*/
@Override
public double[] categorize(String documentText,
- Map<String, Object> extraInformation) {
+ Map<String, Object> extraInformation) {
Tokenizer tokenizer = model.getFactory().getTokenizer();
return categorize(tokenizer.tokenize(documentText), extraInformation);
}
@@ -174,13 +175,13 @@ public class DocumentCategorizerME implements DocumentCategorizer {
}
public static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples,
- TrainingParameters mlParams, DoccatFactory factory)
- throws IOException {
+ TrainingParameters mlParams, DoccatFactory factory)
+ throws IOException {
Map<String, String> manifestInfoEntries = new HashMap<>();
EventTrainer trainer = TrainerFactory.getEventTrainer(
- mlParams.getSettings(), manifestInfoEntries);
+ mlParams.getSettings(), manifestInfoEntries);
MaxentModel model = trainer.train(
new DocumentCategorizerEventStream(samples, factory.getFeatureGenerators()));
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSample.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSample.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSample.java
index 47828ab..0af00d5 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSample.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSample.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.doccat;
import java.util.ArrayList;
@@ -52,7 +53,7 @@ public class DocumentSample {
this.category = category;
this.text = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(text)));
- if(extraInformation == null) {
+ if (extraInformation == null) {
this.extraInformation = Collections.emptyMap();
} else {
this.extraInformation = extraInformation;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSampleStream.java
index 93a070d..e81f9f5 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/doccat/DocumentSampleStream.java
@@ -50,7 +50,7 @@ public class DocumentSampleStream extends FilterObjectStream<String, DocumentSam
if (tokens.length > 1) {
String category = tokens[0];
String docTokens[] = new String[tokens.length - 1];
- System.arraycopy(tokens, 1, docTokens, 0, tokens.length -1);
+ System.arraycopy(tokens, 1, docTokens, 0, tokens.length - 1);
sample = new DocumentSample(category, docTokens);
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/entitylinker/BaseLink.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/BaseLink.java b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/BaseLink.java
index 6e06beb..95c0d88 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/BaseLink.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/BaseLink.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.entitylinker;
import java.util.HashMap;
@@ -40,17 +41,19 @@ public abstract class BaseLink {
this.itemName = itemName;
this.itemType = itemType;
}
-/**
- * Any parent ID for the linked item
- * @return
- */
+
+ /**
+ * Any parent ID for the linked item
+ * @return
+ */
public String getItemParentID() {
return itemParentID;
}
-/**
- * returns the parent ID of the linked item
- * @param itemParentID
- */
+
+ /**
+ * returns the parent ID of the linked item
+ * @param itemParentID
+ */
public void setItemParentID(String itemParentID) {
this.itemParentID = itemParentID;
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java
index 64a53a4..caecd97 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinker.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.entitylinker;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java
index 5b62cb4..48ba354 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerFactory.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.entitylinker;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerProperties.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerProperties.java b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerProperties.java
index bd7b6f6..b0fbea1 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerProperties.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/EntityLinkerProperties.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.entitylinker;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/entitylinker/LinkedSpan.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/LinkedSpan.java b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/LinkedSpan.java
index c44aec8..3598a92 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/entitylinker/LinkedSpan.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/entitylinker/LinkedSpan.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.entitylinker;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/BioNLP2004NameSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/BioNLP2004NameSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/BioNLP2004NameSampleStream.java
index 14eb42e..4f62a3a 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/BioNLP2004NameSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/BioNLP2004NameSampleStream.java
@@ -133,7 +133,7 @@ public class BioNLP2004NameSampleStream implements ObjectStream<NameSample> {
}
beginIndex = i;
- endIndex = i +1;
+ endIndex = i + 1;
}
else if (tag.startsWith("I-")) {
endIndex++;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/ChunkerSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/ChunkerSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/ChunkerSampleStreamFactory.java
index 75dbbfa..4ff8a4d 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/ChunkerSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/ChunkerSampleStreamFactory.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.formats;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/Conll02NameSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/Conll02NameSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/Conll02NameSampleStream.java
index efb37a0..f1986e7 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/Conll02NameSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/Conll02NameSampleStream.java
@@ -46,7 +46,7 @@ import opennlp.tools.util.StringUtil;
* <p>
* <b>Note:</b> Do not use this class, internal use only!
*/
-public class Conll02NameSampleStream implements ObjectStream<NameSample>{
+public class Conll02NameSampleStream implements ObjectStream<NameSample> {
public enum LANGUAGE {
NL,
@@ -172,7 +172,7 @@ public class Conll02NameSampleStream implements ObjectStream<NameSample>{
}
beginIndex = i;
- endIndex = i +1;
+ endIndex = i + 1;
}
else if (tag.startsWith("I-")) {
endIndex++;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/Conll03NameSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/Conll03NameSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/Conll03NameSampleStream.java
index a9e2e64..f2498b8 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/Conll03NameSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/Conll03NameSampleStream.java
@@ -33,7 +33,7 @@ import opennlp.tools.util.StringUtil;
/**
* An import stream which can parse the CONLL03 data.
*/
-public class Conll03NameSampleStream implements ObjectStream<NameSample>{
+public class Conll03NameSampleStream implements ObjectStream<NameSample> {
public enum LANGUAGE {
EN,
@@ -87,7 +87,7 @@ public class Conll03NameSampleStream implements ObjectStream<NameSample>{
String emptyLine = lineStream.read();
if (!StringUtil.isEmpty(emptyLine))
- throw new IOException("Empty line after -DOCSTART- not empty: '" + emptyLine +"'!");
+ throw new IOException("Empty line after -DOCSTART- not empty: '" + emptyLine + "'!");
continue;
}
@@ -121,19 +121,19 @@ public class Conll03NameSampleStream implements ObjectStream<NameSample>{
String tag = tags.get(i);
if (tag.endsWith("PER") &&
- (types & Conll02NameSampleStream.GENERATE_PERSON_ENTITIES) == 0)
+ (types & Conll02NameSampleStream.GENERATE_PERSON_ENTITIES) == 0)
tag = "O";
if (tag.endsWith("ORG") &&
- (types & Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES) == 0)
+ (types & Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES) == 0)
tag = "O";
if (tag.endsWith("LOC") &&
- (types & Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES) == 0)
+ (types & Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES) == 0)
tag = "O";
if (tag.endsWith("MISC") &&
- (types & Conll02NameSampleStream.GENERATE_MISC_ENTITIES) == 0)
+ (types & Conll02NameSampleStream.GENERATE_MISC_ENTITIES) == 0)
tag = "O";
if (tag.equals("O")) {
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/ConllXPOSSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/ConllXPOSSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/ConllXPOSSampleStream.java
index b3b88fc..4ca6374 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/ConllXPOSSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/ConllXPOSSampleStream.java
@@ -59,42 +59,42 @@ public class ConllXPOSSampleStream extends FilterObjectStream<String, POSSample>
// One paragraph contains a whole sentence and, the token
// and tag will be read from the FORM and POSTAG field.
- String paragraph = samples.read();
+ String paragraph = samples.read();
- POSSample sample = null;
+ POSSample sample = null;
- if (paragraph != null) {
+ if (paragraph != null) {
- // paragraph get lines
- BufferedReader reader = new BufferedReader(new StringReader(paragraph));
+ // paragraph get lines
+ BufferedReader reader = new BufferedReader(new StringReader(paragraph));
- List<String> tokens = new ArrayList<>(100);
- List<String> tags = new ArrayList<>(100);
+ List<String> tokens = new ArrayList<>(100);
+ List<String> tags = new ArrayList<>(100);
- String line;
- while ((line = reader.readLine()) != null) {
+ String line;
+ while ((line = reader.readLine()) != null) {
- final int minNumberOfFields = 5;
+ final int minNumberOfFields = 5;
- String parts[] = line.split("\t");
+ String parts[] = line.split("\t");
- if (parts.length >= minNumberOfFields) {
- tokens.add(parts[1]);
- tags.add(parts[4]);
- }
- else {
- throw new InvalidFormatException("Every non-empty line must have at least " +
- minNumberOfFields + " fields: '" + line + "'!");
- }
- }
+ if (parts.length >= minNumberOfFields) {
+ tokens.add(parts[1]);
+ tags.add(parts[4]);
+ }
+ else {
+ throw new InvalidFormatException("Every non-empty line must have at least " +
+ minNumberOfFields + " fields: '" + line + "'!");
+ }
+ }
- // just skip empty samples and read next sample
- if (tokens.size() == 0)
- sample = read();
+ // just skip empty samples and read next sample
+ if (tokens.size() == 0)
+ sample = read();
- sample = new POSSample(tokens.toArray(new String[tokens.size()]), tags.toArray(new String[tags.size()]));
- }
+ sample = new POSSample(tokens.toArray(new String[tokens.size()]), tags.toArray(new String[tags.size()]));
+ }
- return sample;
+ return sample;
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/DirectorySampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/DirectorySampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/DirectorySampleStream.java
index 116ac88..47f4b67 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/DirectorySampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/DirectorySampleStream.java
@@ -45,7 +45,7 @@ public class DirectorySampleStream implements ObjectStream<File> {
public DirectorySampleStream(File dirs[], FileFilter fileFilter, boolean recursive) {
- this.fileFilter= fileFilter;
+ this.fileFilter = fileFilter;
isRecursiveScan = recursive;
List<File> inputDirectoryList = new ArrayList<File>(dirs.length);
@@ -71,7 +71,7 @@ public class DirectorySampleStream implements ObjectStream<File> {
public File read() throws IOException {
- while(textFiles.isEmpty() && !directories.isEmpty()) {
+ while (textFiles.isEmpty() && !directories.isEmpty()) {
File dir = directories.pop();
File files[];
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/DocumentSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/DocumentSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/DocumentSampleStreamFactory.java
index 5c591b2..3e2aa07 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/DocumentSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/DocumentSampleStreamFactory.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.formats;
import java.io.IOException;
@@ -50,7 +51,7 @@ public class DocumentSampleStreamFactory extends AbstractSampleStreamFactory<Doc
CmdLineUtil.checkInputFile("Data", params.getData());
InputStreamFactory sampleDataIn = CmdLineUtil.createInputStreamFactory(params.getData());
- ObjectStream<String> lineStream=null;
+ ObjectStream<String> lineStream = null;
try {
lineStream = new PlainTextByLineStream(sampleDataIn, params.getEncoding());
} catch (IOException ex) {
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/EvalitaNameSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/EvalitaNameSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/EvalitaNameSampleStream.java
index 925a130..68a57fb 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/EvalitaNameSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/EvalitaNameSampleStream.java
@@ -55,7 +55,7 @@ import opennlp.tools.util.StringUtil;
* <p>
* <b>Note:</b> Do not use this class, internal use only!
*/
-public class EvalitaNameSampleStream implements ObjectStream<NameSample>{
+public class EvalitaNameSampleStream implements ObjectStream<NameSample> {
public enum LANGUAGE {
IT
@@ -132,7 +132,7 @@ public class EvalitaNameSampleStream implements ObjectStream<NameSample>{
String emptyLine = lineStream.read();
if (!StringUtil.isEmpty(emptyLine))
- throw new IOException("Empty line after -DOCSTART- not empty: '" + emptyLine +"'!");
+ throw new IOException("Empty line after -DOCSTART- not empty: '" + emptyLine + "'!");
continue;
}
@@ -185,7 +185,7 @@ public class EvalitaNameSampleStream implements ObjectStream<NameSample>{
}
beginIndex = i;
- endIndex = i +1;
+ endIndex = i + 1;
}
else if (tag.startsWith("I-")) {
endIndex++;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDoccatSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDoccatSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDoccatSampleStream.java
index 0ac318a..a9c734a 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDoccatSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDoccatSampleStream.java
@@ -75,7 +75,7 @@ public class LeipzigDoccatSampleStream extends
InputStreamFactory in) throws IOException {
this(language, sentencesPerDocument, SimpleTokenizer.INSTANCE, in);
}
-
+
public DocumentSample read() throws IOException {
int count = 0;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDocumentSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDocumentSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDocumentSampleStreamFactory.java
index c5e5c26..9c12927 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDocumentSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/LeipzigDocumentSampleStreamFactory.java
@@ -56,16 +56,16 @@ public class LeipzigDocumentSampleStreamFactory
Parameters params = ArgumentParser.parse(args, Parameters.class);
File sentencesFileDir = params.getSentencesDir();
-
+
File sentencesFiles[] = sentencesFileDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.contains("sentences") && name.endsWith(".txt");
}
});
-
+
@SuppressWarnings("unchecked")
- ObjectStream<DocumentSample> sampleStreams[] =
+ ObjectStream<DocumentSample> sampleStreams[] =
new ObjectStream[sentencesFiles.length];
for (int i = 0; i < sentencesFiles.length; i++) {
@@ -77,7 +77,7 @@ public class LeipzigDocumentSampleStreamFactory
throw new TerminateToolException(-1, "IO error while opening sample data: " + e.getMessage(), e);
}
}
-
+
return ObjectStreamUtils.createObjectStream(sampleStreams);
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/LemmatizerSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/LemmatizerSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/LemmatizerSampleStreamFactory.java
index 54840dc..edd9a2d 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/LemmatizerSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/LemmatizerSampleStreamFactory.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.formats;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/NameFinderCensus90NameStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/NameFinderCensus90NameStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/NameFinderCensus90NameStream.java
index 7773e50..0f6bb64 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/NameFinderCensus90NameStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/NameFinderCensus90NameStream.java
@@ -66,7 +66,7 @@ public class NameFinderCensus90NameStream implements ObjectStream<StringList> {
*
* @param in an <code>InputStreamFactory</code> for the input file.
* @param encoding the <code>Charset</code> to apply to the input stream.
- * @throws IOException
+ * @throws IOException
*/
public NameFinderCensus90NameStream(InputStreamFactory in, Charset encoding)
throws IOException {
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/NameSampleDataStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/NameSampleDataStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/NameSampleDataStreamFactory.java
index a95c8c6..e607239 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/NameSampleDataStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/NameSampleDataStreamFactory.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.formats;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/ParseSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/ParseSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/ParseSampleStreamFactory.java
index abcaf31..beaf414 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/ParseSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/ParseSampleStreamFactory.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.formats;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/SentenceSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/SentenceSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/SentenceSampleStreamFactory.java
index 6ed7051..fb5b35f 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/SentenceSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/SentenceSampleStreamFactory.java
@@ -53,7 +53,7 @@ public class SentenceSampleStreamFactory extends AbstractSampleStreamFactory<Sen
CmdLineUtil.checkInputFile("Data", params.getData());
InputStreamFactory sampleDataIn = CmdLineUtil.createInputStreamFactory(params.getData());
- ObjectStream<String> lineStream=null;
+ ObjectStream<String> lineStream = null;
try {
lineStream = new PlainTextByLineStream(sampleDataIn, params.getEncoding());
} catch (IOException ex) {
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/TokenSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/TokenSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/TokenSampleStreamFactory.java
index 10338b3..64287f3 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/TokenSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/TokenSampleStreamFactory.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.formats;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/WordTagSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/WordTagSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/WordTagSampleStreamFactory.java
index bfa1523..c52e55f 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/WordTagSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/WordTagSampleStreamFactory.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package opennlp.tools.formats;
import java.io.IOException;
@@ -38,7 +39,7 @@ public class WordTagSampleStreamFactory extends AbstractSampleStreamFactory<POSS
public static void registerFactory() {
StreamFactoryRegistry.registerFactory(POSSample.class,
- StreamFactoryRegistry.DEFAULT_FORMAT, new WordTagSampleStreamFactory(Parameters.class));
+ StreamFactoryRegistry.DEFAULT_FORMAT, new WordTagSampleStreamFactory(Parameters.class));
}
protected <P> WordTagSampleStreamFactory(Class<P> params) {
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStream.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStream.java b/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStream.java
index 12faf4c..e692b11 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStream.java
@@ -58,163 +58,163 @@ import opennlp.tools.util.StringUtil;
*/
public class ADChunkSampleStream implements ObjectStream<ChunkSample> {
- protected final ObjectStream<ADSentenceStream.Sentence> adSentenceStream;
-
- private int start = -1;
- private int end = -1;
-
- private int index = 0;
-
- public static final String OTHER = "O";
-
- /**
- * Creates a new {@link NameSample} stream from a line stream, i.e.
- * {@link ObjectStream}<{@link String}>, that could be a
- * {@link PlainTextByLineStream} object.
- *
- * @param lineStream
- * a stream of lines as {@link String}
- */
- public ADChunkSampleStream(ObjectStream<String> lineStream) {
- this.adSentenceStream = new ADSentenceStream(lineStream);
- }
-
- public ADChunkSampleStream(InputStreamFactory in, String charsetName) throws IOException {
-
- try {
- this.adSentenceStream = new ADSentenceStream(new PlainTextByLineStream(
- in, charsetName));
- } catch (UnsupportedEncodingException e) {
- // UTF-8 is available on all JVMs, will never happen
- throw new IllegalStateException(e);
+ protected final ObjectStream<ADSentenceStream.Sentence> adSentenceStream;
+
+ private int start = -1;
+ private int end = -1;
+
+ private int index = 0;
+
+ public static final String OTHER = "O";
+
+ /**
+ * Creates a new {@link NameSample} stream from a line stream, i.e.
+ * {@link ObjectStream}<{@link String}>, that could be a
+ * {@link PlainTextByLineStream} object.
+ *
+ * @param lineStream
+ * a stream of lines as {@link String}
+ */
+ public ADChunkSampleStream(ObjectStream<String> lineStream) {
+ this.adSentenceStream = new ADSentenceStream(lineStream);
+ }
+
+ public ADChunkSampleStream(InputStreamFactory in, String charsetName) throws IOException {
+
+ try {
+ this.adSentenceStream = new ADSentenceStream(new PlainTextByLineStream(
+ in, charsetName));
+ } catch (UnsupportedEncodingException e) {
+ // UTF-8 is available on all JVMs, will never happen
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public ChunkSample read() throws IOException {
+
+ Sentence paragraph;
+ while ((paragraph = this.adSentenceStream.read()) != null) {
+
+ if (end > -1 && index >= end) {
+ // leave
+ return null;
+ }
+
+ if (start > -1 && index < start) {
+ index++;
+ // skip this one
+ } else {
+ Node root = paragraph.getRoot();
+ List<String> sentence = new ArrayList<>();
+ List<String> tags = new ArrayList<>();
+ List<String> target = new ArrayList<>();
+
+ processRoot(root, sentence, tags, target);
+
+ if (sentence.size() > 0) {
+ index++;
+ return new ChunkSample(sentence, tags, target);
+ }
+
}
+
}
+ return null;
+ }
- public ChunkSample read() throws IOException {
-
- Sentence paragraph;
- while ((paragraph = this.adSentenceStream.read()) != null) {
-
- if (end > -1 && index >= end) {
- // leave
- return null;
- }
-
- if (start > -1 && index < start) {
- index++;
- // skip this one
- } else {
- Node root = paragraph.getRoot();
- List<String> sentence = new ArrayList<>();
- List<String> tags = new ArrayList<>();
- List<String> target = new ArrayList<>();
-
- processRoot(root, sentence, tags, target);
-
- if (sentence.size() > 0) {
- index++;
- return new ChunkSample(sentence, tags, target);
- }
-
- }
-
- }
- return null;
- }
-
- protected void processRoot(Node root, List<String> sentence, List<String> tags,
- List<String> target) {
- if (root != null) {
- TreeElement[] elements = root.getElements();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].isLeaf()) {
- processLeaf((Leaf) elements[i], false, OTHER, sentence, tags, target);
- } else {
- processNode((Node) elements[i], sentence, tags, target, null);
- }
- }
- }
- }
-
- private void processNode(Node node, List<String> sentence, List<String> tags,
- List<String> target, String inheritedTag) {
+ protected void processRoot(Node root, List<String> sentence, List<String> tags,
+ List<String> target) {
+ if (root != null) {
+ TreeElement[] elements = root.getElements();
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i].isLeaf()) {
+ processLeaf((Leaf) elements[i], false, OTHER, sentence, tags, target);
+ } else {
+ processNode((Node) elements[i], sentence, tags, target, null);
+ }
+ }
+ }
+ }
+
+ private void processNode(Node node, List<String> sentence, List<String> tags,
+ List<String> target, String inheritedTag) {
String phraseTag = getChunkTag(node);
boolean inherited = false;
- if(phraseTag.equals(OTHER) && inheritedTag != null) {
+ if (phraseTag.equals(OTHER) && inheritedTag != null) {
phraseTag = inheritedTag;
inherited = true;
}
TreeElement[] elements = node.getElements();
for (int i = 0; i < elements.length; i++) {
- if (elements[i].isLeaf()) {
- boolean isIntermediate = false;
- String tag = phraseTag;
- Leaf leaf = (Leaf) elements[i];
-
- String localChunk = getChunkTag(leaf);
- if(localChunk != null && !tag.equals(localChunk)) {
- tag = localChunk;
- }
-
- if(isIntermediate(tags, target, tag) && (inherited || i > 0)) {
- isIntermediate = true;
- }
- if(!isIncludePunctuations() && leaf.getFunctionalTag() == null &&
- (
- !( i + 1 < elements.length && elements[i+1].isLeaf() ) ||
- !( i > 0 && elements[i - 1].isLeaf() )
+ if (elements[i].isLeaf()) {
+ boolean isIntermediate = false;
+ String tag = phraseTag;
+ Leaf leaf = (Leaf) elements[i];
+
+ String localChunk = getChunkTag(leaf);
+ if (localChunk != null && !tag.equals(localChunk)) {
+ tag = localChunk;
+ }
+
+ if (isIntermediate(tags, target, tag) && (inherited || i > 0)) {
+ isIntermediate = true;
+ }
+ if (!isIncludePunctuations() && leaf.getFunctionalTag() == null &&
+ (
+ !( i + 1 < elements.length && elements[i + 1].isLeaf() ) ||
+ !( i > 0 && elements[i - 1].isLeaf() )
)
- ){
- isIntermediate = false;
- tag = OTHER;
- }
- processLeaf(leaf, isIntermediate, tag, sentence,
- tags, target);
- } else {
- int before = target.size();
- processNode((Node) elements[i], sentence, tags, target, phraseTag);
-
- // if the child node was of a different type we should break the chunk sequence
- for (int j = target.size() - 1; j >= before; j--) {
- if(!target.get(j).endsWith("-" + phraseTag)) {
- phraseTag = OTHER;
- break;
- }
- }
+ ) {
+ isIntermediate = false;
+ tag = OTHER;
}
+ processLeaf(leaf, isIntermediate, tag, sentence,
+ tags, target);
+ } else {
+ int before = target.size();
+ processNode((Node) elements[i], sentence, tags, target, phraseTag);
+
+ // if the child node was of a different type we should break the chunk sequence
+ for (int j = target.size() - 1; j >= before; j--) {
+ if (!target.get(j).endsWith("-" + phraseTag)) {
+ phraseTag = OTHER;
+ break;
+ }
+ }
+ }
}
-}
+ }
protected void processLeaf(Leaf leaf, boolean isIntermediate, String phraseTag,
- List<String> sentence, List<String> tags, List<String> target) {
- String chunkTag;
-
- if (leaf.getFunctionalTag() != null
- && phraseTag.equals(OTHER)) {
- phraseTag = getPhraseTagFromPosTag(leaf.getFunctionalTag());
- }
-
- if (!phraseTag.equals(OTHER)) {
- if (isIntermediate) {
- chunkTag = "I-" + phraseTag;
- } else {
- chunkTag = "B-" + phraseTag;
- }
- } else {
- chunkTag = phraseTag;
- }
-
- sentence.add(leaf.getLexeme());
- if (leaf.getSyntacticTag() == null) {
- tags.add(leaf.getLexeme());
- } else {
- tags.add(ADChunkSampleStream.convertFuncTag(leaf.getFunctionalTag(), false));
- }
- target.add(chunkTag);
- }
+ List<String> sentence, List<String> tags, List<String> target) {
+ String chunkTag;
+
+ if (leaf.getFunctionalTag() != null
+ && phraseTag.equals(OTHER)) {
+ phraseTag = getPhraseTagFromPosTag(leaf.getFunctionalTag());
+ }
+
+ if (!phraseTag.equals(OTHER)) {
+ if (isIntermediate) {
+ chunkTag = "I-" + phraseTag;
+ } else {
+ chunkTag = "B-" + phraseTag;
+ }
+ } else {
+ chunkTag = phraseTag;
+ }
+
+ sentence.add(leaf.getLexeme());
+ if (leaf.getSyntacticTag() == null) {
+ tags.add(leaf.getLexeme());
+ } else {
+ tags.add(ADChunkSampleStream.convertFuncTag(leaf.getFunctionalTag(), false));
+ }
+ target.add(chunkTag);
+ }
protected String getPhraseTagFromPosTag(String functionalTag) {
if (functionalTag.equals("v-fin")) {
@@ -236,7 +236,7 @@ public class ADChunkSampleStream implements ObjectStream<ChunkSample> {
protected String getChunkTag(Leaf leaf) {
String tag = leaf.getSyntacticTag();
- if("P".equals(tag)) {
+ if ("P".equals(tag)) {
return "VP";
}
return null;
@@ -262,21 +262,21 @@ public class ADChunkSampleStream implements ObjectStream<ChunkSample> {
return phraseTag;
}
- public void setStart(int aStart) {
- this.start = aStart;
- }
+ public void setStart(int aStart) {
+ this.start = aStart;
+ }
- public void setEnd(int aEnd) {
- this.end = aEnd;
- }
+ public void setEnd(int aEnd) {
+ this.end = aEnd;
+ }
- public void reset() throws IOException, UnsupportedOperationException {
- adSentenceStream.reset();
- }
+ public void reset() throws IOException, UnsupportedOperationException {
+ adSentenceStream.reset();
+ }
- public void close() throws IOException {
- adSentenceStream.close();
- }
+ public void close() throws IOException {
+ adSentenceStream.close();
+ }
protected boolean isIncludePunctuations() {
return false;
http://git-wip-us.apache.org/repos/asf/opennlp/blob/1bccbabb/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStreamFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStreamFactory.java b/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStreamFactory.java
index 5ef5d89..1f55fe4 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStreamFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADChunkSampleStreamFactory.java
@@ -79,7 +79,7 @@ public class ADChunkSampleStreamFactory extends LanguageSampleStreamFactory<Chun
InputStreamFactory sampleDataIn = CmdLineUtil.createInputStreamFactory(params.getData());
- ObjectStream<String> lineStream=null;
+ ObjectStream<String> lineStream = null;
try {
lineStream = new PlainTextByLineStream(sampleDataIn, params.getEncoding());
} catch (IOException ex) {
@@ -88,11 +88,11 @@ public class ADChunkSampleStreamFactory extends LanguageSampleStreamFactory<Chun
ADChunkSampleStream sampleStream = new ADChunkSampleStream(lineStream);
- if(params.getStart() != null && params.getStart() > -1) {
+ if (params.getStart() != null && params.getStart() > -1) {
sampleStream.setStart(params.getStart());
}
- if(params.getEnd() != null && params.getEnd() > -1) {
+ if (params.getEnd() != null && params.getEnd() > -1) {
sampleStream.setEnd(params.getEnd());
}