You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/01/03 17:56:36 UTC

svn commit: r1428467 [1/4] - in /stanbol/trunk/commons/solr/extras: paoding/ paoding/src/ paoding/src/main/ paoding/src/main/java/ paoding/src/main/java/net/ paoding/src/main/java/net/paoding/ paoding/src/main/java/net/paoding/analysis/ paoding/src/mai...

Author: rwesten
Date: Thu Jan  3 16:56:34 2013
New Revision: 1428467

URL: http://svn.apache.org/viewvc?rev=1428467&view=rev
Log:
STANBOL-875: Adds the stanbol paoding fork including some changes required to run it as OSGI bundle

Added:
    stanbol/trunk/commons/solr/extras/paoding/   (with props)
    stanbol/trunk/commons/solr/extras/paoding/README.md
    stanbol/trunk/commons/solr/extras/paoding/pom.xml
    stanbol/trunk/commons/solr/extras/paoding/src/
    stanbol/trunk/commons/solr/extras/paoding/src/main/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/Constants.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzer.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzerBean.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingTokenizer.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/TokenCollector.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/Estimate.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/TryPaodingAnalyzer.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/CompiledFileDictionaries.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MaxWordLengthTokenCollector.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MostWordsModeDictionariesCompiler.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MostWordsTokenCollector.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/SortingDictionariesCompiler.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/BinaryDictionary.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/Dictionary.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/DictionaryDelegate.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/HashBinaryDictionary.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/Hit.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/Word.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/detection/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/detection/Detector.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/detection/Difference.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/detection/DifferenceListener.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/detection/ExtensionFileFilter.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/detection/Node.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/detection/Snapshot.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/filewords/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/filewords/FileWordsReader.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/filewords/ReadListener.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/filewords/SimpleReadListener.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/dictionary/support/filewords/SimpleReadListener2.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/exception/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/exception/PaodingAnalysisException.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/Beef.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/CJKKnife.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/CharSet.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/Collector.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/CollectorStdoutImpl.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/CombinatoricsKnife.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/Dictionaries.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/DictionariesCompiler.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/DictionariesWare.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/FakeKnife.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/FileDictionaries.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/FileDictionariesDifferenceListener.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/Knife.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/KnifeBox.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/LetterKnife.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/NumberKnife.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/Paoding.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/PaodingMaker.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/knife/SmartKnifeBox.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/apache/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/apache/stanbol/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/apache/stanbol/commons/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/apache/stanbol/commons/solr/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/apache/stanbol/commons/solr/extras/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/apache/stanbol/commons/solr/extras/paoding/
    stanbol/trunk/commons/solr/extras/paoding/src/main/java/org/apache/stanbol/commons/solr/extras/paoding/Activator.java
    stanbol/trunk/commons/solr/extras/paoding/src/main/resources/
    stanbol/trunk/commons/solr/extras/paoding/src/main/resources/paoding-analysis.properties
    stanbol/trunk/commons/solr/extras/paoding/src/main/resources/paoding-dict.zip   (with props)
Modified:
    stanbol/trunk/commons/solr/extras/smartcn/   (props changed)
    stanbol/trunk/commons/solr/extras/stempel/   (props changed)

Propchange: stanbol/trunk/commons/solr/extras/paoding/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan  3 16:56:34 2013
@@ -0,0 +1,7 @@
+.settings
+
+.classpath
+
+target
+
+.project

Added: stanbol/trunk/commons/solr/extras/paoding/README.md
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/README.md?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/README.md (added)
+++ stanbol/trunk/commons/solr/extras/paoding/README.md Thu Jan  3 16:56:34 2013
@@ -0,0 +1,59 @@
+<!--
+  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.
+-->
+
+
+Apache Stanbol Commons Solr extension for paoding-analysis 
+=========================================================
+
+This module provides the [paoding-analysis](http://code.google.com/p/paoding/) analyzer for Chinese as bundle extending the default Apache Stanbol Commons Solr core module.
+
+paoding-analysis version
+----------------------
+
+This modules includes an fork from revision 154 of the the [paoding-analysis](http://code.google.com/p/paoding/) projects [svn repository](http://paoding.googlecode.com/svn/trunk/).
+
+The last commit to this projects repository was in [Nov 15, 2010](https://code.google.com/p/paoding/source/detail?r=154). The project is under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
+
+Changes to the original paoding source
+--------
+
+This provides an overview on all changes made to the paoding source code (anything in the  <code>net.paoding.*</code> packages)
+
+* The Logging framework was changed to SLF4J as this is the one preferable used by Stanbol
+* Resources are now loaded via both the ContextClassloader and (if not present) the Classloader used to load the padding classes. Originally the Classloader of the paoding classes was only considered if the ContextClassloader was <code>null</code>
+* Environment properties can now also be loaded from Java system properties (e.g. parsed via the -D argument to the JVM). System properties are only considered if no Environment property is defined.
+
+
+Dictionary
+----------
+
+The dictionary is included in the module in an ZIP archive. The <code>org.apache.stanbol.commons.solr.extras.paoding.Activator</code> class can be used to initialize the dictionary. When using this module in OSGI this will be done automatically by the Bundle Activator. Outside of OSGI (e.g. for unit test) this needs to be done manually by calling:
+
+    :::java
+    File paodingDict; //the directory for the dict
+    if(!paodingDict.isDirectory()){
+        Activator.initPaodingDictionary(paodingDict, 
+            getClass().getClassLoader().getResourceAsStream(
+                Activator.DICT_ARCHIVE));
+    }
+    Activator.initPaodingDictHomeProperty(paodingDict);
+
+All initialization methods supported by paoding are still supported. In addition the dictionary location can now also be parsed as Java system property (e.g. by adding '-DPAODING_DIC_HOME={path}' when starting the JVM). 
+
+This module also includes an default '<code>paoding-analysis.properties</code>' file that sets the default dictionary path to '.' (the working directory). Users can use their own dictionary file if they place it in the classpath in front of this module. 
+
+

Added: stanbol/trunk/commons/solr/extras/paoding/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/pom.xml?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/pom.xml (added)
+++ stanbol/trunk/commons/solr/extras/paoding/pom.xml Thu Jan  3 16:56:34 2013
@@ -0,0 +1,123 @@
+<?xml version="1.0"?>
+  <!--
+    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.
+  -->
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.stanbol</groupId>
+    <artifactId>stanbol-parent</artifactId>
+    <version>2-SNAPSHOT</version>
+    <relativePath>../../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.solr.extras.paoding</artifactId>
+  <version>0.10.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <name>Stanbol Commons Solr Extension for Paoding Analysis</name>
+  <description>This provides an Solr Analyzer for Chinese including dictionary as
+    OSGI bundle. This includes a forced version of the Paoding code base.</description>
+
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/stanbol/trunk/ext/
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/stanbol/trunk/ext/
+    </developerConnection>
+    <url>http://stanbol.apache.org</url>
+  </scm>
+
+  <build>
+    <!-- make it an OSGi bundle -->
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <!-- 
+             The Bundle Activator copies the dictionary to the persistent
+             location of the bundle and sets up the paoding analyzers to use
+             this directory.
+             -->
+            <Bundle-Activator>
+              org.apache.stanbol.commons.solr.extras.paoding.Activator
+            </Bundle-Activator>
+            <Embed-Dependency>paoding-analysis</Embed-Dependency>
+            <Import-Package>*</Import-Package>
+            <!--
+             For now export all paoding packages.This might however change
+             -->
+            <Export-Package>
+              org.apache.stanbol.commons.solr.extras.paoding;version=${project.version}
+              net.paoding.analysis;version=2.0.4,
+              net.paoding.analysis.analyzer;version=2.0.4,
+              net.paoding.analysis.knife;version=2.0.4,
+              net.paoding.analysis.analyzer.*;version=2.0.4,
+              net.paoding.analysis.dictionar.*version=2.0.4
+            </Export-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-core</artifactId>
+      <version>3.6.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-analyzers</artifactId>
+      <version>3.6.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+      <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.compendium</artifactId>
+        <scope>provided</scope>
+      </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-compress</artifactId>
+    </dependency>
+
+    <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/Constants.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/Constants.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/Constants.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/Constants.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,118 @@
+package net.paoding.analysis;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * 
+ * @author Zhiliang Wang [qieqie.wang@gmail.com]
+ * 
+ * @since 2.0.0
+ */
+public class Constants {
+
+	/**
+	 * "词典目录安装目录"配置的优先级别
+	 * <p>
+	 * "system-env"以及其他非"this"的配置,表示优先从环境变量PAODING_DIC_HOME的值找词典目录安装环境
+	 * "this"表示优先从本配置文件的paoding.dic.home配置项找<br>
+	 * 只有在高优先级没有配置,才会找低优先级的配置。 默认环境变量的优先级别高于paoding-analysis.properties属性文件配置。
+	 */
+	public static final String DIC_HOME_CONFIG_FIRST = "paoding.dic.home.config-first";
+	public static final String DIC_HOME_CONFIG_FIRST_DEFAULT = "system-env";
+
+	/**
+	 * 词典安装目录环境变量名
+	 */
+	public static final String ENV_PAODING_DIC_HOME = "PAODING_DIC_HOME";
+
+	// -------------------------------------------------------------
+	/**
+	 * 词典安装目录
+	 * <p>
+	 * 默认值为null,以在环境变量和配置文件都没有配置paoding.dic.home的情况下,让PaodingMaker尝试从当前工作目录下、类路径下探索是否存在dic目录
+	 */
+	public static final String DIC_HOME = "paoding.dic.home";
+	public static final String DIC_HOME_DEFAULT = null;
+
+	// -------------------------------------------------------------
+	//
+	public static final String DIC_CHARSET = "paoding.dic.charset";
+	public static final String DIC_CHARSET_DEFAULT = "UTF-8";
+
+	// dictionary word length limit
+	public static final String DIC_MAXWORDLEN = "paoding.dic.maxWordLen";
+	public static final String DIC_MAXWORDLEN_DEFAULT = "0";
+	
+	// -------------------------------------------------------------
+	// dictionaries which are skip
+	public static final String DIC_SKIP_PREFIX = "paoding.dic.skip.prefix";
+	public static final String DIC_SKIP_PREFIX_DEFAULT = "x-";
+
+	// -------------------------------------------------------------
+	// chinese/cjk charactors that will not token
+	public static final String DIC_NOISE_CHARACTOR = "paoding.dic.noise-charactor";
+	public static final String DIC_NOISE_CHARACTOR_DEFAULT = "x-noise-charactor";
+
+	// -------------------------------------------------------------
+	// chinese/cjk words that will not token
+	public static final String DIC_NOISE_WORD = "paoding.dic.noise-word";
+	public static final String DIC_NOISE_WORD_DEFAULT = "x-noise-word";
+
+	// -------------------------------------------------------------
+	// unit words, like "ge", "zhi", ...
+	public static final String DIC_UNIT = "paoding.dic.unit";
+	public static final String DIC_UNIT_DEFAULT = "x-unit";
+
+	// -------------------------------------------------------------
+	// like "Wang", "Zhang", ...
+	public static final String DIC_CONFUCIAN_FAMILY_NAME = "paoding.dic.confucian-family-name";
+	public static final String DIC_CONFUCIAN_FAMILY_NAME_DEFAULT = "x-confucian-family-name";
+	
+	// -------------------------------------------------------------
+	// like 
+	public static final String DIC_FOR_COMBINATORICS = "paoding.dic.for-combinatorics";
+	public static final String DIC_FOR_COMBINATORICS_DEFAULT = "x-for-combinatorics";
+
+	// -------------------------------------------------------------
+	// like 
+	public static final String DIC_DETECTOR_INTERVAL = "paoding.dic.detector.interval";
+	public static final String DIC_DETECTOR_INTERVAL_DEFAULT = "60";
+
+	// -------------------------------------------------------------
+	// like "default", "max", ...
+	public static final String ANALYZER_MODE = "paoding.analyzer.mode";
+	public static final String ANALYZER_MOE_DEFAULT = "most-words";
+
+	// -------------------------------------------------------------
+	// 
+	public static final String ANALYZER_DICTIONARIES_COMPILER = "paoding.analyzer.dictionaries.compiler";
+	public static final String ANALYZER_DICTIONARIES_COMPILER_DEFAULT = null;
+
+	// -------------------------------------------------------------
+	private static final Map/* <String, String> */map = new HashMap();
+
+	static {
+		map.put(DIC_HOME_CONFIG_FIRST, DIC_HOME_CONFIG_FIRST_DEFAULT);
+		map.put(DIC_HOME, DIC_HOME_DEFAULT);
+		map.put(DIC_CHARSET, DIC_CHARSET_DEFAULT);
+		map.put(DIC_MAXWORDLEN, DIC_MAXWORDLEN_DEFAULT);
+		map.put(DIC_SKIP_PREFIX, DIC_SKIP_PREFIX_DEFAULT);
+		map.put(DIC_NOISE_CHARACTOR, DIC_NOISE_CHARACTOR_DEFAULT);
+		map.put(DIC_NOISE_WORD, DIC_NOISE_WORD_DEFAULT);
+		map.put(DIC_UNIT, DIC_UNIT_DEFAULT);
+		map.put(DIC_CONFUCIAN_FAMILY_NAME, DIC_CONFUCIAN_FAMILY_NAME_DEFAULT);
+		map.put(DIC_FOR_COMBINATORICS, DIC_FOR_COMBINATORICS_DEFAULT);
+		map.put(DIC_DETECTOR_INTERVAL, DIC_DETECTOR_INTERVAL_DEFAULT);
+		map.put(ANALYZER_MODE, ANALYZER_MOE_DEFAULT);
+		map.put(ANALYZER_DICTIONARIES_COMPILER, ANALYZER_DICTIONARIES_COMPILER_DEFAULT);
+	}
+
+	//
+	public static final String KNIFE_CLASS = "paoding.knife.class.";
+
+	public static String getProperty(Properties p, String name) {
+		return p.getProperty(name, (String) map.get(name));
+	}
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzer.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzer.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzer.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzer.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,153 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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
+ *
+ * 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.
+ */
+package net.paoding.analysis.analyzer;
+
+import java.util.Properties;
+
+import net.paoding.analysis.Constants;
+import net.paoding.analysis.analyzer.estimate.TryPaodingAnalyzer;
+import net.paoding.analysis.knife.Knife;
+import net.paoding.analysis.knife.Paoding;
+import net.paoding.analysis.knife.PaodingMaker;
+
+/**
+ * PaodingAnalyzer是基于“庖丁解牛”框架的Lucene词语分析器,是“庖丁解牛”框架对Lucene的适配器。
+ * <p>
+ * 
+ * PaodingAnalyzer是线程安全的:并发情况下使用同一个PaodingAnalyzer实例是可行的。<br>
+ * PaodingAnalyzer是可复用的:推荐多次同一个PaodingAnalyzer实例。
+ * <p>
+ * 
+ * PaodingAnalyzer自动读取类路径下的paoding-analysis.properties属性文件,装配PaodingAnalyzer
+ * <p>
+ * 
+ * @author Zhiliang Wang [qieqie.wang@gmail.com]
+ * 
+ * @see PaodingAnalyzerBean
+ * 
+ * @since 1.0
+ * 
+ */
+public class PaodingAnalyzer extends PaodingAnalyzerBean {
+
+	/**
+	 * 根据类路径下的paoding-analysis.properties构建一个PaodingAnalyzer对象
+	 * <p>
+	 * 在一个JVM中,可多次创建,而并不会多次读取属性文件,不会重复读取字典。
+	 */
+	public PaodingAnalyzer() {
+		this(PaodingMaker.DEFAULT_PROPERTIES_PATH);
+	}
+
+	/**
+	 * @param propertiesPath null表示使用类路径下的paoding-analysis.properties
+	 */
+	public PaodingAnalyzer(String propertiesPath) {
+		init(propertiesPath);
+	}
+
+	protected void init(String propertiesPath) {
+		// 根据PaodingMaker说明,
+		// 1、多次调用getProperties(),返回的都是同一个properties实例(只要属性文件没发生过修改)
+		// 2、相同的properties实例,PaodingMaker也将返回同一个Paoding实例
+		// 根据以上1、2点说明,在此能够保证多次创建PaodingAnalyzer并不会多次装载属性文件和词典
+		if (propertiesPath == null) {
+			propertiesPath = PaodingMaker.DEFAULT_PROPERTIES_PATH;
+		}
+		Properties properties = PaodingMaker.getProperties(propertiesPath);
+		String mode = Constants
+				.getProperty(properties, Constants.ANALYZER_MODE);
+		Paoding paoding = PaodingMaker.make(properties);
+		setKnife(paoding);
+		setMode(mode);
+	}
+
+	/**
+	 * 本方法为PaodingAnalyzer附带的测试评估方法。 <br>
+	 * 执行之可以查看分词效果。以下任选一种方式进行:
+	 * <p>
+	 * 
+	 * java net...PaodingAnalyzer<br>
+	 * java net...PaodingAnalyzer --help<br>
+	 * java net...PaodingAnalyzer 中华人民共和国<br>
+	 * java net...PaodingAnalyzer -m max 中华人民共和国<br>
+	 * java net...PaodingAnalyzer -f c:/text.txt<br>
+	 * java net...PaodingAnalyzer -f c:/text.txt -c utf-8<br>
+	 * 
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		if (System.getProperty("paoding.try.app") == null) {
+			System.setProperty("paoding.try.app", "PaodingAnalyzer");
+			System.setProperty("paoding.try.cmd", "java PaodingAnalyzer");
+		}
+		TryPaodingAnalyzer.main(args);
+	}
+
+	// --------------------------------------------------
+
+	/**
+	 * @param knife
+	 * @param default_mode
+	 * @deprecated
+	 */
+	public PaodingAnalyzer(Knife knife, int mode) {
+		super(knife, mode);
+	}
+
+	/**
+	 * 等价于maxMode()
+	 * 
+	 * @param knife
+	 * @return
+	 * @deprecated
+	 */
+	public static PaodingAnalyzer queryMode(Knife knife) {
+		return maxMode(knife);
+	}
+
+	/**
+	 * 
+	 * @param knife
+	 * @return
+	 * @deprecated
+	 */
+	public static PaodingAnalyzer defaultMode(Knife knife) {
+		return new PaodingAnalyzer(knife, MOST_WORDS_MODE);
+	}
+
+	/**
+	 * 
+	 * @param knife
+	 * @return
+	 * @deprecated
+	 */
+	public static PaodingAnalyzer maxMode(Knife knife) {
+		return new PaodingAnalyzer(knife, MAX_WORD_LENGTH_MODE);
+	}
+
+	/**
+	 * 等价于defaultMode()
+	 * 
+	 * @param knife
+	 * @return
+	 * @deprecated
+	 * 
+	 */
+	public static PaodingAnalyzer writerMode(Knife knife) {
+		return defaultMode(knife);
+	}
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzerBean.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzerBean.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzerBean.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingAnalyzerBean.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,174 @@
+package net.paoding.analysis.analyzer;
+
+import java.io.Reader;
+
+import net.paoding.analysis.analyzer.impl.MaxWordLengthTokenCollector;
+import net.paoding.analysis.analyzer.impl.MostWordsTokenCollector;
+import net.paoding.analysis.knife.Knife;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.TokenStream;
+
+public class PaodingAnalyzerBean extends Analyzer {
+
+	// -------------------------------------------------
+
+	/**
+	 * 最多切分
+	 */
+	public static final int MOST_WORDS_MODE = 1;
+
+	/**
+	 * 按最大切分
+	 */
+	public static final int MAX_WORD_LENGTH_MODE = 2;
+
+	// -------------------------------------------------
+	/**
+	 * 用于向PaodingTokenizer提供,分解文本字符
+	 * 
+	 * @see PaodingTokenizer#next()
+	 * 
+	 */
+	private Knife knife;
+
+	/**
+	 * @see #MOST_WORDS_MODE
+	 * @see #MAX_WORD_LENGTH_MODE
+	 */
+	private int mode = MOST_WORDS_MODE;
+
+	/**
+	 * 
+	 */
+	private Class modeClass;
+
+	// -------------------------------------------------
+
+	public PaodingAnalyzerBean() {
+	}
+
+	/**
+	 * @see #setKnife(Knife)
+	 * @param knife
+	 */
+	public PaodingAnalyzerBean(Knife knife) {
+		this.knife = knife;
+	}
+
+	/**
+	 * @see #setKnife(Knife)
+	 * @see #setMode(int)
+	 * @param knife
+	 * @param mode
+	 */
+	public PaodingAnalyzerBean(Knife knife, int mode) {
+		this.knife = knife;
+		this.mode = mode;
+	}
+
+	/**
+	 * @see #setKnife(Knife)
+	 * @see #setMode(int)
+	 * @param knife
+	 * @param mode
+	 */
+	public PaodingAnalyzerBean(Knife knife, String mode) {
+		this.knife = knife;
+		this.setMode(mode);
+	}
+
+	// -------------------------------------------------
+
+	public Knife getKnife() {
+		return knife;
+	}
+
+	public void setKnife(Knife knife) {
+		this.knife = knife;
+	}
+
+	public int getMode() {
+		return mode;
+	}
+
+	/**
+	 * 设置分析器模式.
+	 * <p>
+	 * 
+	 * @param mode
+	 */
+	public void setMode(int mode) {
+		if (mode != MOST_WORDS_MODE && mode != MAX_WORD_LENGTH_MODE) {
+			throw new IllegalArgumentException("wrong mode:" + mode);
+		}
+		this.mode = mode;
+		this.modeClass = null;
+	}
+
+	/**
+	 * 设置分析器模式类。
+	 * 
+	 * @param modeClass
+	 *            TokenCollector的实现类。
+	 */
+	public void setModeClass(Class modeClass) {
+		this.modeClass = modeClass;
+	}
+
+	public void setModeClass(String modeClass) {
+		try {
+			this.modeClass = Class.forName(modeClass);
+		} catch (ClassNotFoundException e) {
+			throw new IllegalArgumentException("not found mode class:" + e.getMessage());
+		}
+	}
+
+	public void setMode(String mode) {
+		if (mode.startsWith("class:")) {
+			setModeClass(mode.substring("class:".length()));
+		} else {
+			if ("most-words".equalsIgnoreCase(mode)
+					|| "default".equalsIgnoreCase(mode)
+					|| ("" + MOST_WORDS_MODE).equals(mode)) {
+				setMode(MOST_WORDS_MODE);
+			} else if ("max-word-length".equalsIgnoreCase(mode)
+					|| ("" + MAX_WORD_LENGTH_MODE).equals(mode)) {
+				setMode(MAX_WORD_LENGTH_MODE);
+			}
+			else {
+				throw new IllegalArgumentException("不合法的分析器Mode参数设置:" + mode);
+			}
+		}
+	}
+
+	// -------------------------------------------------
+
+	public TokenStream tokenStream(String fieldName, Reader reader) {
+		if (knife == null) {
+			throw new NullPointerException("knife should be set before token");
+		}
+		// PaodingTokenizer是TokenStream实现,使用knife解析reader流入的文本
+		return new PaodingTokenizer(reader, knife, createTokenCollector());
+	}
+
+	protected TokenCollector createTokenCollector() {
+		if (modeClass != null) {
+			try {
+				return (TokenCollector) modeClass.newInstance();
+			} catch (InstantiationException e) {
+				throw new IllegalArgumentException("wrong mode class:" + e.getMessage());
+			} catch (IllegalAccessException e) {
+				throw new IllegalArgumentException("wrong mode class:" + e.getMessage());
+			}
+		}
+		switch (mode) {
+		case MOST_WORDS_MODE:
+			return new MostWordsTokenCollector();
+		case MAX_WORD_LENGTH_MODE:
+			return new MaxWordLengthTokenCollector();
+		default:
+			throw new Error("never happened");
+		}
+	}
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingTokenizer.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingTokenizer.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingTokenizer.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/PaodingTokenizer.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,217 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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
+ *
+ * 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.
+ */
+package net.paoding.analysis.analyzer;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Iterator;
+
+import net.paoding.analysis.analyzer.impl.MostWordsTokenCollector;
+import net.paoding.analysis.knife.Beef;
+import net.paoding.analysis.knife.Collector;
+import net.paoding.analysis.knife.Knife;
+import net.paoding.analysis.knife.Paoding;
+
+import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
+
+/**
+ * PaodingTokenizer是基于“庖丁解牛”框架的TokenStream实现,为PaodingAnalyzer使用。
+ * <p>
+ * 
+ * @author Zhiliang Wang [qieqie.wang@gmail.com]
+ * 
+ * @see Beef
+ * @see Knife
+ * @see Paoding
+ * @see Tokenizer
+ * @see PaodingAnalyzer
+ * 
+ * @see Collector
+ * @see TokenCollector
+ * @see MAxTokenCollector
+ * @see MostWordsTokenCollector
+ * 
+ * @since 1.0
+ */
+public final class PaodingTokenizer extends Tokenizer implements Collector {
+
+	// -------------------------------------------------
+
+	/**
+	 * 从input读入的总字符数
+	 */
+	private int inputLength;
+
+	/**
+	 * 
+	 */
+	private static final int bufferLength = 128;
+
+	/**
+	 * 接收来自{@link #input}的文本字符
+	 * 
+	 * @see #next()
+	 */
+	private final char[] buffer = new char[bufferLength];
+
+	/**
+	 * {@link buffer}[0]在{@link #input}中的偏移
+	 * 
+	 * @see #collect(String, int, int)
+	 * @see #next()
+	 */
+	private int offset;
+
+	/**
+	 * 
+	 */
+	private final Beef beef = new Beef(buffer, 0, 0);
+
+	/**
+	 * 
+	 */
+	private int dissected;
+
+	/**
+	 * 用于分解beef中的文本字符,由PaodingAnalyzer提供
+	 * 
+	 * @see #next()
+	 */
+	private Knife knife;
+
+	/**
+	 * 
+	 */
+	private TokenCollector tokenCollector;
+
+	/**
+	 * tokens迭代器,用于next()方法顺序读取tokens中的Token对象
+	 * 
+	 * @see #tokens
+	 * @see #next()
+	 */
+	private Iterator<Token> tokenIteractor;
+
+	private TermAttribute termAtt;
+	private OffsetAttribute offsetAtt;
+	private TypeAttribute typeAtt;
+
+	// -------------------------------------------------
+
+	/**
+	 * 
+	 * @param input
+	 * @param knife
+	 * @param tokenCollector
+	 */
+	public PaodingTokenizer(Reader input, Knife knife,
+			TokenCollector tokenCollector) {
+		this.input = input;
+		this.knife = knife;
+		this.tokenCollector = tokenCollector;
+		init();
+	}
+
+	private void init() {
+		termAtt = addAttribute(TermAttribute.class);
+		offsetAtt = addAttribute(OffsetAttribute.class);
+		typeAtt = addAttribute(TypeAttribute.class);
+	}
+
+	// -------------------------------------------------
+
+	public TokenCollector getTokenCollector() {
+		return tokenCollector;
+	}
+
+	public void setTokenCollector(TokenCollector tokenCollector) {
+		this.tokenCollector = tokenCollector;
+	}
+
+	// -------------------------------------------------
+
+	public void collect(String word, int offset, int end) {
+		tokenCollector.collect(word, this.offset + offset, this.offset + end);
+	}
+
+	// -------------------------------------------------
+	public int getInputLength() {
+		return inputLength;
+	}
+
+	@Override
+	public boolean incrementToken() throws IOException {
+		// 已经穷尽tokensIteractor的Token对象,则继续请求reader流入数据
+		while (tokenIteractor == null || !tokenIteractor.hasNext()) {
+			// System.out.println(dissected);
+			int read = 0;
+			int remainning = -1;// 重新从reader读入字符前,buffer中还剩下的字符数,负数表示当前暂不需要从reader中读入字符
+			if (dissected >= beef.length()) {
+				remainning = 0;
+			} else if (dissected < 0) {
+				remainning = bufferLength + dissected;
+			}
+			if (remainning >= 0) {
+				if (remainning > 0) {
+					System.arraycopy(buffer, -dissected, buffer, 0, remainning);
+				}
+				read = input
+						.read(buffer, remainning, bufferLength - remainning);
+				inputLength += read;
+				int charCount = remainning + read;
+				if (charCount < 0) {
+					// reader已尽,按接口next()要求返回null.
+					return false;
+				}
+				if (charCount < bufferLength) {
+					buffer[charCount++] = 0;
+				}
+				// 构造“牛”,并使用knife“解”之
+				beef.set(0, charCount);
+				offset += Math.abs(dissected);
+				// offset -= remainning;
+				dissected = 0;
+			}
+			dissected = knife.dissect((Collector) this, beef, dissected);
+			// offset += read;// !!!
+			tokenIteractor = tokenCollector.iterator();
+		}
+		// 返回tokensIteractor下一个Token对象
+		Token token = tokenIteractor.next();
+		termAtt.setTermBuffer(token.term());
+		offsetAtt.setOffset(correctOffset(token.startOffset()),
+				correctOffset(token.endOffset()));
+		typeAtt.setType("paoding");
+		return true;
+	}
+
+	@Override
+	public void reset() throws IOException {
+		super.reset();
+		offset = 0;
+		inputLength = 0;
+	}
+	
+	@Override
+	public void reset(Reader input) throws IOException {
+		super.reset(input);
+		reset();
+	}
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/TokenCollector.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/TokenCollector.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/TokenCollector.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/TokenCollector.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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
+ *
+ * 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.
+ */
+package net.paoding.analysis.analyzer;
+
+import java.util.Iterator;
+
+import org.apache.lucene.analysis.Token;
+
+import net.paoding.analysis.knife.Collector;
+
+/**
+ * 
+ * @author Zhiliang Wang [qieqie.wang@gmail.com]
+ *
+ * @since 1.1
+ */
+public interface TokenCollector extends Collector {
+
+	/**
+	 * 
+	 * @return
+	 */
+	public Iterator<Token> iterator();
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/Estimate.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/Estimate.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/Estimate.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/Estimate.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,207 @@
+package net.paoding.analysis.analyzer.estimate;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.LinkedList;
+
+import net.paoding.analysis.analyzer.PaodingTokenizer;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+
+public class Estimate {
+	private Analyzer analyzer;
+	private String print;
+	private PrintGate printGate;
+
+	public Estimate() {
+		this.setPrint("50");// 默认只打印前50行分词效果
+	}
+
+	public Estimate(Analyzer analyzer) {
+		setAnalyzer(analyzer);
+		this.setPrint("50");// 默认只打印前50行分词效果
+	}
+
+	public void setAnalyzer(Analyzer analyzer) {
+		this.analyzer = analyzer;
+	}
+
+	public Analyzer getAnalyzer() {
+		return analyzer;
+	}
+
+	public void setPrint(String print) {
+		if (print == null || print.length() == 0
+				|| print.equalsIgnoreCase("null")
+				|| print.equalsIgnoreCase("no")) {
+			printGate = null;
+			this.print = null;
+		} else {
+			printGate = new LinePrintGate();
+			printGate.setPrint(print, 10);
+			this.print = print;
+		}
+	}
+
+	public String getPrint() {
+		return print;
+	}
+
+	public void test(String input) {
+		this.test(System.out, input);
+	}
+
+	public void test(PrintStream out, String input) {
+		Reader reader = new StringReaderEx(input);
+		this.test(out, reader);
+	}
+
+	public void test(PrintStream out, Reader reader) {
+		try {
+			long begin = System.currentTimeMillis();
+			
+			LinkedList<CToken> list = new LinkedList<CToken>();
+			int wordsCount = 0;
+			
+			//collect token
+			TokenStream ts = analyzer.tokenStream("", reader);
+			ts.reset();
+			TermAttribute termAtt = (TermAttribute) ts
+					.addAttribute(TermAttribute.class);
+			while (ts.incrementToken()) {
+				if (printGate != null && printGate.filter(wordsCount)) {
+					list.add(new CToken(termAtt.term(), wordsCount));
+				}
+				wordsCount++;
+			}
+			
+			long end = System.currentTimeMillis();
+			int c = 0;
+			if (list.size() > 0) {
+				for (CToken ctoken : list) {
+					c = ctoken.i;
+					if (c % 10 == 0) {
+						if (c != 0) {
+							out.println();
+						}
+						out.print((c / 10 + 1) + ":\t");
+					}
+					out.print(ctoken.t + "/");
+				}
+			}
+			if (wordsCount == 0) {
+				System.out.println("\tAll are noise characters or words");
+			} else {
+				if (c % 10 != 1) {
+					System.out.println();
+				}
+				String inputLength = "<未知>";
+				if (reader instanceof StringReaderEx) {
+					inputLength = "" + ((StringReaderEx) reader).inputLength;
+				} else if (ts instanceof PaodingTokenizer) {
+					inputLength = "" + ((PaodingTokenizer) ts).getInputLength();
+				}
+				System.out.println();
+				System.out.println("\t分词器" + analyzer.getClass().getName());
+				System.out.println("\t内容长度 " + inputLength + "字符, 分 "
+						+ wordsCount + "个词");
+				System.out.println("\t分词耗时 " + (end - begin) + "ms ");
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				reader.close();
+			} catch (IOException e) {
+			}
+		}
+	}
+
+	// -------------------------------------------
+
+	static class CToken {
+		String t;
+		int i;
+
+		CToken(String t, int i) {
+			this.t = t;
+			this.i = i;
+		}
+	}
+
+	static interface PrintGate {
+		public void setPrint(String print, int unitSize);
+
+		boolean filter(int count);
+	}
+
+	static class PrintGateToken implements PrintGate {
+		private int begin;
+		private int end;
+
+		public void setBegin(int begin) {
+			this.begin = begin;
+		}
+
+		public void setEnd(int end) {
+			this.end = end;
+		}
+
+		public void setPrint(String print, int unitSize) {
+			int i = print.indexOf('-');
+			if (i > 0) {
+				int bv = Integer.parseInt(print.substring(0, i));
+				int ev = Integer.parseInt(print.substring(i + 1));
+				setBegin(unitSize * (Math.abs(bv) - 1));// 第5行,是从第40开始的
+				setEnd(unitSize * Math.abs(ev));// 到第10行,是截止于100(不包含该边界)
+			} else {
+				setBegin(0);
+				int v = Integer.parseInt(print);
+				setEnd(unitSize * (Math.abs(v)));
+			}
+		}
+
+		public boolean filter(int count) {
+			return count >= begin && count < end;
+		}
+	}
+
+	static class LinePrintGate implements PrintGate {
+
+		private PrintGate[] list;
+
+		public void setPrint(String print, int unitSize) {
+			String[] prints = print.split(",");
+			list = new PrintGate[prints.length];
+			for (int i = 0; i < prints.length; i++) {
+				PrintGateToken pg = new PrintGateToken();
+				pg.setPrint(prints[i], unitSize);
+				list[i] = pg;
+			}
+		}
+
+		public boolean filter(int count) {
+			for (int i = 0; i < list.length; i++) {
+				if (list[i].filter(count)) {
+					return true;
+				}
+			}
+			return false;
+		}
+
+	}
+
+	static class StringReaderEx extends StringReader {
+		private int inputLength;
+
+		public StringReaderEx(String s) {
+			super(s);
+			inputLength = s.length();
+		}
+	}
+
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/TryPaodingAnalyzer.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/TryPaodingAnalyzer.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/TryPaodingAnalyzer.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/estimate/TryPaodingAnalyzer.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,299 @@
+package net.paoding.analysis.analyzer.estimate;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+
+import net.paoding.analysis.analyzer.PaodingAnalyzer;
+import net.paoding.analysis.knife.PaodingMaker;
+
+import org.apache.lucene.analysis.Analyzer;
+
+public class TryPaodingAnalyzer {
+	private static final String ARGS_TIP = ":";
+	static String input = null;
+	static String file = null;
+	static Reader reader = null;
+	static String charset = null;
+	static String mode = null;
+	static String analyzerName = null;
+	static String print = null;
+	static String properties = PaodingMaker.DEFAULT_PROPERTIES_PATH;
+	
+	public static void main(String[] args) {
+		try {
+			resetArgs();
+			
+			int inInput = 0;
+			for (int i = 0; i < args.length; i++) {
+				if (args[i] == null || (args[i] = args[i].trim()).length() == 0) {
+					continue;
+				}
+				if (args[i].equals("--file") || args[i].equals("-f")) {
+					file = args[++i];
+				} else if (args[i].equals("--charset") || args[i].equals("-c")) {
+					charset = args[++i];
+				} else if (args[i].equals("--mode") || args[i].equals("-m")) {
+					mode = args[++i];
+				} else if (args[i].equals("--properties") || args[i].equals("-p")) {
+					properties = args[++i];
+				} else if (args[i].equals("--analyzer") || args[i].equals("-a")) {
+					analyzerName = args[++i];
+				} else if (args[i].equals("--print") || args[i].equals("-P")) {
+					print = args[++i];
+				} else if (args[i].equals("--input") || args[i].equals("-i")) {
+					inInput++;
+				} else if (args[i].equals("--help") || args[i].equals("-h")
+						|| args[i].equals("?")) {
+					printHelp();
+					return;
+				} else {
+					// 非选项的参数数组视为input
+					if (!args[i].startsWith("-")
+							&& (i == 0 || args[i - 1].equals("-i") || args[i - 1].equals("--input") || !args[i - 1].startsWith("-"))) {
+						if (input == null) {
+							input = args[i];// !!没有++i
+						} else {
+							input = input + ' ' + args[i];// !!没有++i
+						}
+						inInput++;
+					}
+				}
+			}
+			if (file != null) {
+				input = null;
+				reader = getReader(file, charset);
+			}
+			//
+			analysing();
+		} catch (Exception e1) {
+			resetArgs();
+			e1.printStackTrace();
+		}
+	}
+
+
+
+	private static void resetArgs() {
+		input = null;
+		file = null;
+		reader = null;
+		charset = null;
+		mode = null;
+		print = null;
+		analyzerName = null;
+		properties = PaodingMaker.DEFAULT_PROPERTIES_PATH;
+	}
+	
+
+	
+	private static void analysing() throws Exception {
+		Analyzer analyzer;
+		if (analyzerName == null || analyzerName.length() == 0 || analyzerName.equalsIgnoreCase("paoding")) {
+			//properties==null等同于new new PaodingAnalyzer();
+			analyzer = new PaodingAnalyzer(properties);
+			if (mode != null) {
+				((PaodingAnalyzer) analyzer).setMode(mode);
+			}
+		}
+		else {
+			Class clz;
+			if (analyzerName.equalsIgnoreCase("standard")) {
+				analyzerName = "org.apache.lucene.analysis.standard.StandardAnalyzer";
+			}
+			else if (analyzerName.equalsIgnoreCase("cjk")) {
+				analyzerName = "org.apache.lucene.analysis.cjk.CJKAnalyzer";
+			}
+			else if (analyzerName.equalsIgnoreCase("cn") || analyzerName.equalsIgnoreCase("chinese")) {
+				analyzerName = "org.apache.lucene.analysis.cn.ChineseAnalyzer";
+			}
+			else if (analyzerName.equalsIgnoreCase("st") || analyzerName.equalsIgnoreCase("standard")) {
+				analyzerName = "org.apache.lucene.analysis.standard.StandardAnalyzer";
+			}
+			clz = Class.forName(analyzerName);
+			analyzer = (Analyzer) clz.newInstance();
+		}
+		boolean readInputFromConsle = false;
+		Estimate estimate = new Estimate(analyzer);
+		if (print != null) {
+			estimate.setPrint(print);
+		}
+		while (true) {
+			if (reader == null) {
+				if (input == null || input.length() == 0 || readInputFromConsle) {
+					input = getInputFromConsole();
+					readInputFromConsle = true;
+				}
+				if (input == null || input.length() == 0) {
+					System.out.println("Warn: none charactors you input!!");
+					continue;
+				}
+				else if (input.startsWith(ARGS_TIP)) {
+					String argsStr = input.substring(ARGS_TIP.length());
+					main(argsStr.split(" "));
+					continue;
+				}
+			}
+			if (reader != null) {
+				estimate.test(System.out, reader);
+				reader = null;
+			}
+			else {
+				estimate.test(System.out, input);
+				input = null;
+			}
+			System.out.println("--------------------------------------------------");
+			if (false == readInputFromConsle) {
+				return;
+			}
+		}
+	}
+
+	private static String getInputFromConsole() throws IOException {
+		printTitleIfNotPrinted("");
+		String input = null;
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				System.in));
+		String line;
+		do {
+			System.out.print("paoding> ");
+			line = reader.readLine();
+			if (line == null || line.length() == 0) {
+				continue;
+			}
+			if (line.equals(ARGS_TIP + "clear") || line.equals(ARGS_TIP + "c")) {
+				input = null;
+				System.out.println("paoding> Cleared");
+				return getInputFromConsole();
+			}
+			else if (line.equals(ARGS_TIP + "exit") || line.equals(ARGS_TIP + "quit") || line.equals(ARGS_TIP + "e") || line.equals(ARGS_TIP + "q") ) {
+				System.out.println("Bye!");
+				System.exit(0);
+			}
+			else if (input == null && line.startsWith(ARGS_TIP)) {
+				input = line;
+				break;
+			}
+			else {
+				if (line.endsWith(";")) {
+					if (line.length() > ";".length()) {
+						input = line.substring(0, line.length() - ";".length());
+					}
+					break;
+				}
+				else {
+					if (input == null) {
+						input = line;
+					} else {
+						input = input + "\n" + line;
+					}
+				}
+			}
+		} while (true);
+		return input == null ? null : input.trim();
+	}
+
+	private static void printHelp() {
+		String app = System.getProperty("paoding.try.app",
+				"TryPaodingAnalyzer");
+		String cmd = System.getProperty("paoding.try.cmd", "java "
+				+ TryPaodingAnalyzer.class.getName());
+		System.out.println(app + "的用法:");
+		System.out.println("\t" + cmd + " [OPTIONS] [text_content]");
+		System.out.println("\nOPTIONS:");
+		System.out.println("\t--file, -f:\n\t\t文章以文件的形式输入,在前缀加上\"classpath:\"表示从类路径中寻找该文件。");
+		System.out.println("\t--charset, -c:\n\t\t文章的字符集编码,比如gbk,utf-8等。如果没有设置该选项,则使用Java环境默认的字符集编码。");
+		System.out.println("\t--properties, -p:\n\t\t不读取默认的类路径下的庖丁分词属性文件,而使用指定的文件,在前缀加上\"classpath:\"表示从类路径中寻找该文件。");
+		System.out.println("\t--mode, -m:\n\t\t强制使用给定的mode的分词器;可以设定为default,most-words,max-word-length或指定类名的其他mode(指定类名的,需要加前缀\"class:\")。");
+		System.out.println("\t--input, -i:\n\t\t要被分词的文章内容;当没有通过-f或--file指定文章输入文件时可选择这个选项指定要被分词的内容。");
+		System.out.println("\t--analyzer, -a:\n\t\t测试其他分词器,通过--analyzer或-a指定其完整类名。特别地,paoding、cjk、chinese、st分别对应PaodingAnalyzer、CJKAnalyzer、ChineseAnalyzer、StandardAnalyzer");
+		System.out.println("\t--print, -P:\n\t\t 是否打印分词结果。默认打印前50行。规则:no表示不打印;50等价于1-50行;1-50表示打印1至50行;可以以逗号组合使用,如20,40-50表示打印1-20以及40-50行");
+		System.out.println("\n示例:");
+		System.out.println("\t" + cmd);
+		System.out.println("\t" + cmd + " ?");
+		System.out.println("\t" + cmd + " 中华人民共和国");
+		System.out.println("\t" + cmd + " -m max 中华人民共和国");
+		System.out.println("\t" + cmd + " -f e:/content.txt -c utf8");
+		System.out.println("\t" + cmd + " -f e:/content.txt -c utf8 -m max-word-length");
+		System.out.println("\t" + cmd + " -f e:/content.txt -c utf8 -a cjk");
+		System.out.println("\n若是控制台进入\"paoding>\"后:");
+		titlePrinted = false;
+		printTitleIfNotPrinted("\t");
+	}
+	
+	
+	private static boolean titlePrinted = false;
+	private static boolean welcomePrinted = false;
+	private static void printTitleIfNotPrinted(String prefix) {
+		if (!titlePrinted) {
+			System.out.println();
+			if (!welcomePrinted) {
+				System.out.println("Welcome to Paoding Analyser(2.0.4-alpha2)");
+				System.out.println();
+				welcomePrinted = true;
+			}
+			System.out.println(prefix + "直接输入或粘贴要被分词的内容,以分号;结束,回车后开始分词。");
+			System.out.println(prefix + "另起一行输入:clear或:c,使此次输入无效,用以重新输入。");
+			System.out.println(prefix + "要使用命令行参数读入文件内容或其他参数请以冒号:开始,然后输入参数选项。");
+			System.out.println(prefix + "退出,请输入:quit或:q、:exit、:e");
+			System.out.println(prefix + "需要帮助,请输入:?");
+			System.out.println(prefix + "注意:指定对文件分词之前要了解该文件的编码,如果系统编码和文件编码不一致,要通过-c指定文件的编码。");
+			System.out.println();
+			titlePrinted = true;
+		}
+	}
+	
+		
+	static String getContent(String path, String encoding) throws IOException {
+		return (String) read(path, encoding, true);
+	}
+	
+	static Reader getReader(String path, String encoding) throws IOException {
+		return (Reader) read(path, encoding, false);
+	}
+	
+	static Object read(String path, String encoding, boolean return_string) throws IOException {
+		InputStream in;
+		if (path.startsWith("classpath:")) {
+			path = path.substring("classpath:".length());
+			URL url = Estimate.class.getClassLoader().getResource(path);
+			if (url == null) {
+				throw new IllegalArgumentException("Not found " + path
+						+ " in classpath.");
+			}
+			System.out.println("read content from:" + url.getFile());
+			in = url.openStream();
+		} else {
+			File f = new File(path);
+			if (!f.exists()) {
+				throw new IllegalArgumentException("Not found " + path
+						+ " in system.");
+			}
+			System.out.println("read content from:" + f.getAbsolutePath());
+			in = new FileInputStream(f);
+		}
+		Reader re;
+		if (encoding != null) {
+			re = new InputStreamReader(in, encoding);
+		} else {
+			re = new InputStreamReader(in);
+		}
+		if (!return_string) {
+			return re;
+		}
+		char[] chs = new char[1024];
+		int count;
+		// 为兼容低版本的JDK,使用StringBuffer而不是StringBuilder
+		StringBuffer content = new StringBuffer();
+		while ((count = re.read(chs)) != -1) {
+			content.append(chs, 0, count);
+		}
+		re.close();
+		return content.toString();
+		}
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/CompiledFileDictionaries.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/CompiledFileDictionaries.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/CompiledFileDictionaries.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/CompiledFileDictionaries.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,336 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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
+ *
+ * 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.
+ */
+package net.paoding.analysis.analyzer.impl;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import net.paoding.analysis.dictionary.BinaryDictionary;
+import net.paoding.analysis.dictionary.Dictionary;
+import net.paoding.analysis.dictionary.HashBinaryDictionary;
+import net.paoding.analysis.dictionary.Word;
+import net.paoding.analysis.dictionary.support.detection.Detector;
+import net.paoding.analysis.dictionary.support.detection.DifferenceListener;
+import net.paoding.analysis.dictionary.support.filewords.FileWordsReader;
+import net.paoding.analysis.exception.PaodingAnalysisException;
+import net.paoding.analysis.knife.CJKKnife;
+import net.paoding.analysis.knife.Dictionaries;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 中文字典缓存根据地,为{@link CJKKnife}所用。<br>
+ * 从本对象可以获取中文需要的相关字典。包括词汇表、姓氏表、计量单位表、忽略的词或单字等。
+ * <p>
+ * 
+ * @author Zhiliang Wang [qieqie.wang@gmail.com]
+ * 
+ * @see CJKKnife
+ * 
+ * @since 1.0
+ */
+public class CompiledFileDictionaries implements Dictionaries {
+
+	// -------------------------------------------------
+
+	protected Logger log = LoggerFactory.getLogger(CompiledFileDictionaries.class);
+
+	// -------------------------------------------------
+
+	/**
+	 * 词汇表字典
+	 */
+	protected Dictionary vocabularyDictionary;
+
+	/**
+	 * lantin+cjk的词典
+	 */
+	protected Dictionary combinatoricsDictionary;
+
+	/**
+	 * 姓氏字典
+	 * 
+	 */
+	protected Dictionary confucianFamilyNamesDictionary;
+
+	/**
+	 * 忽略的单字
+	 */
+	protected Dictionary noiseCharactorsDictionary;
+
+	/**
+	 * 忽略的词语
+	 * 
+	 */
+	protected Dictionary noiseWordsDictionary;
+
+	/**
+	 * 计量单位
+	 */
+	protected Dictionary unitsDictionary;
+
+	// -------------------------------------------------
+
+	protected String dicHome;
+	protected String noiseCharactor;
+	protected String noiseWord;
+	protected String unit;
+	protected String confucianFamilyName;
+	protected String combinatorics;
+	protected String charsetName;
+	protected int maxWordLen;
+
+	// ----------------------
+
+	public CompiledFileDictionaries() {
+	}
+
+	public CompiledFileDictionaries(String dicHome, String noiseCharactor,
+			String noiseWord, String unit, String confucianFamilyName,
+			String combinatorics, String charsetName, int maxWordLen) {
+		this.dicHome = dicHome;
+		this.noiseCharactor = noiseCharactor;
+		this.noiseWord = noiseWord;
+		this.unit = unit;
+		this.confucianFamilyName = confucianFamilyName;
+		this.combinatorics = combinatorics;
+		this.charsetName = charsetName;
+		this.maxWordLen = maxWordLen;
+	}
+
+	public String getDicHome() {
+		return dicHome;
+	}
+
+	public void setDicHome(String dicHome) {
+		this.dicHome = dicHome;
+	}
+
+	public String getNoiseCharactor() {
+		return noiseCharactor;
+	}
+
+	public void setNoiseCharactor(String noiseCharactor) {
+		this.noiseCharactor = noiseCharactor;
+	}
+
+	public String getNoiseWord() {
+		return noiseWord;
+	}
+
+	public void setNoiseWord(String noiseWord) {
+		this.noiseWord = noiseWord;
+	}
+
+	public String getUnit() {
+		return unit;
+	}
+
+	public void setUnit(String unit) {
+		this.unit = unit;
+	}
+
+	public String getConfucianFamilyName() {
+		return confucianFamilyName;
+	}
+
+	public void setConfucianFamilyName(String confucianFamilyName) {
+		this.confucianFamilyName = confucianFamilyName;
+	}
+
+	public String getCharsetName() {
+		return charsetName;
+	}
+
+	public void setCharsetName(String charsetName) {
+		this.charsetName = charsetName;
+	}
+
+	public int getMaxWordLen() {
+		return maxWordLen;
+	}
+
+	public void setMaxWordLen(int maxWordLen) {
+		this.maxWordLen = maxWordLen;
+	}
+
+    public void setLantinFllowedByCjk(String lantinFllowedByCjk) {
+		this.combinatorics = lantinFllowedByCjk;
+	}
+
+	public String getLantinFllowedByCjk() {
+		return combinatorics;
+	}
+
+	// -------------------------------------------------
+
+	/**
+	 * 词汇表字典
+	 * 
+	 * @return
+	 */
+	public synchronized Dictionary getVocabularyDictionary() {
+		if (vocabularyDictionary == null) {
+			// 大概有5639个字有词语,故取0x2fff=x^13>8000>8000*0.75=6000>5639
+			vocabularyDictionary = new HashBinaryDictionary(
+					getVocabularyWords(), 0x2fff, 0.75f);
+		}
+		return vocabularyDictionary;
+	}
+
+	/**
+	 * 姓氏字典
+	 * 
+	 * @return
+	 */
+	public synchronized Dictionary getConfucianFamilyNamesDictionary() {
+		if (confucianFamilyNamesDictionary == null) {
+			confucianFamilyNamesDictionary = new BinaryDictionary(
+					getConfucianFamilyNames());
+		}
+		return confucianFamilyNamesDictionary;
+	}
+
+	/**
+	 * 忽略的词语
+	 * 
+	 * @return
+	 */
+	public synchronized Dictionary getNoiseCharactorsDictionary() {
+		if (noiseCharactorsDictionary == null) {
+			noiseCharactorsDictionary = new HashBinaryDictionary(
+					getNoiseCharactors(), 256, 0.75f);
+		}
+		return noiseCharactorsDictionary;
+	}
+
+	/**
+	 * 忽略的单字
+	 * 
+	 * @return
+	 */
+	public synchronized Dictionary getNoiseWordsDictionary() {
+		if (noiseWordsDictionary == null) {
+			noiseWordsDictionary = new BinaryDictionary(getNoiseWords());
+		}
+		return noiseWordsDictionary;
+	}
+
+	/**
+	 * 计量单位
+	 * 
+	 * @return
+	 */
+	public synchronized Dictionary getUnitsDictionary() {
+		if (unitsDictionary == null) {
+			unitsDictionary = new HashBinaryDictionary(getUnits(), 1024, 0.75f);
+		}
+		return unitsDictionary;
+	}
+
+	public synchronized Dictionary getCombinatoricsDictionary() {
+		if (combinatoricsDictionary == null) {
+			combinatoricsDictionary = new BinaryDictionary(
+					getCombinatoricsWords());
+		}
+		return combinatoricsDictionary;
+	}
+
+	private Detector detector;
+
+	public synchronized void startDetecting(int interval, DifferenceListener l) {
+		if (detector != null || interval < 0) {
+			return;
+		}
+		Detector detector = new Detector();
+		detector.setHome(dicHome);
+		detector.setFilter(null);
+		detector.setFilter(new FileFilter() {
+			public boolean accept(File pathname) {
+				return pathname.getPath().endsWith(".dic.compiled")
+						|| pathname.getPath().endsWith(".metadata");
+			}
+		});
+		detector.setLastSnapshot(detector.flash());
+		detector.setListener(l);
+		detector.setInterval(interval);
+		detector.start(true);
+		this.detector = detector;
+	}
+
+	public synchronized void stopDetecting() {
+		if (detector == null) {
+			return;
+		}
+		detector.setStop();
+		detector = null;
+	}
+
+	// ---------------------------------------------------------------
+	// 以下为辅助性的方式-类私有或package私有
+
+	protected Word[] getDictionaryWords(String dicNameRelativeDicHome) {
+		File f = new File(this.dicHome, "/" + dicNameRelativeDicHome
+				+ ".dic.compiled");
+		if (!f.exists()) {
+			return new Word[0];
+		}
+		try {
+			Map map = FileWordsReader.readWords(f.getAbsolutePath(),
+					charsetName, maxWordLen, LinkedList.class, ".dic.compiled");
+			List wordsList = (List) map.values().iterator().next();
+			return (Word[]) wordsList.toArray(new Word[wordsList.size()]);
+		} catch (IOException e) {
+			throw toRuntimeException(e);
+		}
+	}
+	
+	
+	protected Word[] getVocabularyWords() {
+		return getDictionaryWords("vocabulary");
+	}
+
+	protected Word[] getConfucianFamilyNames() {
+		return getDictionaryWords(confucianFamilyName);
+	}
+
+	protected Word[] getNoiseWords() {
+		return getDictionaryWords(noiseWord);
+	}
+
+	protected Word[] getNoiseCharactors() {
+		return getDictionaryWords(noiseCharactor);
+	}
+
+	protected Word[] getUnits() {
+		return getDictionaryWords(unit);
+	}
+
+	protected Word[] getCombinatoricsWords() {
+		return getDictionaryWords(combinatorics);
+	}
+
+	// --------------------------------------
+
+	protected RuntimeException toRuntimeException(IOException e) {
+		return new PaodingAnalysisException(e);
+	}
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MaxWordLengthTokenCollector.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MaxWordLengthTokenCollector.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MaxWordLengthTokenCollector.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MaxWordLengthTokenCollector.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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
+ *
+ * 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.
+ */
+package net.paoding.analysis.analyzer.impl;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
+
+import net.paoding.analysis.analyzer.TokenCollector;
+
+import org.apache.lucene.analysis.Token;
+
+
+/**
+ * 
+ * @author Zhiliang Wang [qieqie.wang@gmail.com]
+ * 
+ * @since 1.1
+ */
+public class MaxWordLengthTokenCollector implements TokenCollector {
+
+	/**
+	 * 存储当前被knife分解而成的Token对象
+	 * 
+	 */
+	private LinkedList/* <Token> */ tokens = new LinkedList/* <Token> */();
+
+	private Token candidate;
+
+	private Token last;
+
+	public Iterator/* <Token> */ iterator() {
+		if (candidate != null) {
+			this.tokens.add(candidate);
+			candidate = null;
+		}
+		Iterator/* <Token> */ iter = this.tokens.iterator();
+		this.tokens = new LinkedList/* <Token> */();
+		return iter;
+	}
+
+	public void collect(String word, int offset, int end) {
+		Token c = candidate != null ? candidate : last;
+		if (c == null) {
+			candidate = new Token(word, offset, end);
+		} else if (offset == c.startOffset()) {
+			if (end > c.endOffset()) {
+				candidate = new Token(word, offset, end);
+			}
+		} else if (offset > c.startOffset()) {
+			if (candidate != null) {
+				select(candidate);
+			}
+			if (end > c.endOffset()) {
+				candidate = new Token(word, offset, end);
+			} else {
+				candidate = null;
+			}
+		} else if (end >= c.endOffset()) {
+			if (last != null && last.startOffset() >= offset
+					&& last.endOffset() <= end) {
+				for (Iterator/* <Token> */ iter = tokens.iterator(); iter.hasNext();) {
+					last = (Token) iter.next();
+					if (last.startOffset() >= offset && last.endOffset() <= end) {
+						iter.remove();
+					}
+				}
+			}
+			last = null;
+			candidate = new Token(word, offset, end);
+		}
+	}
+
+	protected void select(Token t) {
+		this.tokens.add(t);
+		this.last = t;
+	}
+
+}

Added: stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MostWordsModeDictionariesCompiler.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MostWordsModeDictionariesCompiler.java?rev=1428467&view=auto
==============================================================================
--- stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MostWordsModeDictionariesCompiler.java (added)
+++ stanbol/trunk/commons/solr/extras/paoding/src/main/java/net/paoding/analysis/analyzer/impl/MostWordsModeDictionariesCompiler.java Thu Jan  3 16:56:34 2013
@@ -0,0 +1,230 @@
+package net.paoding.analysis.analyzer.impl;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.BitSet;
+import java.util.Properties;
+
+import net.paoding.analysis.Constants;
+import net.paoding.analysis.dictionary.Dictionary;
+import net.paoding.analysis.dictionary.Hit;
+import net.paoding.analysis.dictionary.Word;
+import net.paoding.analysis.dictionary.support.detection.Snapshot;
+import net.paoding.analysis.knife.Beef;
+import net.paoding.analysis.knife.Collector;
+import net.paoding.analysis.knife.Dictionaries;
+import net.paoding.analysis.knife.DictionariesCompiler;
+import net.paoding.analysis.knife.Knife;
+
+public class MostWordsModeDictionariesCompiler implements DictionariesCompiler {
+	public static final String VERSION = "2";
+	
+	public boolean shouldCompile(Properties p) throws Exception {
+		String dicHome = p.getProperty("paoding.dic.home.absolute.path");
+		File dicHomeFile = new File(dicHome);
+		File compliedMetadataFile = new File(dicHomeFile, ".compiled/most-words-mode/.metadata");
+		if (compliedMetadataFile.exists() && compliedMetadataFile.isFile()) {
+			// get checksum for all compiled dictionaries
+			String checksum = Snapshot.flash(
+					new File(dicHomeFile, ".compiled/most-words-mode"),
+					new FileFilter() {
+						public boolean accept(File pathname) {
+							return pathname.getPath().endsWith(".dic.compiled");
+						}
+					}).getCheckSum();
+			
+			Properties compiledProperties = new Properties();
+			InputStream compiledPropertiesInput = new FileInputStream(compliedMetadataFile);
+			compiledProperties.load(compiledPropertiesInput);
+			compiledPropertiesInput.close();
+			String compiledCheckSum = compiledProperties.getProperty("paoding.analysis.compiler.checksum");
+			String clazz = compiledProperties.getProperty("paoding.analysis.compiler.class");
+			String version = compiledProperties.getProperty("paoding.analysis.compiler.version");
+			if (checksum.equals(compiledCheckSum) && this.getClass().getName().equalsIgnoreCase(clazz)
+					&& VERSION.equalsIgnoreCase(version)) {
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	public void compile(Dictionaries dictionaries, Knife knife, Properties p) throws Exception {
+		String dicHome = p.getProperty("paoding.dic.home.absolute.path");
+		String noiseCharactor = getProperty(p, Constants.DIC_NOISE_CHARACTOR);
+		String noiseWord = getProperty(p, Constants.DIC_NOISE_WORD);
+		String unit = getProperty(p, Constants.DIC_UNIT);
+		String confucianFamilyName = getProperty(p, Constants.DIC_CONFUCIAN_FAMILY_NAME);
+		String combinatorics = getProperty(p, Constants.DIC_FOR_COMBINATORICS);
+		String charsetName = getProperty(p, Constants.DIC_CHARSET);
+		
+		File dicHomeFile = new File(dicHome);
+		File compiledDicHomeFile = new File(dicHomeFile, ".compiled/most-words-mode");
+		compiledDicHomeFile.mkdirs();
+		//
+		Dictionary vocabularyDictionary = dictionaries.getVocabularyDictionary();
+		File vocabularyFile = new File(compiledDicHomeFile, "vocabulary.dic.compiled");
+		compileVocabulary(vocabularyDictionary, knife, vocabularyFile, charsetName);
+
+		//
+		Dictionary noiseCharactorsDictionary = dictionaries.getNoiseCharactorsDictionary();
+		File noiseCharactorsDictionaryFile = new File(compiledDicHomeFile, noiseCharactor + ".dic.compiled");
+		sortCompile(noiseCharactorsDictionary, noiseCharactorsDictionaryFile, charsetName);
+		//
+		Dictionary noiseWordsDictionary = dictionaries.getNoiseWordsDictionary();
+		File noiseWordsDictionaryFile = new File(compiledDicHomeFile, noiseWord + ".dic.compiled");
+		sortCompile(noiseWordsDictionary, noiseWordsDictionaryFile, charsetName);
+		//
+		Dictionary unitsDictionary = dictionaries.getUnitsDictionary();
+		File unitsDictionaryFile = new File(compiledDicHomeFile, unit + ".dic.compiled");
+		sortCompile(unitsDictionary, unitsDictionaryFile, charsetName);
+		//
+		Dictionary confucianFamilyDictionary = dictionaries.getConfucianFamilyNamesDictionary();
+		File confucianFamilyDictionaryFile = new File(compiledDicHomeFile, confucianFamilyName + ".dic.compiled");
+		sortCompile(confucianFamilyDictionary, confucianFamilyDictionaryFile, charsetName);
+		//
+		Dictionary combinatoricsDictionary = dictionaries.getCombinatoricsDictionary();
+		File combinatoricsDictionaryFile = new File(compiledDicHomeFile, combinatorics + ".dic.compiled");
+		sortCompile(combinatoricsDictionary, combinatoricsDictionaryFile, charsetName);
+		
+		//
+		File compliedMetadataFile = new File(dicHomeFile, ".compiled/most-words-mode/.metadata");
+		if (compliedMetadataFile.exists()) {
+			//compliedMetadataFile.setWritable(true);
+			compliedMetadataFile.delete();
+		}
+		else {
+			compliedMetadataFile.getParentFile().mkdirs();
+		}
+		OutputStream compiledPropertiesOutput = new FileOutputStream(compliedMetadataFile);
+		Properties compiledProperties = new Properties();
+		String lastModifiedsKey = "paoding.analysis.properties.lastModifieds";
+		String filesKey = "paoding.analysis.properties.files";
+		compiledProperties.setProperty(lastModifiedsKey, p.getProperty(lastModifiedsKey));
+		compiledProperties.setProperty(filesKey, p.getProperty(filesKey));
+		compiledProperties.setProperty("paoding.analysis.compiler.checksum",
+				Snapshot.flash(
+						new File(dicHomeFile, ".compiled/most-words-mode"),
+						new FileFilter() {
+							public boolean accept(File pathname) {
+								return pathname.getPath().endsWith(
+										".dic.compiled");
+							}
+						}).getCheckSum());
+		compiledProperties.setProperty("paoding.analysis.compiler.class", this.getClass().getName());
+		compiledProperties.setProperty("paoding.analysis.compiler.version", VERSION);
+		compiledProperties.store(compiledPropertiesOutput, "dont edit it! this file was auto generated by paoding.");
+		compiledPropertiesOutput.close();
+		compliedMetadataFile.setReadOnly();
+	}
+
+
+	public Dictionaries readCompliedDictionaries(Properties p) {
+		String dicHomeAbsolutePath = p.getProperty("paoding.dic.home.absolute.path");
+		String noiseCharactor = getProperty(p, Constants.DIC_NOISE_CHARACTOR);
+		String noiseWord = getProperty(p, Constants.DIC_NOISE_WORD);
+		String unit = getProperty(p, Constants.DIC_UNIT);
+		String confucianFamilyName = getProperty(p, Constants.DIC_CONFUCIAN_FAMILY_NAME);
+		String combinatorics = getProperty(p, Constants.DIC_FOR_COMBINATORICS);
+		String charsetName = getProperty(p, Constants.DIC_CHARSET);
+		int maxWordLen = Integer.valueOf(getProperty(p, Constants.DIC_MAXWORDLEN));
+		return new CompiledFileDictionaries(
+				dicHomeAbsolutePath + "/.compiled/most-words-mode",
+				noiseCharactor, noiseWord, unit,
+				confucianFamilyName, combinatorics, charsetName,maxWordLen);
+	}
+	
+	private static String getProperty(Properties p, String name) {
+		return Constants.getProperty(p, name);
+	}
+	
+
+	private void sortCompile(final Dictionary dictionary, 
+			File dicFile, String charsetName) throws FileNotFoundException,
+			IOException, UnsupportedEncodingException {
+		int wordsSize = dictionary.size();
+		if (dicFile.exists()) {
+			//dicFile.setWritable(true);
+			dicFile.delete();
+		}
+		BufferedOutputStream out = new BufferedOutputStream(
+				new FileOutputStream(dicFile), 1024 * 16);
+		
+		for (int i = 0; i < wordsSize; i++) {
+			Word word = dictionary.get(i);
+			out.write(word.getText().getBytes(charsetName));
+			if (word.getModifiers() != Word.DEFAUL) {
+				out.write("[m=".getBytes());
+				out.write(String.valueOf(word.getModifiers()).getBytes());
+				out.write(']');
+			}
+			out.write('\r');
+			out.write('\n');
+		}
+		out.flush();
+		out.close();
+		dicFile.setReadOnly();
+	}
+	
+	private void compileVocabulary(final Dictionary vocabularyDictionary, Knife knife,
+			File vocabularyFile, String charsetName) throws FileNotFoundException,
+			IOException, UnsupportedEncodingException {
+		int vocabularySize = vocabularyDictionary.size();
+		Word[] vocabularyWords = new Word[vocabularySize];
+		char[] chs = new char[128];
+		for (int i = 0; i < vocabularySize; i ++) {
+			final Word curWord = vocabularyDictionary.get(i);
+			curWord.getText().getChars(0, curWord.length(), chs, 0);
+			chs[curWord.length()] = (char) -1;
+			Beef beef = new Beef(chs, 0, curWord.length() + 1);
+			final BitSet bs = new BitSet(curWord.length());
+			knife.dissect(new Collector(){
+				public void collect(String word, int offset, int end) {
+					Hit hit = vocabularyDictionary.search(word, 0, word.length());
+					if (hit.isHit() && hit.getWord().length() != curWord.length()) {
+						for (int j = offset; j < end; j++) {
+							bs.set(j, true);
+						}
+					}
+				}
+				
+			}, beef, 0);
+			
+			for (int j = 0; j < curWord.length();j++) {
+				if (!bs.get(j)) {
+					vocabularyWords[i] = curWord;
+					break;
+				}
+			}
+		}
+		if (vocabularyFile.exists()) {
+			//vocabularyFile.setWritable(true);
+			vocabularyFile.delete();
+		}
+		BufferedOutputStream out = new BufferedOutputStream(
+				new FileOutputStream(vocabularyFile), 1024 * 16);
+		
+		for (int i = 0; i < vocabularySize; i++) {
+			if (vocabularyWords[i] != null) {
+				out.write(vocabularyWords[i].getText().getBytes(charsetName));
+				if (vocabularyWords[i].getModifiers() != Word.DEFAUL) {
+					out.write("[m=".getBytes());
+					out.write(String.valueOf(vocabularyWords[i].getModifiers()).getBytes());
+					out.write(']');
+				}
+				out.write('\r');
+				out.write('\n');
+			}
+		}
+		out.flush();
+		out.close();
+		vocabularyFile.setReadOnly();
+	}
+}