You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by kr...@apache.org on 2026/09/12 15:31:20 UTC
(opennlp-addons) branch OPENNLP-1924-checkstyle-pass created (now 91e0ad6)
This is an automated email from the ASF dual-hosted git repository.
krickert pushed a change to branch OPENNLP-1924-checkstyle-pass
in repository https://gitbox.apache.org/repos/asf/opennlp-addons.git
at 91e0ad6 OPENNLP-1924: Align sources with checkstyle and fail on violations
This branch includes the following new commits:
new 91e0ad6 OPENNLP-1924: Align sources with checkstyle and fail on violations
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(opennlp-addons) 01/01: OPENNLP-1924: Align sources with checkstyle and fail on violations
Posted by kr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
krickert pushed a commit to branch OPENNLP-1924-checkstyle-pass
in repository https://gitbox.apache.org/repos/asf/opennlp-addons.git
commit 91e0ad6d6f205fa0d0781a7e820c93451b0f216d
Author: Kristian Rickert <kr...@apache.org>
AuthorDate: Sat Sep 12 11:31:11 2026 -0400
OPENNLP-1924: Align sources with checkstyle and fail on violations
---
.../addons/geoentitylinker/AdminBoundary.java | 16 +-
.../geoentitylinker/AdminBoundaryContext.java | 20 +-
.../AdminBoundaryContextGenerator.java | 35 +--
.../geoentitylinker/CountryContextEntry.java | 13 +-
.../addons/geoentitylinker/GazetteerEntry.java | 13 +-
.../geoentitylinker/GazetteerSearchCache.java | 13 +-
.../addons/geoentitylinker/GazetteerSearcher.java | 25 ++-
.../addons/geoentitylinker/GeoEntityLinker.java | 26 ++-
.../geoentitylinker/indexing/GazetteerIndexer.java | 68 +++---
.../indexing/GeonamesFileDownloader.java | 17 +-
.../indexing/GeonamesProcessor.java | 35 +--
.../geoentitylinker/indexing/RegionProcessor.java | 18 +-
.../geoentitylinker/indexing/USGSProcessor.java | 37 +--
.../scoring/CountryProximityScorer.java | 40 ++--
.../scoring/FuzzyStringMatchScorer.java | 27 ++-
.../scoring/GeoHashBinningScorer.java | 13 +-
.../scoring/LinkedEntityScorer.java | 19 +-
.../geoentitylinker/scoring/ModelBasedScorer.java | 18 +-
.../geoentitylinker/scoring/PlacetypeScorer.java | 21 +-
.../geoentitylinker/scoring/PointClustering.java | 21 +-
.../scoring/ProvinceProximityScorer.java | 35 +--
.../AuxiliaryInfoTokenNameFinderFactory.java | 5 +-
.../lang/jpn/TokenPatternFeatureGenerator.java | 2 +-
.../lang/jpn/BigramNameFeatureGeneratorTest.java | 4 +-
.../lang/jpn/TokenClassFeatureGeneratorTest.java | 14 +-
.../lang/jpn/TokenPatternFeatureGeneratorTest.java | 4 +-
.../lang/jpn/TrigramNameFeatureGeneratorTest.java | 4 +-
.../opennlp/jwnl/lemmatizer/JWNLLemmatizer.java | 2 +-
liblinear/src/main/java/LiblinearModel.java | 40 ++--
.../src/main/java/LiblinearModelSerializer.java | 30 ++-
liblinear/src/main/java/LiblinearTrainer.java | 31 ++-
.../modelbuilder/DefaultModelBuilderUtil.java | 14 +-
.../addons/modelbuilder/KnownEntityProvider.java | 17 +-
.../modelbuilder/ModelGenerationValidator.java | 17 +-
.../addons/modelbuilder/ModelParameter.java | 15 +-
.../opennlp/addons/modelbuilder/Modelable.java | 13 +-
.../modelbuilder/SemiSupervisedModelGenerator.java | 13 +-
.../addons/modelbuilder/SentenceProvider.java | 14 +-
.../modelbuilder/impls/BaseModelBuilderParams.java | 15 +-
.../impls/FileKnownEntityProvider.java | 13 +-
.../modelbuilder/impls/FileModelValidatorImpl.java | 18 +-
.../modelbuilder/impls/FileSentenceProvider.java | 19 +-
.../modelbuilder/impls/GenericModelGenerator.java | 25 ++-
.../modelbuilder/impls/GenericModelableImpl.java | 18 +-
.../main/java/opennlp/morfologik/cmdline/CLI.java | 248 ++++++++++-----------
.../builder/MorfologikDictionaryBuilderParams.java | 15 +-
.../builder/MorfologikDictionaryBuilderTool.java | 1 +
.../builder/XMLDictionaryToTableParams.java | 11 +-
.../cmdline/builder/XMLDictionaryToTableTool.java | 7 +-
.../lemmatizer/MorfologikLemmatizer.java | 1 +
.../tagdict/MorfologikPOSTaggerFactory.java | 5 +-
.../tagdict/MorfologikTagDictionary.java | 1 +
.../builder/POSDictionaryBuilderTest.java | 4 +-
.../lemmatizer/MorfologikLemmatizerTest.java | 4 +-
.../tagdict/MorfologikTagDictionaryTest.java | 7 +-
.../morfologik/tagdict/POSTaggerFactoryTest.java | 9 +-
pom.xml | 4 +-
57 files changed, 650 insertions(+), 544 deletions(-)
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundary.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundary.java
index 1eb02ee..0abc5a4 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundary.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundary.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +26,8 @@ public record AdminBoundary(String countryCode, String countryName, String provi
private static final String NO_DATA_FOUND_VALUE = "NO_DATA_FOUND";
- public AdminBoundary(String countryCode, String countryName, String provinceCode, String provinceName, String countyCode, String countyName,
+ public AdminBoundary(String countryCode, String countryName, String provinceCode, String provinceName,
+ String countyCode, String countyName,
String countryRegex, String provinceRegex, String countyRegex) {
this.countryCode = countryCode;
this.provinceCode = provinceCode;
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContext.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContext.java
index a78478e..4422cc3 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContext.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContext.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -46,7 +47,8 @@ public class AdminBoundaryContext {
Set<String> countyHits,
Map<String, String> countryRefMap,
Map<String, Map<String, String>> provRefMap,
- Map<String, Map<String, String>> countyRefMap, Map<String, Set<String>> nameCodesMap, Map<String, String> countryRegexMap, Map<String, String> provinceRegexMap,
+ Map<String, Map<String, String>> countyRefMap, Map<String, Set<String>> nameCodesMap,
+ Map<String, String> countryRegexMap, Map<String, String> provinceRegexMap,
Map<String, String> countyRegexMap) {
this.countryMentions = countryMentions;
this.provMentions = provMentions;
@@ -80,7 +82,7 @@ public class AdminBoundaryContext {
return countyMentions;
}
- public Set<String> getCountryHits() {
+ public final Set<String> getCountryHits() {
return countryHits;
}
@@ -96,7 +98,7 @@ public class AdminBoundaryContext {
return countryRefMap;
}
- public Map<String, Map<String, String>> getProvRefMap() {
+ public final Map<String, Map<String, String>> getProvRefMap() {
return provRefMap;
}
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContextGenerator.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContextGenerator.java
index bcf6076..d5f7879 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContextGenerator.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/AdminBoundaryContextGenerator.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -51,7 +52,7 @@ public class AdminBoundaryContextGenerator {
private Map<String, String> countyRegexMap = new HashMap<>();
private final Set<CountryContextEntry> countryHits = new HashSet<>();
- private final List<AdminBoundary> adminBoundaryData= new ArrayList<>();
+ private final List<AdminBoundary> adminBoundaryData = new ArrayList<>();
private final Set<AdminBoundary> adminBoundaryHits = new HashSet<>();
private final Set<String> countryHitSet = new HashSet<>();
@@ -76,7 +77,8 @@ public class AdminBoundaryContextGenerator {
"Eastern Africa people are cool.");
System.out.println(c);
} catch (Exception ex) {
- java.util.logging.Logger.getLogger(AdminBoundaryContextGenerator.class.getName()).log(Level.SEVERE, null, ex);
+ java.util.logging.Logger.getLogger(AdminBoundaryContextGenerator.class.getName())
+ .log(Level.SEVERE, null, ex);
}
}
@@ -198,8 +200,9 @@ public class AdminBoundaryContextGenerator {
}
}
- return new AdminBoundaryContext(countryhitMap, provMentions, countyMentions, countryHitSet, provHits, countyHits,
- countryRefMap, provMap, countyMap, nameCodesMap, countryRegexMap, provinceRegexMap, countyRegexMap);
+ return new AdminBoundaryContext(countryhitMap, provMentions, countyMentions, countryHitSet,
+ provHits, countyHits, countryRefMap, provMap, countyMap, nameCodesMap,
+ countryRegexMap, provinceRegexMap, countyRegexMap);
} catch (Exception e) {
LOG.error(e.getLocalizedMessage(), e);
}
@@ -214,7 +217,8 @@ public class AdminBoundaryContextGenerator {
* value is an actual name.
* @param hitsRef a reference to a set that stores the hits by id
*/
- private Map<String, Set<Integer>> regexfind(String docText, Map<String, String> lookupMap, Set<String> hitsRef, String locationType) {
+ private Map<String, Set<Integer>> regexfind(String docText, Map<String, String> lookupMap,
+ Set<String> hitsRef, String locationType) {
Map<String, Set<Integer>> mentions = new HashMap<>();
if (lookupMap == null) {
return mentions;
@@ -339,7 +343,7 @@ public class AdminBoundaryContextGenerator {
if (currentRegex.length() > adm.countryRegex().length()) {
// the longest one wins if they are not all the same for each entry in the file
countryRegexMap.put(adm.countryCode(), currentRegex);
- }//else do nothing
+ } //else do nothing
} else {
countryRegexMap.put(adm.countryCode(), adm.countryRegex());
}
@@ -355,7 +359,8 @@ public class AdminBoundaryContextGenerator {
provMap.put(adm.countryCode(), provs);
// }
- if (!adm.countyCode().equalsIgnoreCase("no_data_found") && !adm.countyName().equalsIgnoreCase("no_data_found")) {
+ if (!adm.countyCode().equalsIgnoreCase("no_data_found")
+ && !adm.countyName().equalsIgnoreCase("no_data_found")) {
Map<String, String> counties = countyMap.get(combined);
if (counties == null) {
counties = new HashMap<>();
@@ -382,7 +387,7 @@ public class AdminBoundaryContextGenerator {
if (currentRegex.length() > adm.provinceRegex().length()) {
// the longest one wins if they are not all the same for each entry in the file
provinceRegexMap.put(adm.getProvCode(), currentRegex);
- }//else do nothing
+ } //else do nothing
} else {
provinceRegexMap.put(adm.getProvCode(), adm.provinceRegex());
}
@@ -399,7 +404,7 @@ public class AdminBoundaryContextGenerator {
if (currentRegex.length() > adm.countyRegex().length()) {
// the longest one wins if they are not all the same for each entry in the file
countyRegexMap.put(adm.countyCode(), currentRegex);
- }//else do nothing
+ } //else do nothing
} else {
countyRegexMap.put(adm.countyCode(), adm.countyRegex());
}
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/CountryContextEntry.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/CountryContextEntry.java
index d04073d..eff7463 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/CountryContextEntry.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/CountryContextEntry.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerEntry.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerEntry.java
index 6497894..c6d75ba 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerEntry.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerEntry.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearchCache.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearchCache.java
index 9cdca41..192cde1 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearchCache.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearchCache.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java
index 19ebf4f..057c521 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -101,7 +102,8 @@ public class GazetteerSearcher {
*/
String placeNameQueryString = "placename:(" + searchString.toLowerCase() + ") " + "AND " + whereClause;
if (searchString.trim().contains(" ") && useHierarchyField) {
- placeNameQueryString = "(placename:(" + searchString.toLowerCase() + ") AND hierarchy:(" + formatForHierarchy(searchString) + "))"
+ placeNameQueryString = "(placename:(" + searchString.toLowerCase() + ") AND hierarchy:("
+ + formatForHierarchy(searchString) + "))"
+ " AND " + whereClause;
}
@@ -118,7 +120,8 @@ public class GazetteerSearcher {
*/
QueryParser parser = new QueryParser(placeNameQueryString, opennlpAnalyzer);
Query q = parser.parse(placeNameQueryString);
- //Filter filter = new QueryWrapperFilter(new QueryParser(Version.LUCENE_48, whereClause, opennlpAnalyzer).parse(whereClause));
+ //Filter filter = new QueryWrapperFilter(new QueryParser(Version.LUCENE_48, whereClause,
+ // opennlpAnalyzer).parse(whereClause));
TopDocs bestDocs = opennlpSearcher.search(q, rowsReturned);
Double maxscore = 0d;
@@ -208,7 +211,8 @@ public class GazetteerSearcher {
IndexReader opennlpReader = DirectoryReader.open(opennlpIndex);
opennlpSearcher = new IndexSearcher(opennlpReader);
opennlpAnalyzer
- = //new StandardAnalyzer(Version.LUCENE_48, new CharArraySet(Version.LUCENE_48, new ArrayList(), true));
+ = //new StandardAnalyzer(Version.LUCENE_48, new CharArraySet(Version.LUCENE_48,
+ // new ArrayList(), true));
new StandardAnalyzer(new CharArraySet(new ArrayList<>(), true));
Map<String, Analyzer> analyMap = new HashMap<>();
@@ -221,7 +225,8 @@ public class GazetteerSearcher {
opennlpAnalyzer
= new PerFieldAnalyzerWrapper(opennlpAnalyzer, analyMap);
- String cutoff = properties.getProperty("opennlp.geoentitylinker.gaz.lucenescore.min", String.valueOf(scoreCutoff));
+ String cutoff = properties.getProperty("opennlp.geoentitylinker.gaz.lucenescore.min",
+ String.valueOf(scoreCutoff));
String usehierarchy = properties.getProperty("opennlp.geoentitylinker.gaz.hierarchyfield", "0");
if (cutoff != null && !cutoff.isEmpty()) {
scoreCutoff = Double.parseDouble(cutoff);
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
index 7c67aba..f28f627 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/GeoEntityLinker.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -47,7 +48,8 @@ public class GeoEntityLinker implements EntityLinker<LinkedSpan<BaseLink>> {
private AdminBoundaryContextGenerator countryContext;
private EntityLinkerProperties linkerProperties;
private GazetteerSearcher gazetteerSearcher;
- private final List<LinkedEntityScorer<? extends BaseLink, AdminBoundaryContext>> scorers = new ArrayList<>();
+ private final List<LinkedEntityScorer<? extends BaseLink, AdminBoundaryContext>> scorers =
+ new ArrayList<>();
@Override
public List<LinkedSpan<BaseLink>> find(String doctext, Span[] sentences,
@@ -73,8 +75,10 @@ public class GeoEntityLinker implements EntityLinker<LinkedSpan<BaseLink>> {
}
}
}
- } else { //this means there were no where clauses generated so the where clause will default to look at the entire index
- List<GazetteerEntry> find = gazetteerSearcher.find(matches[i], topN, " gaztype:usgs geonames regions ");
+ } else { //this means there were no where clauses generated so the where clause
+ // will default to look at the entire index
+ List<GazetteerEntry> find = gazetteerSearcher.find(matches[i], topN,
+ " gaztype:usgs geonames regions ");
for (GazetteerEntry gazetteerEntry : find) {
if (!geoNamesEntries.contains(gazetteerEntry)) {
geoNamesEntries.add(gazetteerEntry);
@@ -113,7 +117,9 @@ public class GeoEntityLinker implements EntityLinker<LinkedSpan<BaseLink>> {
if (!scorers.isEmpty()) {
for (LinkedEntityScorer<? extends BaseLink, AdminBoundaryContext> scorer : scorers) {
- LinkedEntityScorer<BaseLink, AdminBoundaryContext> s = (LinkedEntityScorer) scorer;
+ @SuppressWarnings("unchecked")
+ LinkedEntityScorer<BaseLink, AdminBoundaryContext> s =
+ (LinkedEntityScorer<BaseLink, AdminBoundaryContext>) scorer;
s.score(spans, doctext, sentences, linkerProperties, context);
}
}
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java
index 394da00..e80fe71 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -52,27 +53,27 @@ public class GazetteerIndexer {
public enum GazType implements Separable {
GEONAMES {
- @Override
- public String toString() {
- return "/opennlp_geoentitylinker_geonames_idx";
- }
-
- @Override
- public String getSeparator() {
- return "\t";
- }
- },
+ @Override
+ public String toString() {
+ return "/opennlp_geoentitylinker_geonames_idx";
+ }
+
+ @Override
+ public String getSeparator() {
+ return "\t";
+ }
+ },
USGS {
- @Override
- public String toString() {
- return "/opennlp_geoentitylinker_usgsgaz_idx";
- }
-
- @Override
- public String getSeparator() {
- return "\\|";
- }
- }
+ @Override
+ public String toString() {
+ return "/opennlp_geoentitylinker_usgsgaz_idx";
+ }
+
+ @Override
+ public String getSeparator() {
+ return "\\|";
+ }
+ }
}
/**
@@ -115,8 +116,9 @@ public class GazetteerIndexer {
* @throws FileNotFoundException Thrown if required resources do not exist.
* @throws IllegalArgumentException Thrown if parameters are invalid.
*/
- public void index(File geonamesData, File geoNamesCountryInfo, File geonamesAdmin1CodesASCII, File usgsDataFile,
- File usgsGovUnitsFile, File outputIndexDir, File outputCountryContextFile, File regionsFile)
+ public void index(File geonamesData, File geoNamesCountryInfo, File geonamesAdmin1CodesASCII,
+ File usgsDataFile, File usgsGovUnitsFile, File outputIndexDir,
+ File outputCountryContextFile, File regionsFile)
throws IOException {
if (!outputIndexDir.isDirectory()) {
throw new IllegalArgumentException("outputIndexDir must be a directory.");
@@ -158,12 +160,15 @@ public class GazetteerIndexer {
try (IndexWriter w = new IndexWriter(index, config)) {
//write the column headers for the countryContextFile
try (FileWriter writer = new FileWriter(outputCountryContextFile, false)) {
- String colNamesForCountryContextFile = "countrycode\tprovcode\tcountycode\tcountryname\tprovincename\tcountyname\tcountryregex\tprovregex\tcountyregex\n";
+ String colNamesForCountryContextFile =
+ "countrycode\tprovcode\tcountycode\tcountryname\tprovincename\tcountyname"
+ + "\tcountryregex\tprovregex\tcountyregex\n";
writer.write(colNamesForCountryContextFile);
writer.flush();
}
USGSProcessor.process(usgsGovUnitsFile, usgsDataFile, outputCountryContextFile, w);
- GeonamesProcessor.process(geoNamesCountryInfo, geonamesAdmin1CodesASCII, geonamesData, outputCountryContextFile, w);
+ GeonamesProcessor.process(geoNamesCountryInfo, geonamesAdmin1CodesASCII, geonamesData,
+ outputCountryContextFile, w);
RegionProcessor.process(regionsFile, outputCountryContextFile, w);
w.commit();
}
@@ -179,7 +184,8 @@ public class GazetteerIndexer {
System.out.println("Usage: GazetteerIndexer geonamesData geoNamesCountryInfo geonamesAdmin1CodesASCII "
+ "usgsDataFile usgsGovUnitsFile outputIndexDir outputCountryContextFile regionsFile");
System.out.println();
- System.out.println("The GazetteerIndexer.index methods javadoc explains how to retrieve the data files.");
+ System.out.println(
+ "The GazetteerIndexer.index methods javadoc explains how to retrieve the data files.");
return;
}
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesFileDownloader.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesFileDownloader.java
index 9e90e00..ae58223 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesFileDownloader.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesFileDownloader.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,7 +22,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
-import java.net.URL;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -73,7 +73,8 @@ public class GeonamesFileDownloader {
public static String fileUrl(String fAddress, String localFileName, String destDir) {
String filename = destDir + "\\" + localFileName;
try (InputStream is = new URI(fAddress).toURL().openConnection().getInputStream();
- OutputStream outStream = new BufferedOutputStream(new FileOutputStream(destDir + "\\" + localFileName))) {
+ OutputStream outStream = new BufferedOutputStream(
+ new FileOutputStream(destDir + "\\" + localFileName))) {
byte[] buf = new byte[size];
int byteRead, byteWritten = 0;
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesProcessor.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesProcessor.java
index b1e8bee..ada567b 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesProcessor.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/GeonamesProcessor.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -49,11 +50,13 @@ public class GeonamesProcessor {
}
public static void process(File countryCodesLookup, File adm1CodesLookup,
- File geonamesGazetteer, File outputCountryContext, IndexWriter w) throws IOException {
+ File geonamesGazetteer, File outputCountryContext, IndexWriter w)
+ throws IOException {
Map<String, String> countryCodes = getCountryCodes(countryCodesLookup);
Map<String, AdminBoundary> adm1s = getProvData(adm1CodesLookup, countryCodes);
- // List<AdminBoundary> adm2s = getCountryContextFromFile(new File("C:\\temp\\gazetteers\\geonamesdata\\admin2Codes.txt"));
+ // List<AdminBoundary> adm2s = getCountryContextFromFile(
+ // new File("C:\\temp\\gazetteers\\geonamesdata\\admin2Codes.txt"));
//admin2Codes.txt
readFile(geonamesGazetteer, GazetteerIndexer.GazType.GEONAMES, adm1s, countryCodes, w);
@@ -62,12 +65,14 @@ public class GeonamesProcessor {
}
- private static Map<String, AdminBoundary> getProvData(File adm1CodesLookupFile, Map<String, String> ccodes) {
- System.out.println("Attempting to read geonames province data from: " + adm1CodesLookupFile.getPath());
+ private static Map<String, AdminBoundary> getProvData(File adm1CodesLookupFile,
+ Map<String, String> ccodes) {
+ System.out.println("Attempting to read geonames province data from: "
+ + adm1CodesLookupFile.getPath());
Map<String, AdminBoundary> outmap = new HashMap<>();
Set<String> nullcodes = new HashSet<>();
- try (BufferedReader reader = new BufferedReader(new FileReader(adm1CodesLookupFile))){
+ try (BufferedReader reader = new BufferedReader(new FileReader(adm1CodesLookupFile))) {
String line;
while ((line = reader.readLine()) != null) {
@@ -99,12 +104,14 @@ public class GeonamesProcessor {
if (cname == null) {
nullcodes.add(ccode);
}
- AdminBoundary data = new AdminBoundary(ccode, cname, pcode, pname, "NO_DATA_FOUND", "NO_DATA_FOUND", cname, pname, "NO_DATA_FOUND");
+ AdminBoundary data = new AdminBoundary(ccode, cname, pcode, pname, "NO_DATA_FOUND",
+ "NO_DATA_FOUND", cname, pname, "NO_DATA_FOUND");
// System.out.println(data);
outmap.put(ccode + "." + pcode, data);
}
- System.out.println("INFO: there were " + nullcodes.size() + " null prov codes. This is due to inconsistencies in reference data.");
+ System.out.println("INFO: there were " + nullcodes.size()
+ + " null prov codes. This is due to inconsistencies in reference data.");
} catch (IOException ex) {
ex.printStackTrace();
}
@@ -116,7 +123,7 @@ public class GeonamesProcessor {
private static Map<String, String> getCountryCodes(File countryContextFile) {
Map<String, String> ccs = new HashMap<>();
- try (BufferedReader reader = new BufferedReader(new FileReader(countryContextFile))){
+ try (BufferedReader reader = new BufferedReader(new FileReader(countryContextFile))) {
String line;
boolean start = false;
while ((line = reader.readLine()) != null) {
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/RegionProcessor.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/RegionProcessor.java
index d97427f..25f059c 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/RegionProcessor.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/RegionProcessor.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -92,9 +93,10 @@ public class RegionProcessor {
doc.add(new StringField("locid", id, Field.Store.YES));
doc.add(new StringField("gazsource", "region", Field.Store.YES));
//countrycontext file format
- // US KY 131 United States Kentucky Leslie
+ // US\tKY\t131\tUnited States\tKentucky\tLeslie
- ccfileentries.add(id + "\t" + id + "\t" + id + "\t" + placeName + "\t" + "NO_DATA_FOUND" + "\t" + "NO_DATA_FOUND" + "\t" + "("
+ ccfileentries.add(id + "\t" + id + "\t" + id + "\t" + placeName + "\t" + "NO_DATA_FOUND"
+ + "\t" + "NO_DATA_FOUND" + "\t" + "("
+ placeName + ")" + "\t" + "NO_DATA_FOUND" + "\t" + "NO_DATA_FOUND" + "\n");
if (w != null) {
w.addDocument(doc);
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/USGSProcessor.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/USGSProcessor.java
index 09105f8..1f3b0ed 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/USGSProcessor.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/indexing/USGSProcessor.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -42,8 +43,11 @@ public class USGSProcessor {
public static void main(String[] args) {
try {
- Map<String, AdminBoundary> provData = getProvData(new File("C:\\temp\\gazetteers\\usgsdata\\GOVT_UNITS_20140601.txt"), GazetteerIndexer.GazType.USGS);
- process(new File("C:\\temp\\gazetteers\\usgsdata\\GOVT_UNITS_20140601.txt"), new File("C:\\temp\\gazetteers\\usgsdata\\NationalFile_20140601.txt"), null, null);
+ Map<String, AdminBoundary> provData = getProvData(
+ new File("C:\\temp\\gazetteers\\usgsdata\\GOVT_UNITS_20140601.txt"),
+ GazetteerIndexer.GazType.USGS);
+ process(new File("C:\\temp\\gazetteers\\usgsdata\\GOVT_UNITS_20140601.txt"),
+ new File("C:\\temp\\gazetteers\\usgsdata\\NationalFile_20140601.txt"), null, null);
} catch (Exception ex) {
Logger.getLogger(USGSProcessor.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -90,7 +94,8 @@ public class USGSProcessor {
AdminBoundary get = lookupMap.get(admincode + "." + ccode);
String countyname = "";
if (get == null) {
- System.out.println("null...continuing to index" + " ccode: " + ccode + " , admincode: " + admincode + " , placename: " + placeName);
+ System.out.println("null...continuing to index" + " ccode: " + ccode
+ + " , admincode: " + admincode + " , placename: " + placeName);
continue;
}
@@ -102,7 +107,8 @@ public class USGSProcessor {
if (!get.countyCode().equals("NO_DATA_FOUND_VALUE")) {
countyCode = get.countyCode();
}
- String hierarchy = get.countryName() + ", " + get.provinceName() + ", " + countyname + ", " + placeName;
+ String hierarchy = get.countryName() + ", " + get.provinceName() + ", " + countyname
+ + ", " + placeName;
if (states.containsKey(get.provinceName())) {
StateCentroid entry = states.get(get.provinceName());
@@ -123,9 +129,12 @@ public class USGSProcessor {
doc.add(new TextField("latitude", lat, Field.Store.YES));
doc.add(new TextField("longitude", lon, Field.Store.YES));
doc.add(new StringField("loctype", dsg, Field.Store.YES));
- doc.add(new StringField("admincode", (get.countryCode() + "." + get.getProvCode()).toLowerCase(), Field.Store.YES));
+ doc.add(new StringField("admincode",
+ (get.countryCode() + "." + get.getProvCode()).toLowerCase(), Field.Store.YES));
doc.add(new StringField("countrycode", get.countryCode().toLowerCase(), Field.Store.YES));
- doc.add(new StringField("countycode", (get.countryCode() + "." + get.getProvCode() + "." + countyCode).toLowerCase(), Field.Store.YES));
+ doc.add(new StringField("countycode",
+ (get.countryCode() + "." + get.getProvCode() + "." + countyCode).toLowerCase(),
+ Field.Store.YES));
doc.add(new StringField("locid", id, Field.Store.YES));
doc.add(new StringField("gazsource", "usgs", Field.Store.YES));
@@ -213,8 +222,8 @@ public class USGSProcessor {
String stateName = values[6];
String countryCode = values[7];
String countryName = values[8];
- AdminBoundary adminBoundary = new AdminBoundary(countryCode, countryName, stateCode, stateName, countyCode,
- countyName, null, null, null);
+ AdminBoundary adminBoundary = new AdminBoundary(countryCode, countryName, stateCode,
+ stateName, countyCode, countyName, null, null, null);
outmap.put(stateCode + "." + countyCode, adminBoundary);
// System.out.println(adminBoundary);
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/CountryProximityScorer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/CountryProximityScorer.java
index 08d6055..025a6ff 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/CountryProximityScorer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/CountryProximityScorer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,8 +26,8 @@ import java.util.TreeSet;
import java.util.regex.Pattern;
import opennlp.addons.geoentitylinker.AdminBoundaryContext;
-import opennlp.tools.entitylinker.EntityLinkerProperties;
import opennlp.tools.entitylinker.BaseLink;
+import opennlp.tools.entitylinker.EntityLinkerProperties;
import opennlp.tools.entitylinker.LinkedSpan;
import opennlp.tools.util.Span;
@@ -44,9 +45,11 @@ public class CountryProximityScorer implements LinkedEntityScorer<BaseLink, Adm
private Map<String, String> regexMap = new HashMap<>();
@Override
- public void score(List<LinkedSpan<BaseLink>> linkedSpans, String docText, Span[] sentenceSpans, EntityLinkerProperties properties, AdminBoundaryContext additionalContext) {
+ public void score(List<LinkedSpan<BaseLink>> linkedSpans, String docText, Span[] sentenceSpans,
+ EntityLinkerProperties properties, AdminBoundaryContext additionalContext) {
regexMap = additionalContext.getCountryRegexMap();
- score(linkedSpans, additionalContext.getCountryMentions(), additionalContext.getNameCodesMap(), docText, sentenceSpans, 1000);
+ score(linkedSpans, additionalContext.getCountryMentions(), additionalContext.getNameCodesMap(),
+ docText, sentenceSpans, 1000);
}
/**
@@ -69,7 +72,9 @@ public class CountryProximityScorer implements LinkedEntityScorer<BaseLink, Adm
* Named Entity.
* @return
*/
- public List<LinkedSpan<BaseLink>> score(List<LinkedSpan<BaseLink>> linkedData, Map<String, Set<Integer>> countryHits, Map<String, Set<String>> nameCodesMap, String docText, Span[] sentences, Integer maxAllowedDist) {
+ public List<LinkedSpan<BaseLink>> score(List<LinkedSpan<BaseLink>> linkedData,
+ Map<String, Set<Integer>> countryHits, Map<String, Set<String>> nameCodesMap, String docText,
+ Span[] sentences, Integer maxAllowedDist) {
this.nameCodesMap = nameCodesMap;
setDominantCode(countryHits);
for (LinkedSpan<BaseLink> linkedspan : linkedData) {
@@ -104,7 +109,9 @@ public class CountryProximityScorer implements LinkedEntityScorer<BaseLink, Adm
* @param span
* @return
*/
- private LinkedSpan<BaseLink> simpleProximityAnalysis(Span[] sentences, Map<String, Set<Integer>> countryHits, LinkedSpan<BaseLink> span, Integer maxAllowedDistance) {
+ private LinkedSpan<BaseLink> simpleProximityAnalysis(Span[] sentences,
+ Map<String, Set<Integer>> countryHits, LinkedSpan<BaseLink> span,
+ Integer maxAllowedDistance) {
Double score = 0.0;
/*
* get the index of the actual span, beginning of sentence //should generate
@@ -152,10 +159,12 @@ public class CountryProximityScorer implements LinkedEntityScorer<BaseLink, Adm
score = scoreMap.get(spanCountryCode);
///does the name extracted match a country name?
- if (nameCodesMap.containsKey(link.getItemName().toLowerCase()) || regexMatch(link.getItemName(), link.getItemParentID())) {
+ if (nameCodesMap.containsKey(link.getItemName().toLowerCase())
+ || regexMatch(link.getItemName(), link.getItemParentID())) {
//if so, is it the correct country code for that name?
if (nameCodesMap.get(link.getItemName().toLowerCase()).contains(link.getItemParentID())) {
- //boost the score because it is likely that this is the location in the text, so add 50% to the score or set to 1
+ //boost the score because it is likely that this is the location in the text,
+ // so add 50% to the score or set to 1
score = (score + .75) > 1.0 ? 1d : (score + .75);
if (link.getItemParentID().equals(dominantCode)) {
@@ -181,7 +190,8 @@ public class CountryProximityScorer implements LinkedEntityScorer<BaseLink, Adm
* @param span
* @return
*/
- private Map<String, Double> analyzeMap(Map<String, Set<Integer>> distanceMap, Span[] sentences, LinkedSpan<BaseLink> span) {
+ private Map<String, Double> analyzeMap(Map<String, Set<Integer>> distanceMap, Span[] sentences,
+ LinkedSpan<BaseLink> span) {
Map<String, Double> scoreMap = new HashMap<>();
if (distanceMap.isEmpty()) {
@@ -219,7 +229,7 @@ public class CountryProximityScorer implements LinkedEntityScorer<BaseLink, Adm
if (regexMap.containsKey(countryCode)) {
String regexForCountry = regexMap.get(countryCode);
- Pattern p = Pattern.compile(regexForCountry,Pattern.DOTALL|Pattern.CASE_INSENSITIVE);
+ Pattern p = Pattern.compile(regexForCountry,Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
return p.matcher(placeName.trim()).matches();
}
return false;
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/FuzzyStringMatchScorer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/FuzzyStringMatchScorer.java
index 873b6ea..b5fd3eb 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/FuzzyStringMatchScorer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/FuzzyStringMatchScorer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,8 +23,8 @@ import java.util.Set;
import opennlp.addons.geoentitylinker.AdminBoundaryContext;
import opennlp.addons.geoentitylinker.GazetteerEntry;
-import opennlp.tools.entitylinker.EntityLinkerProperties;
import opennlp.tools.entitylinker.BaseLink;
+import opennlp.tools.entitylinker.EntityLinkerProperties;
import opennlp.tools.entitylinker.LinkedSpan;
import opennlp.tools.util.Span;
@@ -33,20 +34,24 @@ import opennlp.tools.util.Span;
public class FuzzyStringMatchScorer implements LinkedEntityScorer<GazetteerEntry, AdminBoundaryContext> {
@Override
- public void score(List<LinkedSpan<GazetteerEntry>> linkedSpans, String docText, Span[] sentenceSpans, EntityLinkerProperties properties, AdminBoundaryContext additionalContext) {
+ public void score(List<LinkedSpan<GazetteerEntry>> linkedSpans, String docText,
+ Span[] sentenceSpans, EntityLinkerProperties properties,
+ AdminBoundaryContext additionalContext) {
for (LinkedSpan<GazetteerEntry> linkedSpan : linkedSpans) {
for (BaseLink link : linkedSpan.getLinkedEntries()) {
if (link instanceof GazetteerEntry entry) {
String hierarchy = entry.getHierarchy();
if (hierarchy != null) {
- Double dice = getDiceCoefficient(linkedSpan.getSearchTerm().toLowerCase(), hierarchy.toLowerCase(), 2);
+ Double dice = getDiceCoefficient(linkedSpan.getSearchTerm().toLowerCase(),
+ hierarchy.toLowerCase(), 2);
link.getScoreMap().put("hierarchydicecoef", dice);
- Double ld = (double) getLevenshteinDistance(linkedSpan.getSearchTerm().toLowerCase(), hierarchy.toLowerCase());
+ Double ld = (double) getLevenshteinDistance(linkedSpan.getSearchTerm().toLowerCase(),
+ hierarchy.toLowerCase());
link.getScoreMap().put("hierarchylevenshtein", ld);
}
String placename = entry.getItemName().toLowerCase();
- if (placename != null) {
+ if (placename != null) {
Double dice = getDiceCoefficient(linkedSpan.getSearchTerm().toLowerCase(), placename, 2);
link.getScoreMap().put("placenamedicecoef", dice);
}
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/GeoHashBinningScorer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/GeoHashBinningScorer.java
index 30f98c4..bce403b 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/GeoHashBinningScorer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/GeoHashBinningScorer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/LinkedEntityScorer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/LinkedEntityScorer.java
index ad9f220..30b997b 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/LinkedEntityScorer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/LinkedEntityScorer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -32,9 +33,11 @@ import opennlp.tools.util.Span;
public interface LinkedEntityScorer<L extends BaseLink, T> {
/**
- * Scores a collection of linked entities. Implementations should populate the scoreMap in the list of BaseLink for each linkedSpan
+ * Scores a collection of linked entities. Implementations should populate the scoreMap
+ * in the list of BaseLink for each linkedSpan
* this method internally affects the reference to linkedSpans that was passed in
- * @param linkedSpans the spans that have been linked to some external source and have all the data they need to be scored
+ * @param linkedSpans the spans that have been linked to some external source and have
+ * all the data they need to be scored
* @param docText the full text of the document.
* @param sentenceSpans the sentence spans that corresponds to the document text
* @param properties the entitylinker properties config file
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ModelBasedScorer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ModelBasedScorer.java
index 4b305e4..3bb09aa 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ModelBasedScorer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ModelBasedScorer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,8 +28,8 @@ import org.slf4j.LoggerFactory;
import opennlp.addons.geoentitylinker.AdminBoundaryContext;
import opennlp.tools.doccat.DoccatModel;
import opennlp.tools.doccat.DocumentCategorizerME;
-import opennlp.tools.entitylinker.EntityLinkerProperties;
import opennlp.tools.entitylinker.BaseLink;
+import opennlp.tools.entitylinker.EntityLinkerProperties;
import opennlp.tools.entitylinker.LinkedSpan;
import opennlp.tools.util.Span;
@@ -57,7 +58,8 @@ public class ModelBasedScorer implements LinkedEntityScorer<BaseLink, AdminBound
doccatModel = new DoccatModel(new File(path));
documentCategorizerME = new DocumentCategorizerME(doccatModel);
}
- Map<Integer, String> proximalFeatures = generateProximalFeatures(linkedSpans, sentenceSpans, docText, RADIUS);
+ Map<Integer, String> proximalFeatures = generateProximalFeatures(linkedSpans, sentenceSpans,
+ docText, RADIUS);
for (Map.Entry<Integer, String> entry : proximalFeatures.entrySet()) {
Map<String, Double> scores = this.getScore(entry.getValue());
for (BaseLink link : linkedSpans.get(entry.getKey()).getLinkedEntries()) {
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PlacetypeScorer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PlacetypeScorer.java
index 4a3b05a..66eff51 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PlacetypeScorer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PlacetypeScorer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -68,15 +69,15 @@ public class PlacetypeScorer implements LinkedEntityScorer<GazetteerEntry, Admin
for (String type : boosts) {
if (type.equals("PCLI")) {
boosetedTypes.put(type.toLowerCase(), 1d);
- } else if ((type.startsWith("PC")|| type.startsWith("PP")) && !type.equals("PCLI")) {
+ } else if ((type.startsWith("PC") || type.startsWith("PP")) && !type.equals("PCLI")) {
boosetedTypes.put(type.toLowerCase(), .5d);
} else if (type.startsWith("ADM")) {
boosetedTypes.put(type.toLowerCase(), .75d);
- }else if (type.equalsIgnoreCase("civil")){
+ } else if (type.equalsIgnoreCase("civil")) {
boosetedTypes.put(type.toLowerCase(), .9d);
}
- if(type.equalsIgnoreCase("populated_place")){
- boosetedTypes.put("Populated Place", .75d);
+ if (type.equalsIgnoreCase("populated_place")) {
+ boosetedTypes.put("Populated Place", .75d);
}
}
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PointClustering.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PointClustering.java
index 5f218d9..cdca5a3 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PointClustering.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/PointClustering.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2014 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,13 +16,15 @@
*/
package opennlp.addons.geoentitylinker.scoring;
-import com.spatial4j.core.context.SpatialContext;
-import com.spatial4j.core.io.GeohashUtils;
-import com.spatial4j.core.shape.Point;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
+import com.spatial4j.core.context.SpatialContext;
+import com.spatial4j.core.io.GeohashUtils;
+import com.spatial4j.core.shape.Point;
+
import opennlp.addons.geoentitylinker.GazetteerEntry;
/**
diff --git a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ProvinceProximityScorer.java b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ProvinceProximityScorer.java
index 13ce217..7044b7c 100644
--- a/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ProvinceProximityScorer.java
+++ b/geoentitylinker/src/main/java/opennlp/addons/geoentitylinker/scoring/ProvinceProximityScorer.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -46,10 +47,12 @@ public class ProvinceProximityScorer implements LinkedEntityScorer<BaseLink, Adm
private Map<String, String> regexMap = new HashMap<>();
@Override
- public void score(List<LinkedSpan<BaseLink>> linkedSpans, String docText, Span[] sentenceSpans, EntityLinkerProperties properties, AdminBoundaryContext additionalContext) {
+ public void score(List<LinkedSpan<BaseLink>> linkedSpans, String docText, Span[] sentenceSpans,
+ EntityLinkerProperties properties, AdminBoundaryContext additionalContext) {
if (!additionalContext.getProvHits().isEmpty()) {
regexMap = additionalContext.getProvinceRegexMap();
- score(linkedSpans, additionalContext.getProvMentions(), additionalContext.getNameCodesMap(), docText, sentenceSpans, 1000);
+ score(linkedSpans, additionalContext.getProvMentions(), additionalContext.getNameCodesMap(),
+ docText, sentenceSpans, 1000);
} else {
for (LinkedSpan<BaseLink> span : linkedSpans) {
for (BaseLink link : span.getLinkedEntries()) {
@@ -80,7 +83,9 @@ public class ProvinceProximityScorer implements LinkedEntityScorer<BaseLink, Adm
* Named Entity.
* @return
*/
- public List<LinkedSpan<BaseLink>> score(List<LinkedSpan<BaseLink>> linkedData, Map<String, Set<Integer>> countryHits, Map<String, Set<String>> nameCodesMap, String docText, Span[] sentences, Integer maxAllowedDist) {
+ public List<LinkedSpan<BaseLink>> score(List<LinkedSpan<BaseLink>> linkedData,
+ Map<String, Set<Integer>> countryHits, Map<String, Set<String>> nameCodesMap, String docText,
+ Span[] sentences, Integer maxAllowedDist) {
this.nameCodesMap = nameCodesMap;
setDominantCode(countryHits);
for (LinkedSpan<BaseLink> linkedspan : linkedData) {
@@ -114,8 +119,10 @@ public class ProvinceProximityScorer implements LinkedEntityScorer<BaseLink, Adm
* @param span
* @return
*/
- private LinkedSpan<BaseLink> simpleProximityAnalysis(Span[] sentences, Map<String, Set<Integer>> countryHits,
- LinkedSpan<BaseLink> span, Integer maxAllowedDistance) {
+ private LinkedSpan<BaseLink> simpleProximityAnalysis(Span[] sentences,
+ Map<String, Set<Integer>> countryHits,
+ LinkedSpan<BaseLink> span,
+ Integer maxAllowedDistance) {
Double score = 0.0;
/*
* get the index of the actual span, beginning of sentence //should generate
@@ -165,10 +172,12 @@ public class ProvinceProximityScorer implements LinkedEntityScorer<BaseLink, Adm
score = scoreMap.get(spanCountryCode);
///does the name extracted match a province name?
- if (nameCodesMap.containsKey(link.getItemName().toLowerCase()) || regexMatch(link.getItemName(), link.getItemParentID())) {
+ if (nameCodesMap.containsKey(link.getItemName().toLowerCase())
+ || regexMatch(link.getItemName(), link.getItemParentID())) {
//if so, is it the correct country code for that name?
if (nameCodesMap.get(entry.getItemName().toLowerCase()).contains(entry.getProvinceCode())) {
- //boost the score because it is likely that this is the location in the text, so add 50% to the score or set to 1
+ //boost the score because it is likely that this is the location in the text,
+ // so add 50% to the score or set to 1
//TODO: make this smarter
score = (score + .75) > 1.0 ? 1d : (score + .75);
diff --git a/japanese/src/main/java/opennlp/tools/namefind/AuxiliaryInfoTokenNameFinderFactory.java b/japanese/src/main/java/opennlp/tools/namefind/AuxiliaryInfoTokenNameFinderFactory.java
index 9977433..bcd6439 100644
--- a/japanese/src/main/java/opennlp/tools/namefind/AuxiliaryInfoTokenNameFinderFactory.java
+++ b/japanese/src/main/java/opennlp/tools/namefind/AuxiliaryInfoTokenNameFinderFactory.java
@@ -18,6 +18,7 @@
package opennlp.tools.namefind;
import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
+import opennlp.tools.util.featuregen.AggregatedFeatureGenerator;
import opennlp.tools.util.featuregen.BigramNameFeatureGenerator;
import opennlp.tools.util.featuregen.CachedFeatureGenerator;
import opennlp.tools.util.featuregen.OutcomePriorFeatureGenerator;
@@ -42,13 +43,13 @@ public class AuxiliaryInfoTokenNameFinderFactory extends TokenNameFinderFactory
AdaptiveFeatureGenerator featureGenerator = createFeatureGenerators();
if (featureGenerator == null) {
- featureGenerator = new CachedFeatureGenerator(
+ featureGenerator = new CachedFeatureGenerator(new AggregatedFeatureGenerator(
new WindowFeatureGenerator(new TokenFeatureGenerator(), 2, 2),
new WindowFeatureGenerator(new TokenClassFeatureGenerator(true), 2, 2),
new OutcomePriorFeatureGenerator(),
new PreviousMapFeatureGenerator(),
new BigramNameFeatureGenerator(),
- new SentenceFeatureGenerator(true, false));
+ new SentenceFeatureGenerator(true, false)));
}
return new AuxiliaryInfoNameContextGenerator(featureGenerator);
diff --git a/japanese/src/main/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGenerator.java b/japanese/src/main/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGenerator.java
index cf1fe7a..624a6bd 100644
--- a/japanese/src/main/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGenerator.java
+++ b/japanese/src/main/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGenerator.java
@@ -40,7 +40,7 @@ public class TokenPatternFeatureGenerator implements AdaptiveFeatureGenerator {
* For tokinization the {@link SimpleTokenizer} is used.
*/
public TokenPatternFeatureGenerator() {
- this(SimpleTokenizer.INSTANCE);
+ this(SimpleTokenizer.INSTANCE);
}
/**
diff --git a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/BigramNameFeatureGeneratorTest.java b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/BigramNameFeatureGeneratorTest.java
index 12407a5..83fdb18 100644
--- a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/BigramNameFeatureGeneratorTest.java
+++ b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/BigramNameFeatureGeneratorTest.java
@@ -20,11 +20,11 @@ package opennlp.tools.util.featuregen.lang.jpn;
import java.util.ArrayList;
import java.util.List;
-import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BigramNameFeatureGeneratorTest {
diff --git a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenClassFeatureGeneratorTest.java b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenClassFeatureGeneratorTest.java
index 96cd746..b7096eb 100644
--- a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenClassFeatureGeneratorTest.java
+++ b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenClassFeatureGeneratorTest.java
@@ -20,11 +20,11 @@ package opennlp.tools.util.featuregen.lang.jpn;
import java.util.ArrayList;
import java.util.List;
-import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TokenClassFeatureGeneratorTest {
@@ -46,9 +46,9 @@ public class TokenClassFeatureGeneratorTest {
generator.createFeatures(features, TEST_SENTENCE, testTokenIndex, null);
- assertEquals(2, features.size());
- assertEquals("wc=alpha", features.get(0));
- assertEquals("w&c=example,alpha", features.get(1));
+ assertEquals(2, features.size());
+ assertEquals("wc=alpha", features.get(0));
+ assertEquals("w&c=example,alpha", features.get(1));
}
@Test
@@ -60,7 +60,7 @@ public class TokenClassFeatureGeneratorTest {
generator.createFeatures(features, TEST_SENTENCE, testTokenIndex, null);
- assertEquals(1, features.size());
- assertEquals("wc=alpha", features.get(0));
+ assertEquals(1, features.size());
+ assertEquals("wc=alpha", features.get(0));
}
}
diff --git a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGeneratorTest.java b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGeneratorTest.java
index 3b84faf..de2fd26 100644
--- a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGeneratorTest.java
+++ b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TokenPatternFeatureGeneratorTest.java
@@ -20,11 +20,11 @@ package opennlp.tools.util.featuregen.lang.jpn;
import java.util.ArrayList;
import java.util.List;
-import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TokenPatternFeatureGeneratorTest {
diff --git a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TrigramNameFeatureGeneratorTest.java b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TrigramNameFeatureGeneratorTest.java
index 02bafb1..ba397db 100644
--- a/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TrigramNameFeatureGeneratorTest.java
+++ b/japanese/src/test/java/opennlp/tools/util/featuregen/lang/jpn/TrigramNameFeatureGeneratorTest.java
@@ -20,11 +20,11 @@ package opennlp.tools.util.featuregen.lang.jpn;
import java.util.ArrayList;
import java.util.List;
-import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TrigramNameFeatureGeneratorTest {
diff --git a/jwnl/src/main/java/opennlp/jwnl/lemmatizer/JWNLLemmatizer.java b/jwnl/src/main/java/opennlp/jwnl/lemmatizer/JWNLLemmatizer.java
index b85b2b8..aec822c 100644
--- a/jwnl/src/main/java/opennlp/jwnl/lemmatizer/JWNLLemmatizer.java
+++ b/jwnl/src/main/java/opennlp/jwnl/lemmatizer/JWNLLemmatizer.java
@@ -82,7 +82,7 @@ public class JWNLLemmatizer implements Lemmatizer {
} else if (postag.startsWith(constantTag)) {
lemma = word;
} else {
- lemma= word.toLowerCase();
+ lemma = word.toLowerCase();
}
} catch (JWNLException e) {
return null;
diff --git a/liblinear/src/main/java/LiblinearModel.java b/liblinear/src/main/java/LiblinearModel.java
index ea52e89..4eeb97f 100644
--- a/liblinear/src/main/java/LiblinearModel.java
+++ b/liblinear/src/main/java/LiblinearModel.java
@@ -1,20 +1,18 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
import java.io.ByteArrayInputStream;
@@ -33,13 +31,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import opennlp.tools.ml.model.MaxentModel;
-import opennlp.tools.util.model.SerializableArtifact;
import de.bwaldvogel.liblinear.Feature;
import de.bwaldvogel.liblinear.FeatureNode;
import de.bwaldvogel.liblinear.Linear;
import de.bwaldvogel.liblinear.Model;
+import opennlp.tools.ml.model.MaxentModel;
+import opennlp.tools.util.model.SerializableArtifact;
+
// TODO: The features need to be serialized with the model
// the liblinear model only contains the ints and weights,
// but the string labels get lost ... basically that are two maps.
@@ -88,7 +87,8 @@ public class LiblinearModel implements MaxentModel, SerializableArtifact {
predMap.put(key, value);
}
- model = Linear.loadModel(new InputStreamReader(new ByteArrayInputStream(modelBytes), LIBLINEAR_MODEL_ENCODING));
+ model = Linear.loadModel(
+ new InputStreamReader(new ByteArrayInputStream(modelBytes), LIBLINEAR_MODEL_ENCODING));
}
}
@@ -142,7 +142,7 @@ public class LiblinearModel implements MaxentModel, SerializableArtifact {
public String getBestOutcome(double[] ocs) {
int best = 0;
for (int i = 1; i < ocs.length; i++)
- if (ocs[i] > ocs[best]) best = i;
+ if (ocs[i] > ocs[best]) best = i;
return outcomeLabels[best];
}
diff --git a/liblinear/src/main/java/LiblinearModelSerializer.java b/liblinear/src/main/java/LiblinearModelSerializer.java
index 370e225..617fb6f 100644
--- a/liblinear/src/main/java/LiblinearModelSerializer.java
+++ b/liblinear/src/main/java/LiblinearModelSerializer.java
@@ -1,20 +1,18 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
import java.io.IOException;
diff --git a/liblinear/src/main/java/LiblinearTrainer.java b/liblinear/src/main/java/LiblinearTrainer.java
index dce4437..765dc1e 100644
--- a/liblinear/src/main/java/LiblinearTrainer.java
+++ b/liblinear/src/main/java/LiblinearTrainer.java
@@ -1,20 +1,18 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
import java.io.IOException;
@@ -30,7 +28,6 @@ import de.bwaldvogel.liblinear.Model;
import de.bwaldvogel.liblinear.Parameter;
import de.bwaldvogel.liblinear.Problem;
import de.bwaldvogel.liblinear.SolverType;
-import de.bwaldvogel.liblinear.Train;
import opennlp.tools.ml.AbstractEventTrainer;
import opennlp.tools.ml.model.DataIndexer;
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/DefaultModelBuilderUtil.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/DefaultModelBuilderUtil.java
index 72f5d46..e4e6075 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/DefaultModelBuilderUtil.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/DefaultModelBuilderUtil.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,6 +17,7 @@
package opennlp.addons.modelbuilder;
import java.io.File;
+
import opennlp.addons.modelbuilder.impls.BaseModelBuilderParams;
import opennlp.addons.modelbuilder.impls.FileKnownEntityProvider;
import opennlp.addons.modelbuilder.impls.FileModelValidatorImpl;
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/KnownEntityProvider.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/KnownEntityProvider.java
index 60104a1..2ce1391 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/KnownEntityProvider.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/KnownEntityProvider.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,10 +16,10 @@
*/
package opennlp.addons.modelbuilder;
-import opennlp.addons.modelbuilder.impls.BaseModelBuilderParams;
-
import java.util.Set;
+import opennlp.addons.modelbuilder.impls.BaseModelBuilderParams;
+
/**
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelGenerationValidator.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelGenerationValidator.java
index 16c11e0..68fcc04 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelGenerationValidator.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelGenerationValidator.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,10 +16,10 @@
*/
package opennlp.addons.modelbuilder;
-import opennlp.addons.modelbuilder.impls.BaseModelBuilderParams;
-
import java.util.Collection;
+import opennlp.addons.modelbuilder.impls.BaseModelBuilderParams;
+
/**
* Validates results from the iterative name finding.
*/
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelParameter.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelParameter.java
index 5bc8e15..e03dfd5 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelParameter.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/ModelParameter.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,7 +21,7 @@ import opennlp.addons.modelbuilder.impls.BaseModelBuilderParams;
/**
*
*/
-public interface ModelParameter<T extends BaseModelBuilderParams>{
+public interface ModelParameter<T extends BaseModelBuilderParams> {
void setParameters(T params);
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/Modelable.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/Modelable.java
index 36a33a9..fbfc508 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/Modelable.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/Modelable.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SemiSupervisedModelGenerator.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SemiSupervisedModelGenerator.java
index 3bb303a..d24f8bb 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SemiSupervisedModelGenerator.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SemiSupervisedModelGenerator.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SentenceProvider.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SentenceProvider.java
index 83af594..d7bc693 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SentenceProvider.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/SentenceProvider.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,6 +17,7 @@
package opennlp.addons.modelbuilder;
import java.util.Set;
+
import opennlp.addons.modelbuilder.impls.BaseModelBuilderParams;
/**
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/BaseModelBuilderParams.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/BaseModelBuilderParams.java
index fff456b..df52bee 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/BaseModelBuilderParams.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/BaseModelBuilderParams.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -87,4 +88,4 @@ public class BaseModelBuilderParams {
public void setAnnotatedTrainingDataFile(File annotatedTrainingDataFile) {
this.annotatedTrainingDataFile = annotatedTrainingDataFile;
}
-}
\ No newline at end of file
+}
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileKnownEntityProvider.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileKnownEntityProvider.java
index 1cb94b4..e4774c8 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileKnownEntityProvider.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileKnownEntityProvider.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileModelValidatorImpl.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileModelValidatorImpl.java
index 8b31d56..eee4c9f 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileModelValidatorImpl.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileModelValidatorImpl.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -43,7 +44,8 @@ public class FileModelValidatorImpl implements ModelGenerationValidator {
@Override
public Boolean validSentence(String sentence) {
- //returning true by default, because the sentence provider will return only "valid" sentences in this case
+ //returning true by default, because the sentence provider will return only "valid" sentences
+ // in this case
return true;
}
@@ -68,7 +70,7 @@ public class FileModelValidatorImpl implements ModelGenerationValidator {
}
if (!badentities.isEmpty()) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(
- new FileInputStream(params.getKnownEntityBlacklist()), StandardCharsets.UTF_8))){
+ new FileInputStream(params.getKnownEntityBlacklist()), StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
badentities.add(line);
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileSentenceProvider.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileSentenceProvider.java
index cb6715f..e783f50 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileSentenceProvider.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/FileSentenceProvider.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -37,9 +38,9 @@ public class FileSentenceProvider implements SentenceProvider {
@Override
public Set<String> getSentences() {
- if (sentences.isEmpty()) {
+ if (sentences.isEmpty()) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(
- new FileInputStream(params.getSentenceFile()), StandardCharsets.UTF_8))){
+ new FileInputStream(params.getSentenceFile()), StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
sentences.add(line);
@@ -51,7 +52,7 @@ public class FileSentenceProvider implements SentenceProvider {
return sentences;
}
- public void setParameters(BaseModelBuilderParams params) {
+ public void setParameters(BaseModelBuilderParams params) {
this.params = params;
}
}
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelGenerator.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelGenerator.java
index 358cef1..a0a8b08 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelGenerator.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelGenerator.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,6 +18,7 @@ package opennlp.addons.modelbuilder.impls;
import java.util.HashMap;
import java.util.Map;
+
import opennlp.addons.modelbuilder.KnownEntityProvider;
import opennlp.addons.modelbuilder.ModelGenerationValidator;
import opennlp.addons.modelbuilder.Modelable;
@@ -50,7 +52,8 @@ public class GenericModelGenerator implements SemiSupervisedModelGenerator {
for (String knownEntity : knownEntityProvider.getKnownEntities()) {
if (sentence.contains(knownEntity)) {
//if the same sentence has multiple hits should they be annotated separately?
- modelable.addAnnotatedSentence(modelable.annotate(sentence, knownEntity, knownEntityProvider.getKnownEntitiesType()));
+ modelable.addAnnotatedSentence(modelable.annotate(sentence, knownEntity,
+ knownEntityProvider.getKnownEntitiesType()));
}
}
}
@@ -64,13 +67,14 @@ public class GenericModelGenerator implements SemiSupervisedModelGenerator {
}
System.out.println("\t\twriting annotated sentences....: ");
modelable.writeAnnotatedSentences();
- System.out.println("\t\tbuilding model.... ");
+ System.out.println("\t\tbuilding model.... ");
modelable.buildModel(knownEntityProvider.getKnownEntitiesType());
System.out.println("\t\tmodel building complete.... ");
NameFinderME nf = new NameFinderME(modelable.getModel());
System.out.println("\t\tannotated sentences: " + modelable.getAnnotatedSentences().size());
System.out.println("\tPerforming NER with new model");
- System.out.println("\t\tPrinting NER Results. Add undesired results to the blacklist file and start over");
+ System.out.println(
+ "\t\tPrinting NER Results. Add undesired results to the blacklist file and start over");
for (String sentence : sentenceProvider.getSentences()) {
if (!validator.validSentence(sentence)) {
continue;
@@ -87,7 +91,8 @@ public class GenericModelGenerator implements SemiSupervisedModelGenerator {
if (validator.validNamedEntity(namedEntity)) {
knownEntityProvider.addKnownEntity(namedEntity);
- modelable.addAnnotatedSentence(modelable.annotate(sentence, namedEntity, knownEntityProvider.getKnownEntitiesType()));
+ modelable.addAnnotatedSentence(modelable.annotate(sentence, namedEntity,
+ knownEntityProvider.getKnownEntitiesType()));
} else {
System.out.println("\t\t" + namedEntity + "...already blacklisted");
diff --git a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelableImpl.java b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelableImpl.java
index b58af17..4d87ba7 100644
--- a/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelableImpl.java
+++ b/modelbuilder/src/main/java/opennlp/addons/modelbuilder/impls/GenericModelableImpl.java
@@ -1,11 +1,12 @@
/*
- * Copyright 2013 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,10 +17,10 @@
package opennlp.addons.modelbuilder.impls;
import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
-import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
@@ -87,7 +88,8 @@ public class GenericModelableImpl implements Modelable {
@Override
public void buildModel(String entityType) {
try (ObjectStream<NameSample> sampleStream = new NameSampleDataStream(new PlainTextByLineStream(
- new MarkableFileInputStreamFactory(params.getAnnotatedTrainingDataFile()), StandardCharsets.UTF_8));
+ new MarkableFileInputStreamFactory(params.getAnnotatedTrainingDataFile()),
+ StandardCharsets.UTF_8));
OutputStream modelOut = new BufferedOutputStream(new FileOutputStream(params.getModelFile()))) {
System.out.println("\tBuilding Model using " + annotatedSentences.size() + " annotations");
System.out.println("\t\treading training data...");
diff --git a/morfologik/src/main/java/opennlp/morfologik/cmdline/CLI.java b/morfologik/src/main/java/opennlp/morfologik/cmdline/CLI.java
index 5373ecd..53456b1 100644
--- a/morfologik/src/main/java/opennlp/morfologik/cmdline/CLI.java
+++ b/morfologik/src/main/java/opennlp/morfologik/cmdline/CLI.java
@@ -35,130 +35,130 @@ import opennlp.tools.util.Version;
public final class CLI {
- public static final String CMD = "opennlp-morfologik-addon";
-
- private static Map<String, CmdLineTool> toolLookupMap;
-
- static {
- toolLookupMap = new LinkedHashMap<>();
-
- List<CmdLineTool> tools = new LinkedList<>();
-
- tools.add(new MorfologikDictionaryBuilderTool());
- tools.add(new XMLDictionaryToTableTool());
-
- for (CmdLineTool tool : tools) {
- toolLookupMap.put(tool.getName(), tool);
- }
-
- toolLookupMap = Collections.unmodifiableMap(toolLookupMap);
- }
-
- /**
- * @return a set which contains all tool names
- */
- public static Set<String> getToolNames() {
- return toolLookupMap.keySet();
- }
-
- private static void usage() {
- System.out.print("OpenNLP Morfologik Addon "
- + Version.currentVersion().toString() + ". ");
- System.out.println("Usage: " + CMD + " TOOL");
- System.out.println("where TOOL is one of:");
-
- // distance of tool name from line start
- int numberOfSpaces = -1;
- for (String toolName : toolLookupMap.keySet()) {
- if (toolName.length() > numberOfSpaces) {
- numberOfSpaces = toolName.length();
- }
- }
- numberOfSpaces = numberOfSpaces + 4;
-
- for (CmdLineTool tool : toolLookupMap.values()) {
-
- System.out.print(" " + tool.getName());
-
- for (int i = 0; i < Math.abs(tool.getName().length()
- - numberOfSpaces); i++) {
- System.out.print(" ");
- }
-
- System.out.println(tool.getShortDescription());
- }
-
- System.out
- .println("All tools print help when invoked with help parameter");
- System.out
- .println("Example: opennlp-morfologik-addon POSDictionaryBuilder help");
- }
-
-
- @SuppressWarnings("rawtypes")
- public static void main(String[] args) {
-
- if (args.length == 0) {
- usage();
- System.exit(0);
- }
-
- String[] toolArguments = new String[args.length -1];
- System.arraycopy(args, 1, toolArguments, 0, toolArguments.length);
-
- String toolName = args[0];
-
- //check for format
- String formatName = StreamFactoryRegistry.DEFAULT_FORMAT;
- int idx = toolName.indexOf(".");
- if (-1 < idx) {
- formatName = toolName.substring(idx + 1);
- toolName = toolName.substring(0, idx);
- }
- CmdLineTool tool = toolLookupMap.get(toolName);
-
- try {
- if (null == tool) {
- throw new TerminateToolException(1, "Tool " + toolName + " is not found.");
- }
-
- if ((0 == toolArguments.length && tool.hasParams()) ||
- 0 < toolArguments.length && "help".equals(toolArguments[0])) {
- if (tool instanceof TypedCmdLineTool) {
- System.out.println(((TypedCmdLineTool) tool).getHelp(formatName));
- } else if (tool instanceof BasicCmdLineTool) {
- System.out.println(tool.getHelp());
- }
-
- System.exit(0);
- }
-
- if (tool instanceof TypedCmdLineTool) {
- ((TypedCmdLineTool) tool).run(formatName, toolArguments);
- } else if (tool instanceof BasicCmdLineTool) {
- if (-1 == idx) {
- ((BasicCmdLineTool) tool).run(toolArguments);
- } else {
- throw new TerminateToolException(1, "Tool " + toolName + " does not support formats.");
- }
- } else {
- throw new TerminateToolException(1, "Tool " + toolName + " is not supported.");
- }
- }
- catch (TerminateToolException e) {
-
- if (e.getMessage() != null) {
- System.err.println(e.getMessage());
- }
-
- if (e.getCause() != null) {
- System.err.println(e.getCause().getMessage());
- e.getCause().printStackTrace(System.err);
- }
-
- System.exit(e.getCode());
- }
- }
+ public static final String CMD = "opennlp-morfologik-addon";
+
+ private static Map<String, CmdLineTool> toolLookupMap;
+
+ static {
+ toolLookupMap = new LinkedHashMap<>();
+
+ List<CmdLineTool> tools = new LinkedList<>();
+
+ tools.add(new MorfologikDictionaryBuilderTool());
+ tools.add(new XMLDictionaryToTableTool());
+
+ for (CmdLineTool tool : tools) {
+ toolLookupMap.put(tool.getName(), tool);
+ }
+
+ toolLookupMap = Collections.unmodifiableMap(toolLookupMap);
+ }
+
+ /**
+ * @return a set which contains all tool names
+ */
+ public static Set<String> getToolNames() {
+ return toolLookupMap.keySet();
+ }
+
+ private static void usage() {
+ System.out.print("OpenNLP Morfologik Addon "
+ + Version.currentVersion().toString() + ". ");
+ System.out.println("Usage: " + CMD + " TOOL");
+ System.out.println("where TOOL is one of:");
+
+ // distance of tool name from line start
+ int numberOfSpaces = -1;
+ for (String toolName : toolLookupMap.keySet()) {
+ if (toolName.length() > numberOfSpaces) {
+ numberOfSpaces = toolName.length();
+ }
+ }
+ numberOfSpaces = numberOfSpaces + 4;
+
+ for (CmdLineTool tool : toolLookupMap.values()) {
+
+ System.out.print(" " + tool.getName());
+
+ for (int i = 0; i < Math.abs(tool.getName().length()
+ - numberOfSpaces); i++) {
+ System.out.print(" ");
+ }
+
+ System.out.println(tool.getShortDescription());
+ }
+
+ System.out
+ .println("All tools print help when invoked with help parameter");
+ System.out
+ .println("Example: opennlp-morfologik-addon POSDictionaryBuilder help");
+ }
+
+
+ @SuppressWarnings("rawtypes")
+ public static void main(String[] args) {
+
+ if (args.length == 0) {
+ usage();
+ System.exit(0);
+ }
+
+ String[] toolArguments = new String[args.length - 1];
+ System.arraycopy(args, 1, toolArguments, 0, toolArguments.length);
+
+ String toolName = args[0];
+
+ //check for format
+ String formatName = StreamFactoryRegistry.DEFAULT_FORMAT;
+ int idx = toolName.indexOf(".");
+ if (-1 < idx) {
+ formatName = toolName.substring(idx + 1);
+ toolName = toolName.substring(0, idx);
+ }
+ CmdLineTool tool = toolLookupMap.get(toolName);
+
+ try {
+ if (null == tool) {
+ throw new TerminateToolException(1, "Tool " + toolName + " is not found.");
+ }
+
+ if ((0 == toolArguments.length && tool.hasParams()) ||
+ 0 < toolArguments.length && "help".equals(toolArguments[0])) {
+ if (tool instanceof TypedCmdLineTool) {
+ System.out.println(((TypedCmdLineTool) tool).getHelp(formatName));
+ } else if (tool instanceof BasicCmdLineTool) {
+ System.out.println(tool.getHelp());
+ }
+
+ System.exit(0);
+ }
+
+ if (tool instanceof TypedCmdLineTool) {
+ ((TypedCmdLineTool) tool).run(formatName, toolArguments);
+ } else if (tool instanceof BasicCmdLineTool) {
+ if (-1 == idx) {
+ ((BasicCmdLineTool) tool).run(toolArguments);
+ } else {
+ throw new TerminateToolException(1, "Tool " + toolName + " does not support formats.");
+ }
+ } else {
+ throw new TerminateToolException(1, "Tool " + toolName + " is not supported.");
+ }
+ }
+ catch (TerminateToolException e) {
+
+ if (e.getMessage() != null) {
+ System.err.println(e.getMessage());
+ }
+
+ if (e.getCause() != null) {
+ System.err.println(e.getCause().getMessage());
+ e.getCause().printStackTrace(System.err);
+ }
+
+ System.exit(e.getCode());
+ }
+ }
}
diff --git a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderParams.java b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderParams.java
index 5ea2e4f..44e497c 100644
--- a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderParams.java
+++ b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderParams.java
@@ -28,30 +28,31 @@ import opennlp.tools.cmdline.params.EncodingParameter;
*/
interface MorfologikDictionaryBuilderParams extends EncodingParameter {
- @ParameterDescription(valueName = "in", description = "The input file (base,inflected,tag). An associated metadata (*.info) file must exist.")
+ @ParameterDescription(valueName = "in",
+ description = "The input file (base,inflected,tag). An associated metadata (*.info) file must exist.")
File getInputFile();
@ParameterDescription(valueName = "true|false", description = "Accept leading BOM bytes (UTF-8).")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getAcceptBOM();
@ParameterDescription(valueName = "true|false", description = "Accept CR bytes in input sequences (\r).")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getAcceptCR();
@ParameterDescription(valueName = "FSA5|CFSA2", description = "Automaton serialization format.")
- @OptionalParameter(defaultValue="FSA5")
+ @OptionalParameter(defaultValue = "FSA5")
String getFormat();
@ParameterDescription(valueName = "true|false", description = "Ignore empty lines in the input.")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getIgnoreEmpty();
@ParameterDescription(valueName = "true|false", description = "Overwrite the output file if it exists.")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getOverwrite();
@ParameterDescription(valueName = "true|false", description = "Validate input to make sure it makes sense.")
- @OptionalParameter(defaultValue="false")
+ @OptionalParameter(defaultValue = "false")
Boolean getValidate();
}
diff --git a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderTool.java b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderTool.java
index 923255f..c14bd63 100644
--- a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderTool.java
+++ b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/MorfologikDictionaryBuilderTool.java
@@ -21,6 +21,7 @@ import java.io.File;
import java.nio.file.Path;
import morfologik.stemming.DictionaryMetadata;
+
import opennlp.morfologik.builder.MorfologikDictionaryBuilder;
import opennlp.tools.cmdline.BasicCmdLineTool;
import opennlp.tools.cmdline.CmdLineUtil;
diff --git a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableParams.java b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableParams.java
index eb001dc..8aa4352 100644
--- a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableParams.java
+++ b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableParams.java
@@ -31,15 +31,18 @@ interface XMLDictionaryToTableParams extends EncodingParameter {
@ParameterDescription(valueName = "in", description = "OpenNLP XML Tag Dictionary.")
File getInputFile();
- @ParameterDescription(valueName = "out", description = "Output for Morfologik (.info will be also created).")
+ @ParameterDescription(valueName = "out",
+ description = "Output for Morfologik (.info will be also created).")
File getOutputFile();
@ParameterDescription(valueName = "char", description = "Column separator (must be a single character)")
- @OptionalParameter(defaultValue=",")
+ @OptionalParameter(defaultValue = ",")
String getSeparator();
- @ParameterDescription(valueName = "value", description = " Type of lemma-inflected form encoding compression that precedes automaton construction. Allowed values: [suffix, infix, prefix, none].")
- @OptionalParameter(defaultValue="prefix")
+ @ParameterDescription(valueName = "value",
+ description = " Type of lemma-inflected form encoding compression that precedes automaton"
+ + " construction. Allowed values: [suffix, infix, prefix, none].")
+ @OptionalParameter(defaultValue = "prefix")
String getEncoder();
}
diff --git a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableTool.java b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableTool.java
index 77e33bc..04e675a 100644
--- a/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableTool.java
+++ b/morfologik/src/main/java/opennlp/morfologik/cmdline/builder/XMLDictionaryToTableTool.java
@@ -28,6 +28,7 @@ import java.util.Iterator;
import java.util.Properties;
import morfologik.stemming.DictionaryMetadata;
+
import opennlp.tools.cmdline.BasicCmdLineTool;
import opennlp.tools.cmdline.CmdLineUtil;
import opennlp.tools.cmdline.TerminateToolException;
@@ -76,7 +77,7 @@ public class XMLDictionaryToTableTool extends BasicCmdLineTool {
while (iterator.hasNext()) {
String word = iterator.next();
for (String tag : tagDictionary.getTags(word)) {
- if(valid(word,tag)) {
+ if (valid(word,tag)) {
String entry = createEntry(word, tag);
writer.write(entry);
writer.newLine();
@@ -108,7 +109,7 @@ public class XMLDictionaryToTableTool extends BasicCmdLineTool {
}
private boolean valid(String word, String tag) {
- if(word.contains(SEPARATOR) || tag.contains(SEPARATOR)) {
+ if (word.contains(SEPARATOR) || tag.contains(SEPARATOR)) {
System.out.println("Warn: invalid entry because contains separator - word: "
+ word + " tag: " + tag);
return false;
@@ -118,7 +119,7 @@ public class XMLDictionaryToTableTool extends BasicCmdLineTool {
private String createEntry(String word, String tag) {
- String entry = SEPARATOR +// base
+ String entry = SEPARATOR + // base
word + SEPARATOR + tag;
return entry;
}
diff --git a/morfologik/src/main/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizer.java b/morfologik/src/main/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizer.java
index 421a82f..37a42d2 100644
--- a/morfologik/src/main/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizer.java
+++ b/morfologik/src/main/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizer.java
@@ -30,6 +30,7 @@ import morfologik.stemming.Dictionary;
import morfologik.stemming.DictionaryLookup;
import morfologik.stemming.IStemmer;
import morfologik.stemming.WordData;
+
import opennlp.tools.lemmatizer.Lemmatizer;
public class MorfologikLemmatizer implements Lemmatizer {
diff --git a/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikPOSTaggerFactory.java b/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikPOSTaggerFactory.java
index ee26cba..2694980 100644
--- a/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikPOSTaggerFactory.java
+++ b/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikPOSTaggerFactory.java
@@ -28,6 +28,7 @@ import java.nio.file.Path;
import java.util.Map;
import morfologik.stemming.DictionaryMetadata;
+
import opennlp.tools.postag.POSTaggerFactory;
import opennlp.tools.postag.TagDictionary;
import opennlp.tools.util.model.ArtifactSerializer;
@@ -52,13 +53,13 @@ public class MorfologikPOSTaggerFactory extends POSTaggerFactory {
@Override
public TagDictionary createTagDictionary(File dictionary) throws IOException {
- if(!dictionary.canRead()) {
+ if (!dictionary.canRead()) {
throw new FileNotFoundException("Could not read dictionary: " + dictionary.getAbsolutePath());
}
Path dictionaryMeta = DictionaryMetadata.getExpectedMetadataLocation(dictionary.toPath());
- if(dictionaryMeta == null || !dictionaryMeta.toFile().canRead()) {
+ if (dictionaryMeta == null || !dictionaryMeta.toFile().canRead()) {
throw new FileNotFoundException("Could not read dictionary metadata: " + dictionaryMeta.getFileName());
}
diff --git a/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikTagDictionary.java b/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikTagDictionary.java
index c5219c1..532149a 100644
--- a/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikTagDictionary.java
+++ b/morfologik/src/main/java/opennlp/morfologik/tagdict/MorfologikTagDictionary.java
@@ -25,6 +25,7 @@ import morfologik.stemming.Dictionary;
import morfologik.stemming.DictionaryLookup;
import morfologik.stemming.IStemmer;
import morfologik.stemming.WordData;
+
import opennlp.tools.postag.TagDictionary;
/**
diff --git a/morfologik/src/test/java/opennlp/morfologik/builder/POSDictionaryBuilderTest.java b/morfologik/src/test/java/opennlp/morfologik/builder/POSDictionaryBuilderTest.java
index 834447c..641508a 100644
--- a/morfologik/src/test/java/opennlp/morfologik/builder/POSDictionaryBuilderTest.java
+++ b/morfologik/src/test/java/opennlp/morfologik/builder/POSDictionaryBuilderTest.java
@@ -23,10 +23,10 @@ import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import morfologik.stemming.DictionaryMetadata;
-import opennlp.morfologik.lemmatizer.MorfologikLemmatizer;
-
import org.junit.jupiter.api.Test;
+import opennlp.morfologik.lemmatizer.MorfologikLemmatizer;
+
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class POSDictionaryBuilderTest {
diff --git a/morfologik/src/test/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizerTest.java b/morfologik/src/test/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizerTest.java
index 10f61ca..3a68914 100644
--- a/morfologik/src/test/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizerTest.java
+++ b/morfologik/src/test/java/opennlp/morfologik/lemmatizer/MorfologikLemmatizerTest.java
@@ -19,10 +19,10 @@ package opennlp.morfologik.lemmatizer;
import java.nio.file.Path;
-import opennlp.morfologik.builder.POSDictionaryBuilderTest;
-
import org.junit.jupiter.api.Test;
+import opennlp.morfologik.builder.POSDictionaryBuilderTest;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MorfologikLemmatizerTest {
diff --git a/morfologik/src/test/java/opennlp/morfologik/tagdict/MorfologikTagDictionaryTest.java b/morfologik/src/test/java/opennlp/morfologik/tagdict/MorfologikTagDictionaryTest.java
index 7e63e27..cf1d007 100644
--- a/morfologik/src/test/java/opennlp/morfologik/tagdict/MorfologikTagDictionaryTest.java
+++ b/morfologik/src/test/java/opennlp/morfologik/tagdict/MorfologikTagDictionaryTest.java
@@ -21,11 +21,11 @@ import java.util.Arrays;
import java.util.List;
import morfologik.stemming.Dictionary;
+import org.junit.jupiter.api.Test;
+
import opennlp.morfologik.builder.POSDictionaryBuilderTest;
import opennlp.tools.postag.TagDictionary;
-import org.junit.jupiter.api.Test;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -82,7 +82,8 @@ public class MorfologikTagDictionaryTest {
return this.createDictionary(caseSensitive, null);
}
- private MorfologikTagDictionary createDictionary(boolean caseSensitive, List<String> constant) throws Exception {
+ private MorfologikTagDictionary createDictionary(boolean caseSensitive, List<String> constant)
+ throws Exception {
Dictionary dic = Dictionary.read(POSDictionaryBuilderTest.createMorfologikDictionary());
return new MorfologikTagDictionary(dic, caseSensitive);
diff --git a/morfologik/src/test/java/opennlp/morfologik/tagdict/POSTaggerFactoryTest.java b/morfologik/src/test/java/opennlp/morfologik/tagdict/POSTaggerFactoryTest.java
index 871977d..b30caea 100644
--- a/morfologik/src/test/java/opennlp/morfologik/tagdict/POSTaggerFactoryTest.java
+++ b/morfologik/src/test/java/opennlp/morfologik/tagdict/POSTaggerFactoryTest.java
@@ -24,6 +24,8 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
+import org.junit.jupiter.api.Test;
+
import opennlp.morfologik.builder.POSDictionaryBuilderTest;
import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSSample;
@@ -37,11 +39,8 @@ import opennlp.tools.util.PlainTextByLineStream;
import opennlp.tools.util.TrainingParameters;
import opennlp.tools.util.model.ModelType;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
/**
* Tests for the {@link POSTaggerFactory} class.
@@ -85,4 +84,4 @@ public class POSTaggerFactoryTest {
TrainingParameters.defaultParams(), factory);
}
-}
\ No newline at end of file
+}
diff --git a/pom.xml b/pom.xml
index 7e8b496..a51318e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -254,9 +254,7 @@
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<testSourceDirectories>${project.basedir}/src/test/java</testSourceDirectories>
<violationSeverity>error</violationSeverity>
- <!-- Reports without breaking the build. The existing sources predate these rules;
- a follow-up brings them into line and then turns this on. -->
- <failOnViolation>false</failOnViolation>
+ <failOnViolation>true</failOnViolation>
</configuration>
<goals>
<goal>check</goal>