camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [7/8] camel git commit: CAMEL-9434: camel-catalog - did you mean
Date Wed, 23 Dec 2015 11:45:27 GMT
CAMEL-9434: camel-catalog - did you mean


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f9c94549
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f9c94549
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f9c94549

Branch: refs/heads/camel-2.16.x
Commit: f9c9454979f9ba8780c6205a847fa8bed2ba284e
Parents: 9c7bb64
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Dec 23 12:41:54 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Dec 23 12:45:01 2015 +0100

----------------------------------------------------------------------
 apache-camel/pom.xml                                    |  4 ++++
 apache-camel/src/main/descriptors/common-bin.xml        |  1 +
 parent/pom.xml                                          |  5 +++++
 platforms/catalog-lucene/pom.xml                        |  8 --------
 .../camel/catalog/lucene/LuceneSuggestionStrategy.java  | 10 ++++++++--
 .../org/apache/camel/catalog/SuggestionStrategy.java    | 12 ++++++------
 6 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f9c94549/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 4b57d79..7e83b6b 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -894,6 +894,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-catalog-lucene</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-commands-core</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/f9c94549/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 3b7aa4b..cdf3f08 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -234,6 +234,7 @@
         <include>org.apache.camel:camel-zipfile</include>
         <include>org.apache.camel:camel-zookeeper</include>
         <include>org.apache.camel:camel-catalog</include>
+        <include>org.apache.camel:camel-catalog-lucene</include>
         <include>org.apache.camel:camel-commands-core</include>
         <include>org.apache.camel:camel-commands-jolokia</include>
         <include>org.apache.camel.karaf:camel-karaf-commands</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/f9c94549/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index ca8fa59..75b5966 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1686,6 +1686,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-catalog-lucene</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-commands-core</artifactId>
         <version>${project.version}</version>
       </dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/f9c94549/platforms/catalog-lucene/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-lucene/pom.xml b/platforms/catalog-lucene/pom.xml
index d211db9..1eb9bff 100644
--- a/platforms/catalog-lucene/pom.xml
+++ b/platforms/catalog-lucene/pom.xml
@@ -53,14 +53,6 @@
       <version>${lucene-version}</version>
     </dependency>
 
-    <!-- testing -->
-    <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-databind</artifactId>
-      <version>${jackson2-version}</version>
-      <scope>test</scope>
-    </dependency>
-
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>

http://git-wip-us.apache.org/repos/asf/camel/blob/f9c94549/platforms/catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java
b/platforms/catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java
index e8cae13..5ed183f 100644
--- a/platforms/catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java
+++ b/platforms/catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java
@@ -28,11 +28,16 @@ import org.apache.lucene.store.RAMDirectory;
 
 /**
  * Apache Lucene based {@link SuggestionStrategy}.
+ * <p/>
+ * This is a simple implementation using in-memory directory and no state.
  */
 public class LuceneSuggestionStrategy implements SuggestionStrategy {
 
+    private int maxSuggestions = 5;
+
     @Override
-    public String[] suggestEndpointOptions(Set<String> names, String option) {
+    public String[] suggestEndpointOptions(Set<String> names, String unknownOption)
{
+        // each option must be on a separate line in a String
         StringBuilder sb = new StringBuilder();
         for (String name : names) {
             sb.append(name);
@@ -43,12 +48,13 @@ public class LuceneSuggestionStrategy implements SuggestionStrategy {
         try {
             PlainTextDictionary words = new PlainTextDictionary(reader);
 
+            // use in-memory lucene spell checker to make the suggestions
             RAMDirectory dir = new RAMDirectory();
             SpellChecker checker = new SpellChecker(dir);
             checker.indexDictionary(words, new IndexWriterConfig(new StandardAnalyzer()),
false);
 
             // suggest up to 5 names
-            return checker.suggestSimilar(option, 5);
+            return checker.suggestSimilar(unknownOption, maxSuggestions);
         } catch (Exception e) {
             // ignore
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/f9c94549/platforms/catalog/src/main/java/org/apache/camel/catalog/SuggestionStrategy.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/SuggestionStrategy.java
b/platforms/catalog/src/main/java/org/apache/camel/catalog/SuggestionStrategy.java
index 90faa49..9b6dfce 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/SuggestionStrategy.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/SuggestionStrategy.java
@@ -5,9 +5,9 @@
  * 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
- *
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
  * 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.
@@ -26,9 +26,9 @@ public interface SuggestionStrategy {
     /**
      * Provides a list of valid option names for a did you mean function.
      *
-     * @param names  valid names
-     * @param option unknown option name
+     * @param names         valid names
+     * @param unknownOption unknown option name
      * @return a list of suggested names (did you mean)
      */
-    String[] suggestEndpointOptions(Set<String> names, String option);
+    String[] suggestEndpointOptions(Set<String> names, String unknownOption);
 }


Mime
View raw message