This is an automated email from the ASF dual-hosted git repository.

mawiesne pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opennlp-addons.git


The following commit(s) were added to refs/heads/main by this push:
     new 0327b14  Bump org.apache.lucene:lucene-core from 6.0.0 to 7.7.3 (#83)
0327b14 is described below

commit 0327b142296379739fd3da5c2a692bd4e3cf8f0c
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
AuthorDate: Mon May 26 12:05:01 2025 +0200

    Bump org.apache.lucene:lucene-core from 6.0.0 to 7.7.3 (#83)
    
    * Bump org.apache.lucene:lucene-core from 6.0.0 to 7.7.3
    
    - bumps org.apache.lucene:lucene-core from 6.0.0 to 7.7.3.
    - fixes compile errors due to package relocation since Lucene 7.x for 
`CharArraySet` class
    - introduces common Lucene property in geoentitylinker-addon's `pom.xml`
    - optimizes imports in `GazetteerIndexer` and `GazetteerSearcher`
    
    ---
    updated-dependencies:
    - dependency-name: org.apache.lucene:lucene-core
      dependency-version: 7.7.3
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    
    * - fixes compile errors due to package relocation since Lucene 7.x for 
CharArraySet class
    - introduces common Lucene property in geoentitylinker-addon's pom.xml
    - optimizes imports in GazetteerIndexer and GazetteerSearcher
    
    ---------
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] 
<49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Martin Wiesner <[email protected]>
---
 geoentitylinker-addon/pom.xml                      | 17 ++++++----
 .../addons/geoentitylinker/GazetteerSearcher.java  | 11 ++++---
 .../geoentitylinker/indexing/GazetteerIndexer.java | 38 ++++++++++------------
 3 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/geoentitylinker-addon/pom.xml b/geoentitylinker-addon/pom.xml
index 35fc56c..ae0da35 100644
--- a/geoentitylinker-addon/pom.xml
+++ b/geoentitylinker-addon/pom.xml
@@ -33,6 +33,11 @@
     <packaging>jar</packaging>
     <name>Apache OpenNLP GeoentityLinker Addon</name>
 
+    <properties>
+        <lucene.version>7.7.3</lucene.version>
+        <spatial4j.version>0.5</spatial4j.version>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.opennlp</groupId>
@@ -42,35 +47,33 @@
         <dependency>
             <groupId>org.apache.lucene</groupId>
             <artifactId>lucene-core</artifactId>
-            <version>6.0.0</version>
+            <version>${lucene.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.lucene</groupId>
             <artifactId>lucene-analyzers-common</artifactId>
-            <version>6.0.0</version>
+            <version>${lucene.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.lucene</groupId>
             <artifactId>lucene-queryparser</artifactId>
-            <version>6.0.0</version>
+            <version>${lucene.version}</version>
         </dependency>
         <dependency>
             <groupId>com.spatial4j</groupId>
             <artifactId>spatial4j</artifactId>
-            <version>0.5</version>
-            <type>jar</type>
+            <version>${spatial4j.version}</version>
         </dependency>
 
+        <!-- TEST scope -->
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-api</artifactId>
         </dependency>
-
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-engine</artifactId>
         </dependency>
-
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-params</artifactId>
diff --git 
a/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java
 
b/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java
index 804432a..19ebf4f 100644
--- 
a/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java
+++ 
b/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/GazetteerSearcher.java
@@ -23,27 +23,28 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
 import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.CharArraySet;
+import org.apache.lucene.analysis.core.KeywordAnalyzer;
+import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.queryparser.classic.ParseException;
-
 import org.apache.lucene.queryparser.classic.QueryParser;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MMapDirectory;
-import opennlp.tools.entitylinker.EntityLinkerProperties;
-import org.apache.lucene.analysis.core.KeywordAnalyzer;
-import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
-import org.apache.lucene.analysis.util.CharArraySet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import opennlp.tools.entitylinker.EntityLinkerProperties;
+
 /**
  *
  * Searches Gazetteers stored in a MMapDirectory Lucene index. The structure of
diff --git 
a/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java
 
b/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java
index a640c5d..394da00 100644
--- 
a/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java
+++ 
b/geoentitylinker-addon/src/main/java/opennlp/addons/geoentitylinker/indexing/GazetteerIndexer.java
@@ -21,21 +21,24 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.nio.file.Paths;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.CharArraySet;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.util.CharArraySet;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MMapDirectory;
 
+import opennlp.addons.geoentitylinker.GeoEntityLinker;
+
 /**
- * Creates two lucene indexes, geonames and usgs for use in GeoEntityLinker.
+ * Creates two lucene indexes, geonames and usgs for use in {@link 
GeoEntityLinker}.
+ *
+ * @see GeoEntityLinker
  */
 public class GazetteerIndexer {
 
@@ -143,16 +146,15 @@ public class GazetteerIndexer {
     String indexloc = outputIndexDir.getPath() + 
"/opennlp_geoentitylinker_gazetteer";
     Directory index = new MMapDirectory(Paths.get(indexloc));
     Analyzer a = new StandardAnalyzer(new CharArraySet(new ArrayList<>(), 
true));
-    Map<String, Analyzer> analyMap = new HashMap<>();
-
-    analyMap.put("countrycode", new KeywordAnalyzer());
-    analyMap.put("admincode", new KeywordAnalyzer());
-    analyMap.put("loctype", new KeywordAnalyzer());
-    analyMap.put("countycode", new KeywordAnalyzer());
-    analyMap.put("gazsource", new KeywordAnalyzer());
-
-    PerFieldAnalyzerWrapper aWrapper = new PerFieldAnalyzerWrapper(a, 
analyMap);
-    IndexWriterConfig config = new IndexWriterConfig(aWrapper);
+    Map<String, Analyzer> analyMap = Map.of(
+            "countcode", new KeywordAnalyzer(),
+            "admincode", new KeywordAnalyzer(),
+            "loctype", new KeywordAnalyzer(),
+            "countycode", new KeywordAnalyzer(),
+            "gazsource", new KeywordAnalyzer());
+
+    final PerFieldAnalyzerWrapper aWrapper = new PerFieldAnalyzerWrapper(a, 
analyMap);
+    final IndexWriterConfig config = new IndexWriterConfig(aWrapper);
     try (IndexWriter w = new IndexWriter(index, config)) {
       //write the column headers for the countryContextFile
       try (FileWriter writer = new FileWriter(outputCountryContextFile, 
false)) {
@@ -192,14 +194,8 @@ public class GazetteerIndexer {
 
     try {
       GazetteerIndexer i = new GazetteerIndexer();
-      i.index(geonamesData,
-              geoNamesCountryInfo,
-              geonamesAdmin1CodesASCII,
-              usgsDataFile,
-              usgsGovUnitsFile,
-              outputIndexDir,
-              outputCountryContextFile,
-              regionsFile);
+      i.index(geonamesData, geoNamesCountryInfo, geonamesAdmin1CodesASCII,
+              usgsDataFile, usgsGovUnitsFile, outputIndexDir, 
outputCountryContextFile, regionsFile);
     } catch (Exception ex) {
       ex.printStackTrace();
     }

Reply via email to