Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC5C118E72 for ; Wed, 23 Dec 2015 11:45:21 +0000 (UTC) Received: (qmail 16052 invoked by uid 500); 23 Dec 2015 11:45:21 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 15890 invoked by uid 500); 23 Dec 2015 11:45:21 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 15817 invoked by uid 99); 23 Dec 2015 11:45:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Dec 2015 11:45:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 70AB8E01C1; Wed, 23 Dec 2015 11:45:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Wed, 23 Dec 2015 11:45:23 -0000 Message-Id: <5b8ae256dd114c4fae9b44c1aca0817c@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/8] camel git commit: CAMEL-9434: camel-catalog - did you mean 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/2e502e44 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2e502e44 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2e502e44 Branch: refs/heads/master Commit: 2e502e446713650c46983dc4a153b7c37d288d11 Parents: 758327f Author: Claus Ibsen Authored: Wed Dec 23 12:41:54 2015 +0100 Committer: Claus Ibsen Committed: Wed Dec 23 12:41:54 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/2e502e44/apache-camel/pom.xml ---------------------------------------------------------------------- diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index 61fcee9..6a54092 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -898,6 +898,10 @@ org.apache.camel + camel-catalog-lucene + + + org.apache.camel camel-commands-core http://git-wip-us.apache.org/repos/asf/camel/blob/2e502e44/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 09585d4..9d2e447 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -235,6 +235,7 @@ org.apache.camel:camel-zipfile org.apache.camel:camel-zookeeper org.apache.camel:camel-catalog + org.apache.camel:camel-catalog-lucene org.apache.camel:camel-commands-core org.apache.camel:camel-commands-jolokia org.apache.camel:camel-commands-spring-boot http://git-wip-us.apache.org/repos/asf/camel/blob/2e502e44/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index c05db62..f2e3db2 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1700,6 +1700,11 @@ org.apache.camel + camel-catalog-lucene + ${project.version} + + + org.apache.camel camel-commands-core ${project.version} http://git-wip-us.apache.org/repos/asf/camel/blob/2e502e44/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 @@ ${lucene-version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson2-version} - test - - junit junit http://git-wip-us.apache.org/repos/asf/camel/blob/2e502e44/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}. + *

+ * 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 names, String option) { + public String[] suggestEndpointOptions(Set 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/2e502e44/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 - * + *

+ * 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. @@ -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 names, String option); + String[] suggestEndpointOptions(Set names, String unknownOption); }