commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r941823 [7/21] - in /websites/production/commons/content/sandbox/commons-text: ./ apidocs/ apidocs/org/apache/commons/text/diff/ apidocs/org/apache/commons/text/diff/class-use/ apidocs/org/apache/commons/text/similarity/ apidocs/org/apache/...
Date Sun, 01 Mar 2015 12:14:31 GMT
Added: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/ReplacementsHandler.html
==============================================================================
--- websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/ReplacementsHandler.html (added)
+++ websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/ReplacementsHandler.html Sun Mar  1 12:14:29 2015
@@ -0,0 +1,123 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="de">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * contributor license agreements.  See the NOTICE file distributed with<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * the License.  You may obtain a copy of the License at<a name="line.7"></a>
+<span class="sourceLineNo">008</span> *<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *      http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *<a name="line.10"></a>
+<span class="sourceLineNo">011</span> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * limitations under the License.<a name="line.15"></a>
+<span class="sourceLineNo">016</span> */<a name="line.16"></a>
+<span class="sourceLineNo">017</span>package org.apache.commons.text.diff;<a name="line.17"></a>
+<span class="sourceLineNo">018</span><a name="line.18"></a>
+<span class="sourceLineNo">019</span>import java.util.List;<a name="line.19"></a>
+<span class="sourceLineNo">020</span><a name="line.20"></a>
+<span class="sourceLineNo">021</span>/**<a name="line.21"></a>
+<span class="sourceLineNo">022</span> * This interface is devoted to handle synchronized replacement sequences.<a name="line.22"></a>
+<span class="sourceLineNo">023</span> *<a name="line.23"></a>
+<span class="sourceLineNo">024</span> * @see ReplacementsFinder<a name="line.24"></a>
+<span class="sourceLineNo">025</span> * @since 1.0<a name="line.25"></a>
+<span class="sourceLineNo">026</span> */<a name="line.26"></a>
+<span class="sourceLineNo">027</span>public interface ReplacementsHandler&lt;T&gt; {<a name="line.27"></a>
+<span class="sourceLineNo">028</span><a name="line.28"></a>
+<span class="sourceLineNo">029</span>    /**<a name="line.29"></a>
+<span class="sourceLineNo">030</span>     * Handle two synchronized sequences.<a name="line.30"></a>
+<span class="sourceLineNo">031</span>     * &lt;p&gt;<a name="line.31"></a>
+<span class="sourceLineNo">032</span>     * This method is called by a {@link ReplacementsFinder ReplacementsFinder}<a name="line.32"></a>
+<span class="sourceLineNo">033</span>     * instance when it has synchronized two sub-sequences of object arrays<a name="line.33"></a>
+<span class="sourceLineNo">034</span>     * being compared, and at least one of the sequences is non-empty. Since the<a name="line.34"></a>
+<span class="sourceLineNo">035</span>     * sequences are synchronized, the objects before the two sub-sequences are<a name="line.35"></a>
+<span class="sourceLineNo">036</span>     * equals (if they exist). This property also holds for the objects after<a name="line.36"></a>
+<span class="sourceLineNo">037</span>     * the two sub-sequences.<a name="line.37"></a>
+<span class="sourceLineNo">038</span>     * &lt;p&gt;<a name="line.38"></a>
+<span class="sourceLineNo">039</span>     * The replacement is defined as replacing the &lt;code&gt;from&lt;/code&gt;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>     * sub-sequence into the &lt;code&gt;to&lt;/code&gt; sub-sequence.<a name="line.40"></a>
+<span class="sourceLineNo">041</span>     *<a name="line.41"></a>
+<span class="sourceLineNo">042</span>     * @param skipped  number of tokens skipped since the last call (i.e. number of<a name="line.42"></a>
+<span class="sourceLineNo">043</span>     *   tokens that were in both sequences), this number should be strictly positive<a name="line.43"></a>
+<span class="sourceLineNo">044</span>     *   except on the very first call where it can be zero (if the first object of<a name="line.44"></a>
+<span class="sourceLineNo">045</span>     *   the two sequences are different)<a name="line.45"></a>
+<span class="sourceLineNo">046</span>     * @param from  sub-sequence of objects coming from the first sequence<a name="line.46"></a>
+<span class="sourceLineNo">047</span>     * @param to  sub-sequence of objects coming from the second sequence<a name="line.47"></a>
+<span class="sourceLineNo">048</span>     */<a name="line.48"></a>
+<span class="sourceLineNo">049</span>    void handleReplacement(int skipped, List&lt;T&gt; from, List&lt;T&gt; to);<a name="line.49"></a>
+<span class="sourceLineNo">050</span><a name="line.50"></a>
+<span class="sourceLineNo">051</span>}<a name="line.51"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>
\ No newline at end of file

Propchange: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/ReplacementsHandler.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/StringsComparator.html
==============================================================================
--- websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/StringsComparator.html (added)
+++ websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/StringsComparator.html Sun Mar  1 12:14:29 2015
@@ -0,0 +1,400 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="de">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * contributor license agreements.  See the NOTICE file distributed with<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * the License.  You may obtain a copy of the License at<a name="line.7"></a>
+<span class="sourceLineNo">008</span> *<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *      http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *<a name="line.10"></a>
+<span class="sourceLineNo">011</span> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * limitations under the License.<a name="line.15"></a>
+<span class="sourceLineNo">016</span> */<a name="line.16"></a>
+<span class="sourceLineNo">017</span>package org.apache.commons.text.diff;<a name="line.17"></a>
+<span class="sourceLineNo">018</span><a name="line.18"></a>
+<span class="sourceLineNo">019</span>/**<a name="line.19"></a>
+<span class="sourceLineNo">020</span> * &lt;p&gt;<a name="line.20"></a>
+<span class="sourceLineNo">021</span> * It is guaranteed that the comparisons will always be done as<a name="line.21"></a>
+<span class="sourceLineNo">022</span> * &lt;code&gt;o1.equals(o2)&lt;/code&gt; where &lt;code&gt;o1&lt;/code&gt; belongs to the first<a name="line.22"></a>
+<span class="sourceLineNo">023</span> * sequence and &lt;code&gt;o2&lt;/code&gt; belongs to the second sequence. This can<a name="line.23"></a>
+<span class="sourceLineNo">024</span> * be important if subclassing is used for some elements in the first<a name="line.24"></a>
+<span class="sourceLineNo">025</span> * sequence and the &lt;code&gt;equals&lt;/code&gt; method is specialized.<a name="line.25"></a>
+<span class="sourceLineNo">026</span> * &lt;/p&gt;<a name="line.26"></a>
+<span class="sourceLineNo">027</span> * &lt;p&gt;<a name="line.27"></a>
+<span class="sourceLineNo">028</span> * Comparison can be seen from two points of view: either as giving the smallest<a name="line.28"></a>
+<span class="sourceLineNo">029</span> * modification allowing to transform the first sequence into the second one, or<a name="line.29"></a>
+<span class="sourceLineNo">030</span> * as giving the longest sequence which is a subsequence of both initial<a name="line.30"></a>
+<span class="sourceLineNo">031</span> * sequences. The &lt;code&gt;equals&lt;/code&gt; method is used to compare objects, so any<a name="line.31"></a>
+<span class="sourceLineNo">032</span> * object can be put into sequences. Modifications include deleting, inserting<a name="line.32"></a>
+<span class="sourceLineNo">033</span> * or keeping one object, starting from the beginning of the first sequence.<a name="line.33"></a>
+<span class="sourceLineNo">034</span> * &lt;/p&gt;<a name="line.34"></a>
+<span class="sourceLineNo">035</span> * &lt;p&gt;<a name="line.35"></a>
+<span class="sourceLineNo">036</span> * This class implements the comparison algorithm, which is the very efficient<a name="line.36"></a>
+<span class="sourceLineNo">037</span> * algorithm from Eugene W. Myers<a name="line.37"></a>
+<span class="sourceLineNo">038</span> * &lt;a href="http://www.cis.upenn.edu/~bcpierce/courses/dd/papers/diff.ps"&gt;<a name="line.38"></a>
+<span class="sourceLineNo">039</span> * An O(ND) Difference Algorithm and Its Variations&lt;/a&gt;. This algorithm produces<a name="line.39"></a>
+<span class="sourceLineNo">040</span> * the shortest possible {@link EditScript edit script} containing all the<a name="line.40"></a>
+<span class="sourceLineNo">041</span> * {@link EditCommand commands} needed to transform the first sequence into<a name="line.41"></a>
+<span class="sourceLineNo">042</span> * the second one.<a name="line.42"></a>
+<span class="sourceLineNo">043</span> *<a name="line.43"></a>
+<span class="sourceLineNo">044</span> * &lt;p&gt;<a name="line.44"></a>
+<span class="sourceLineNo">045</span> * This code has been adapted from Apache Commons Collections 4.0.<a name="line.45"></a>
+<span class="sourceLineNo">046</span> * &lt;/p&gt;<a name="line.46"></a>
+<span class="sourceLineNo">047</span> *<a name="line.47"></a>
+<span class="sourceLineNo">048</span> * @see EditScript<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * @see EditCommand<a name="line.49"></a>
+<span class="sourceLineNo">050</span> * @see CommandVisitor<a name="line.50"></a>
+<span class="sourceLineNo">051</span> *<a name="line.51"></a>
+<span class="sourceLineNo">052</span> * @since 1.0<a name="line.52"></a>
+<span class="sourceLineNo">053</span> */<a name="line.53"></a>
+<span class="sourceLineNo">054</span>public class StringsComparator {<a name="line.54"></a>
+<span class="sourceLineNo">055</span><a name="line.55"></a>
+<span class="sourceLineNo">056</span>    /**<a name="line.56"></a>
+<span class="sourceLineNo">057</span>     * First character sequence.<a name="line.57"></a>
+<span class="sourceLineNo">058</span>     */<a name="line.58"></a>
+<span class="sourceLineNo">059</span>    private final String left;<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    /**<a name="line.60"></a>
+<span class="sourceLineNo">061</span>     * Second character sequence.<a name="line.61"></a>
+<span class="sourceLineNo">062</span>     */<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    private final String right;<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>    /** Temporary variables. */<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    private final int[] vDown;<a name="line.66"></a>
+<span class="sourceLineNo">067</span>    private final int[] vUp;<a name="line.67"></a>
+<span class="sourceLineNo">068</span><a name="line.68"></a>
+<span class="sourceLineNo">069</span>    /**<a name="line.69"></a>
+<span class="sourceLineNo">070</span>     * Simple constructor.<a name="line.70"></a>
+<span class="sourceLineNo">071</span>     * &lt;p&gt;<a name="line.71"></a>
+<span class="sourceLineNo">072</span>     * Creates a new instance of StringsComparator.<a name="line.72"></a>
+<span class="sourceLineNo">073</span>     * &lt;/p&gt;<a name="line.73"></a>
+<span class="sourceLineNo">074</span>     * &lt;p&gt;<a name="line.74"></a>
+<span class="sourceLineNo">075</span>     * It is &lt;em&gt;guaranteed&lt;/em&gt; that the comparisons will always be done as<a name="line.75"></a>
+<span class="sourceLineNo">076</span>     * &lt;code&gt;o1.equals(o2)&lt;/code&gt; where &lt;code&gt;o1&lt;/code&gt; belongs to the first<a name="line.76"></a>
+<span class="sourceLineNo">077</span>     * sequence and &lt;code&gt;o2&lt;/code&gt; belongs to the second sequence. This can be<a name="line.77"></a>
+<span class="sourceLineNo">078</span>     * important if subclassing is used for some elements in the first sequence<a name="line.78"></a>
+<span class="sourceLineNo">079</span>     * and the &lt;code&gt;equals&lt;/code&gt; method is specialized.<a name="line.79"></a>
+<span class="sourceLineNo">080</span>     * &lt;/p&gt;<a name="line.80"></a>
+<span class="sourceLineNo">081</span>     *<a name="line.81"></a>
+<span class="sourceLineNo">082</span>     * @param left first character sequence to be compared<a name="line.82"></a>
+<span class="sourceLineNo">083</span>     * @param right second character sequence to be compared<a name="line.83"></a>
+<span class="sourceLineNo">084</span>     */<a name="line.84"></a>
+<span class="sourceLineNo">085</span>    public StringsComparator(String left, String right) {<a name="line.85"></a>
+<span class="sourceLineNo">086</span>        this.left = left;<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        this.right = right;<a name="line.87"></a>
+<span class="sourceLineNo">088</span><a name="line.88"></a>
+<span class="sourceLineNo">089</span>        final int size = left.length() + right.length() + 2;<a name="line.89"></a>
+<span class="sourceLineNo">090</span>        vDown = new int[size];<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        vUp   = new int[size];<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    }<a name="line.92"></a>
+<span class="sourceLineNo">093</span><a name="line.93"></a>
+<span class="sourceLineNo">094</span>    /**<a name="line.94"></a>
+<span class="sourceLineNo">095</span>     * Get the {@link EditScript} object.<a name="line.95"></a>
+<span class="sourceLineNo">096</span>     * &lt;p&gt;<a name="line.96"></a>
+<span class="sourceLineNo">097</span>     * It is guaranteed that the objects embedded in the {@link InsertCommand<a name="line.97"></a>
+<span class="sourceLineNo">098</span>     * insert commands} come from the second sequence and that the objects<a name="line.98"></a>
+<span class="sourceLineNo">099</span>     * embedded in either the {@link DeleteCommand delete commands} or<a name="line.99"></a>
+<span class="sourceLineNo">100</span>     * {@link KeepCommand keep commands} come from the first sequence. This can<a name="line.100"></a>
+<span class="sourceLineNo">101</span>     * be important if subclassing is used for some elements in the first<a name="line.101"></a>
+<span class="sourceLineNo">102</span>     * sequence and the &lt;code&gt;equals&lt;/code&gt; method is specialized.<a name="line.102"></a>
+<span class="sourceLineNo">103</span>     * &lt;/p&gt;<a name="line.103"></a>
+<span class="sourceLineNo">104</span>     *<a name="line.104"></a>
+<span class="sourceLineNo">105</span>     * @return the edit script resulting from the comparison of the two<a name="line.105"></a>
+<span class="sourceLineNo">106</span>     *         sequences<a name="line.106"></a>
+<span class="sourceLineNo">107</span>     */<a name="line.107"></a>
+<span class="sourceLineNo">108</span>    public EditScript&lt;Character&gt; getScript() {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>        final EditScript&lt;Character&gt; script = new EditScript&lt;Character&gt;();<a name="line.109"></a>
+<span class="sourceLineNo">110</span>        buildScript(0, left.length(), 0, right.length(), script);<a name="line.110"></a>
+<span class="sourceLineNo">111</span>        return script;<a name="line.111"></a>
+<span class="sourceLineNo">112</span>    }<a name="line.112"></a>
+<span class="sourceLineNo">113</span><a name="line.113"></a>
+<span class="sourceLineNo">114</span>    /**<a name="line.114"></a>
+<span class="sourceLineNo">115</span>     * Build an edit script.<a name="line.115"></a>
+<span class="sourceLineNo">116</span>     *<a name="line.116"></a>
+<span class="sourceLineNo">117</span>     * @param start1  the begin of the first sequence to be compared<a name="line.117"></a>
+<span class="sourceLineNo">118</span>     * @param end1  the end of the first sequence to be compared<a name="line.118"></a>
+<span class="sourceLineNo">119</span>     * @param start2  the begin of the second sequence to be compared<a name="line.119"></a>
+<span class="sourceLineNo">120</span>     * @param end2  the end of the second sequence to be compared<a name="line.120"></a>
+<span class="sourceLineNo">121</span>     * @param script the edited script<a name="line.121"></a>
+<span class="sourceLineNo">122</span>     */<a name="line.122"></a>
+<span class="sourceLineNo">123</span>    private void buildScript(final int start1, final int end1, final int start2, final int end2,<a name="line.123"></a>
+<span class="sourceLineNo">124</span>            final EditScript&lt;Character&gt; script) {<a name="line.124"></a>
+<span class="sourceLineNo">125</span>        final Snake middle = getMiddleSnake(start1, end1, start2, end2);<a name="line.125"></a>
+<span class="sourceLineNo">126</span><a name="line.126"></a>
+<span class="sourceLineNo">127</span>        if (middle == null<a name="line.127"></a>
+<span class="sourceLineNo">128</span>                || middle.getStart() == end1 &amp;&amp; middle.getDiag() == end1 - end2<a name="line.128"></a>
+<span class="sourceLineNo">129</span>                || middle.getEnd() == start1 &amp;&amp; middle.getDiag() == start1 - start2) {<a name="line.129"></a>
+<span class="sourceLineNo">130</span><a name="line.130"></a>
+<span class="sourceLineNo">131</span>            int i = start1;<a name="line.131"></a>
+<span class="sourceLineNo">132</span>            int j = start2;<a name="line.132"></a>
+<span class="sourceLineNo">133</span>            while (i &lt; end1 || j &lt; end2) {<a name="line.133"></a>
+<span class="sourceLineNo">134</span>                if (i &lt; end1 &amp;&amp; j &lt; end2 &amp;&amp; left.charAt(i) == right.charAt(j)) {<a name="line.134"></a>
+<span class="sourceLineNo">135</span>                    script.append(new KeepCommand&lt;Character&gt;(left.charAt(i)));<a name="line.135"></a>
+<span class="sourceLineNo">136</span>                    ++i;<a name="line.136"></a>
+<span class="sourceLineNo">137</span>                    ++j;<a name="line.137"></a>
+<span class="sourceLineNo">138</span>                } else {<a name="line.138"></a>
+<span class="sourceLineNo">139</span>                    if (end1 - start1 &gt; end2 - start2) {<a name="line.139"></a>
+<span class="sourceLineNo">140</span>                        script.append(new DeleteCommand&lt;Character&gt;(left.charAt(i)));<a name="line.140"></a>
+<span class="sourceLineNo">141</span>                        ++i;<a name="line.141"></a>
+<span class="sourceLineNo">142</span>                    } else {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>                        script.append(new InsertCommand&lt;Character&gt;(right.charAt(j)));<a name="line.143"></a>
+<span class="sourceLineNo">144</span>                        ++j;<a name="line.144"></a>
+<span class="sourceLineNo">145</span>                    }<a name="line.145"></a>
+<span class="sourceLineNo">146</span>                }<a name="line.146"></a>
+<span class="sourceLineNo">147</span>            }<a name="line.147"></a>
+<span class="sourceLineNo">148</span><a name="line.148"></a>
+<span class="sourceLineNo">149</span>        } else {<a name="line.149"></a>
+<span class="sourceLineNo">150</span><a name="line.150"></a>
+<span class="sourceLineNo">151</span>            buildScript(start1, middle.getStart(),<a name="line.151"></a>
+<span class="sourceLineNo">152</span>                        start2, middle.getStart() - middle.getDiag(),<a name="line.152"></a>
+<span class="sourceLineNo">153</span>                        script);<a name="line.153"></a>
+<span class="sourceLineNo">154</span>            for (int i = middle.getStart(); i &lt; middle.getEnd(); ++i) {<a name="line.154"></a>
+<span class="sourceLineNo">155</span>                script.append(new KeepCommand&lt;Character&gt;(left.charAt(i)));<a name="line.155"></a>
+<span class="sourceLineNo">156</span>            }<a name="line.156"></a>
+<span class="sourceLineNo">157</span>            buildScript(middle.getEnd(), end1,<a name="line.157"></a>
+<span class="sourceLineNo">158</span>                        middle.getEnd() - middle.getDiag(), end2,<a name="line.158"></a>
+<span class="sourceLineNo">159</span>                        script);<a name="line.159"></a>
+<span class="sourceLineNo">160</span>        }<a name="line.160"></a>
+<span class="sourceLineNo">161</span>    }<a name="line.161"></a>
+<span class="sourceLineNo">162</span><a name="line.162"></a>
+<span class="sourceLineNo">163</span>    /**<a name="line.163"></a>
+<span class="sourceLineNo">164</span>     * Get the middle snake corresponding to two subsequences of the<a name="line.164"></a>
+<span class="sourceLineNo">165</span>     * main sequences.<a name="line.165"></a>
+<span class="sourceLineNo">166</span>     * &lt;p&gt;<a name="line.166"></a>
+<span class="sourceLineNo">167</span>     * The snake is found using the MYERS Algorithm (this algorithms has<a name="line.167"></a>
+<span class="sourceLineNo">168</span>     * also been implemented in the GNU diff program). This algorithm is<a name="line.168"></a>
+<span class="sourceLineNo">169</span>     * explained in Eugene Myers article:<a name="line.169"></a>
+<span class="sourceLineNo">170</span>     * &lt;a href="http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps"&gt;<a name="line.170"></a>
+<span class="sourceLineNo">171</span>     * An O(ND) Difference Algorithm and Its Variations&lt;/a&gt;.<a name="line.171"></a>
+<span class="sourceLineNo">172</span>     * &lt;/p&gt;<a name="line.172"></a>
+<span class="sourceLineNo">173</span>     *<a name="line.173"></a>
+<span class="sourceLineNo">174</span>     * @param start1  the begin of the first sequence to be compared<a name="line.174"></a>
+<span class="sourceLineNo">175</span>     * @param end1  the end of the first sequence to be compared<a name="line.175"></a>
+<span class="sourceLineNo">176</span>     * @param start2  the begin of the second sequence to be compared<a name="line.176"></a>
+<span class="sourceLineNo">177</span>     * @param end2  the end of the second sequence to be compared<a name="line.177"></a>
+<span class="sourceLineNo">178</span>     * @return the middle snake<a name="line.178"></a>
+<span class="sourceLineNo">179</span>     */<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    private Snake getMiddleSnake(int start1, int end1, int start2, int end2) {<a name="line.180"></a>
+<span class="sourceLineNo">181</span>        // Myers Algorithm<a name="line.181"></a>
+<span class="sourceLineNo">182</span>        // Initialisations<a name="line.182"></a>
+<span class="sourceLineNo">183</span>        final int m = end1 - start1;<a name="line.183"></a>
+<span class="sourceLineNo">184</span>        final int n = end2 - start2;<a name="line.184"></a>
+<span class="sourceLineNo">185</span>        if (m == 0 || n == 0) {<a name="line.185"></a>
+<span class="sourceLineNo">186</span>            return null;<a name="line.186"></a>
+<span class="sourceLineNo">187</span>        }<a name="line.187"></a>
+<span class="sourceLineNo">188</span><a name="line.188"></a>
+<span class="sourceLineNo">189</span>        final int delta  = m - n;<a name="line.189"></a>
+<span class="sourceLineNo">190</span>        final int sum    = n + m;<a name="line.190"></a>
+<span class="sourceLineNo">191</span>        final int offset = (sum % 2 == 0 ? sum : sum + 1) / 2;<a name="line.191"></a>
+<span class="sourceLineNo">192</span>        vDown[1+offset] = start1;<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        vUp[1+offset]   = end1 + 1;<a name="line.193"></a>
+<span class="sourceLineNo">194</span><a name="line.194"></a>
+<span class="sourceLineNo">195</span>        for (int d = 0; d &lt;= offset ; ++d) {<a name="line.195"></a>
+<span class="sourceLineNo">196</span>            // Down<a name="line.196"></a>
+<span class="sourceLineNo">197</span>            for (int k = -d; k &lt;= d; k += 2) {<a name="line.197"></a>
+<span class="sourceLineNo">198</span>                // First step<a name="line.198"></a>
+<span class="sourceLineNo">199</span><a name="line.199"></a>
+<span class="sourceLineNo">200</span>                final int i = k + offset;<a name="line.200"></a>
+<span class="sourceLineNo">201</span>                if (k == -d || k != d &amp;&amp; vDown[i-1] &lt; vDown[i+1]) {<a name="line.201"></a>
+<span class="sourceLineNo">202</span>                    vDown[i] = vDown[i+1];<a name="line.202"></a>
+<span class="sourceLineNo">203</span>                } else {<a name="line.203"></a>
+<span class="sourceLineNo">204</span>                    vDown[i] = vDown[i-1] + 1;<a name="line.204"></a>
+<span class="sourceLineNo">205</span>                }<a name="line.205"></a>
+<span class="sourceLineNo">206</span><a name="line.206"></a>
+<span class="sourceLineNo">207</span>                int x = vDown[i];<a name="line.207"></a>
+<span class="sourceLineNo">208</span>                int y = x - start1 + start2 - k;<a name="line.208"></a>
+<span class="sourceLineNo">209</span><a name="line.209"></a>
+<span class="sourceLineNo">210</span>                while (x &lt; end1 &amp;&amp; y &lt; end2 &amp;&amp; left.charAt(x) == right.charAt(y)) {<a name="line.210"></a>
+<span class="sourceLineNo">211</span>                    vDown[i] = ++x;<a name="line.211"></a>
+<span class="sourceLineNo">212</span>                    ++y;<a name="line.212"></a>
+<span class="sourceLineNo">213</span>                }<a name="line.213"></a>
+<span class="sourceLineNo">214</span>                // Second step<a name="line.214"></a>
+<span class="sourceLineNo">215</span>                if (delta % 2 != 0 &amp;&amp; delta - d &lt;= k &amp;&amp; k &lt;= delta + d) {<a name="line.215"></a>
+<span class="sourceLineNo">216</span>                    if (vUp[i-delta] &lt;= vDown[i]) {<a name="line.216"></a>
+<span class="sourceLineNo">217</span>                        return buildSnake(vUp[i-delta], k + start1 - start2, end1, end2);<a name="line.217"></a>
+<span class="sourceLineNo">218</span>                    }<a name="line.218"></a>
+<span class="sourceLineNo">219</span>                }<a name="line.219"></a>
+<span class="sourceLineNo">220</span>            }<a name="line.220"></a>
+<span class="sourceLineNo">221</span><a name="line.221"></a>
+<span class="sourceLineNo">222</span>            // Up<a name="line.222"></a>
+<span class="sourceLineNo">223</span>            for (int k = delta - d; k &lt;= delta + d; k += 2) {<a name="line.223"></a>
+<span class="sourceLineNo">224</span>                // First step<a name="line.224"></a>
+<span class="sourceLineNo">225</span>                final int i = k + offset - delta;<a name="line.225"></a>
+<span class="sourceLineNo">226</span>                if (k == delta - d<a name="line.226"></a>
+<span class="sourceLineNo">227</span>                        || k != delta + d &amp;&amp; vUp[i+1] &lt;= vUp[i-1]) {<a name="line.227"></a>
+<span class="sourceLineNo">228</span>                    vUp[i] = vUp[i+1] - 1;<a name="line.228"></a>
+<span class="sourceLineNo">229</span>                } else {<a name="line.229"></a>
+<span class="sourceLineNo">230</span>                    vUp[i] = vUp[i-1];<a name="line.230"></a>
+<span class="sourceLineNo">231</span>                }<a name="line.231"></a>
+<span class="sourceLineNo">232</span><a name="line.232"></a>
+<span class="sourceLineNo">233</span>                int x = vUp[i] - 1;<a name="line.233"></a>
+<span class="sourceLineNo">234</span>                int y = x - start1 + start2 - k;<a name="line.234"></a>
+<span class="sourceLineNo">235</span>                while (x &gt;= start1 &amp;&amp; y &gt;= start2<a name="line.235"></a>
+<span class="sourceLineNo">236</span>                        &amp;&amp; left.charAt(x) == right.charAt(y)) {<a name="line.236"></a>
+<span class="sourceLineNo">237</span>                    vUp[i] = x--;<a name="line.237"></a>
+<span class="sourceLineNo">238</span>                    y--;<a name="line.238"></a>
+<span class="sourceLineNo">239</span>                }<a name="line.239"></a>
+<span class="sourceLineNo">240</span>                // Second step<a name="line.240"></a>
+<span class="sourceLineNo">241</span>                if (delta % 2 == 0 &amp;&amp; -d &lt;= k &amp;&amp; k &lt;= d ) {<a name="line.241"></a>
+<span class="sourceLineNo">242</span>                    if (vUp[i] &lt;= vDown[i + delta]) {<a name="line.242"></a>
+<span class="sourceLineNo">243</span>                        return buildSnake(vUp[i], k + start1 - start2, end1, end2);<a name="line.243"></a>
+<span class="sourceLineNo">244</span>                    }<a name="line.244"></a>
+<span class="sourceLineNo">245</span>                }<a name="line.245"></a>
+<span class="sourceLineNo">246</span>            }<a name="line.246"></a>
+<span class="sourceLineNo">247</span>        }<a name="line.247"></a>
+<span class="sourceLineNo">248</span><a name="line.248"></a>
+<span class="sourceLineNo">249</span>        // this should not happen<a name="line.249"></a>
+<span class="sourceLineNo">250</span>        throw new RuntimeException("Internal Error");<a name="line.250"></a>
+<span class="sourceLineNo">251</span>    }<a name="line.251"></a>
+<span class="sourceLineNo">252</span><a name="line.252"></a>
+<span class="sourceLineNo">253</span>    /**<a name="line.253"></a>
+<span class="sourceLineNo">254</span>     * Build a snake.<a name="line.254"></a>
+<span class="sourceLineNo">255</span>     *<a name="line.255"></a>
+<span class="sourceLineNo">256</span>     * @param start  the value of the start of the snake<a name="line.256"></a>
+<span class="sourceLineNo">257</span>     * @param diag  the value of the diagonal of the snake<a name="line.257"></a>
+<span class="sourceLineNo">258</span>     * @param end1  the value of the end of the first sequence to be compared<a name="line.258"></a>
+<span class="sourceLineNo">259</span>     * @param end2  the value of the end of the second sequence to be compared<a name="line.259"></a>
+<span class="sourceLineNo">260</span>     * @return the snake built<a name="line.260"></a>
+<span class="sourceLineNo">261</span>     */<a name="line.261"></a>
+<span class="sourceLineNo">262</span>    private Snake buildSnake(final int start, final int diag, final int end1, final int end2) {<a name="line.262"></a>
+<span class="sourceLineNo">263</span>        int end = start;<a name="line.263"></a>
+<span class="sourceLineNo">264</span>        while (end - diag &lt; end2<a name="line.264"></a>
+<span class="sourceLineNo">265</span>                &amp;&amp; end &lt; end1<a name="line.265"></a>
+<span class="sourceLineNo">266</span>                &amp;&amp; left.charAt(end) == right.charAt(end - diag)) {<a name="line.266"></a>
+<span class="sourceLineNo">267</span>            ++end;<a name="line.267"></a>
+<span class="sourceLineNo">268</span>        }<a name="line.268"></a>
+<span class="sourceLineNo">269</span>        return new Snake(start, end, diag);<a name="line.269"></a>
+<span class="sourceLineNo">270</span>    }<a name="line.270"></a>
+<span class="sourceLineNo">271</span><a name="line.271"></a>
+<span class="sourceLineNo">272</span>    /**<a name="line.272"></a>
+<span class="sourceLineNo">273</span>     * This class is a simple placeholder to hold the end part of a path<a name="line.273"></a>
+<span class="sourceLineNo">274</span>     * under construction in a {@link StringsComparator StringsComparator}.<a name="line.274"></a>
+<span class="sourceLineNo">275</span>     */<a name="line.275"></a>
+<span class="sourceLineNo">276</span>    private static class Snake {<a name="line.276"></a>
+<span class="sourceLineNo">277</span><a name="line.277"></a>
+<span class="sourceLineNo">278</span>        /** Start index. */<a name="line.278"></a>
+<span class="sourceLineNo">279</span>        private final int start;<a name="line.279"></a>
+<span class="sourceLineNo">280</span><a name="line.280"></a>
+<span class="sourceLineNo">281</span>        /** End index. */<a name="line.281"></a>
+<span class="sourceLineNo">282</span>        private final int end;<a name="line.282"></a>
+<span class="sourceLineNo">283</span><a name="line.283"></a>
+<span class="sourceLineNo">284</span>        /** Diagonal number. */<a name="line.284"></a>
+<span class="sourceLineNo">285</span>        private final int diag;<a name="line.285"></a>
+<span class="sourceLineNo">286</span><a name="line.286"></a>
+<span class="sourceLineNo">287</span>        /**<a name="line.287"></a>
+<span class="sourceLineNo">288</span>         * Simple constructor. Creates a new instance of Snake with specified indices.<a name="line.288"></a>
+<span class="sourceLineNo">289</span>         *<a name="line.289"></a>
+<span class="sourceLineNo">290</span>         * @param start  start index of the snake<a name="line.290"></a>
+<span class="sourceLineNo">291</span>         * @param end  end index of the snake<a name="line.291"></a>
+<span class="sourceLineNo">292</span>         * @param diag  diagonal number<a name="line.292"></a>
+<span class="sourceLineNo">293</span>         */<a name="line.293"></a>
+<span class="sourceLineNo">294</span>        public Snake(final int start, final int end, final int diag) {<a name="line.294"></a>
+<span class="sourceLineNo">295</span>            this.start = start;<a name="line.295"></a>
+<span class="sourceLineNo">296</span>            this.end   = end;<a name="line.296"></a>
+<span class="sourceLineNo">297</span>            this.diag  = diag;<a name="line.297"></a>
+<span class="sourceLineNo">298</span>        }<a name="line.298"></a>
+<span class="sourceLineNo">299</span><a name="line.299"></a>
+<span class="sourceLineNo">300</span>        /**<a name="line.300"></a>
+<span class="sourceLineNo">301</span>         * Get the start index of the snake.<a name="line.301"></a>
+<span class="sourceLineNo">302</span>         *<a name="line.302"></a>
+<span class="sourceLineNo">303</span>         * @return start index of the snake<a name="line.303"></a>
+<span class="sourceLineNo">304</span>         */<a name="line.304"></a>
+<span class="sourceLineNo">305</span>        public int getStart() {<a name="line.305"></a>
+<span class="sourceLineNo">306</span>            return start;<a name="line.306"></a>
+<span class="sourceLineNo">307</span>        }<a name="line.307"></a>
+<span class="sourceLineNo">308</span><a name="line.308"></a>
+<span class="sourceLineNo">309</span>        /**<a name="line.309"></a>
+<span class="sourceLineNo">310</span>         * Get the end index of the snake.<a name="line.310"></a>
+<span class="sourceLineNo">311</span>         *<a name="line.311"></a>
+<span class="sourceLineNo">312</span>         * @return end index of the snake<a name="line.312"></a>
+<span class="sourceLineNo">313</span>         */<a name="line.313"></a>
+<span class="sourceLineNo">314</span>        public int getEnd() {<a name="line.314"></a>
+<span class="sourceLineNo">315</span>            return end;<a name="line.315"></a>
+<span class="sourceLineNo">316</span>        }<a name="line.316"></a>
+<span class="sourceLineNo">317</span><a name="line.317"></a>
+<span class="sourceLineNo">318</span>        /**<a name="line.318"></a>
+<span class="sourceLineNo">319</span>         * Get the diagonal number of the snake.<a name="line.319"></a>
+<span class="sourceLineNo">320</span>         *<a name="line.320"></a>
+<span class="sourceLineNo">321</span>         * @return diagonal number of the snake<a name="line.321"></a>
+<span class="sourceLineNo">322</span>         */<a name="line.322"></a>
+<span class="sourceLineNo">323</span>        public int getDiag() {<a name="line.323"></a>
+<span class="sourceLineNo">324</span>            return diag;<a name="line.324"></a>
+<span class="sourceLineNo">325</span>        }<a name="line.325"></a>
+<span class="sourceLineNo">326</span>    }<a name="line.326"></a>
+<span class="sourceLineNo">327</span><a name="line.327"></a>
+<span class="sourceLineNo">328</span>}<a name="line.328"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>
\ No newline at end of file

Propchange: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/StringsComparator.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/FuzzyScore.html
==============================================================================
--- websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/FuzzyScore.html (added)
+++ websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/FuzzyScore.html Sun Mar  1 12:14:29 2015
@@ -0,0 +1,205 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="de">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * contributor license agreements.  See the NOTICE file distributed with<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * the License.  You may obtain a copy of the License at<a name="line.7"></a>
+<span class="sourceLineNo">008</span> *<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *      http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *<a name="line.10"></a>
+<span class="sourceLineNo">011</span> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * limitations under the License.<a name="line.15"></a>
+<span class="sourceLineNo">016</span> */<a name="line.16"></a>
+<span class="sourceLineNo">017</span>package org.apache.commons.text.similarity;<a name="line.17"></a>
+<span class="sourceLineNo">018</span><a name="line.18"></a>
+<span class="sourceLineNo">019</span>import java.util.Locale;<a name="line.19"></a>
+<span class="sourceLineNo">020</span><a name="line.20"></a>
+<span class="sourceLineNo">021</span>/**<a name="line.21"></a>
+<span class="sourceLineNo">022</span> * A matching algorithm that is similar to the searching algorithms implemented in editors such<a name="line.22"></a>
+<span class="sourceLineNo">023</span> * as Sublime Text, TextMate, Atom and others.<a name="line.23"></a>
+<span class="sourceLineNo">024</span> *<a name="line.24"></a>
+<span class="sourceLineNo">025</span> * &lt;p&gt;<a name="line.25"></a>
+<span class="sourceLineNo">026</span> * One point is given for every matched character. Subsequent matches yield two bonus points. A higher score<a name="line.26"></a>
+<span class="sourceLineNo">027</span> * indicates a higher similarity.<a name="line.27"></a>
+<span class="sourceLineNo">028</span> * &lt;/p&gt;<a name="line.28"></a>
+<span class="sourceLineNo">029</span> *<a name="line.29"></a>
+<span class="sourceLineNo">030</span> * &lt;p&gt;<a name="line.30"></a>
+<span class="sourceLineNo">031</span> * This code has been adapted from Apache Commons Lang 3.3.<a name="line.31"></a>
+<span class="sourceLineNo">032</span> * &lt;/p&gt;<a name="line.32"></a>
+<span class="sourceLineNo">033</span> */<a name="line.33"></a>
+<span class="sourceLineNo">034</span>public class FuzzyScore implements StringMetric&lt;Integer&gt; {<a name="line.34"></a>
+<span class="sourceLineNo">035</span><a name="line.35"></a>
+<span class="sourceLineNo">036</span>    /**<a name="line.36"></a>
+<span class="sourceLineNo">037</span>     * &lt;p&gt;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>     * Find the Fuzzy Score which indicates the similarity score between two<a name="line.38"></a>
+<span class="sourceLineNo">039</span>     * Strings. This method uses the default locale.<a name="line.39"></a>
+<span class="sourceLineNo">040</span>     * &lt;/p&gt;<a name="line.40"></a>
+<span class="sourceLineNo">041</span>     *<a name="line.41"></a>
+<span class="sourceLineNo">042</span>     * @param term a full term that should be matched against, must not be null<a name="line.42"></a>
+<span class="sourceLineNo">043</span>     * @param query the query that will be matched against a term, must not be<a name="line.43"></a>
+<span class="sourceLineNo">044</span>     *            null<a name="line.44"></a>
+<span class="sourceLineNo">045</span>     * @return result score<a name="line.45"></a>
+<span class="sourceLineNo">046</span>     * @throws IllegalArgumentException if either String input {@code null}<a name="line.46"></a>
+<span class="sourceLineNo">047</span>     */<a name="line.47"></a>
+<span class="sourceLineNo">048</span>    @Override<a name="line.48"></a>
+<span class="sourceLineNo">049</span>    public Integer compare(CharSequence term, CharSequence query) {<a name="line.49"></a>
+<span class="sourceLineNo">050</span>        return compare(term, query, Locale.getDefault());<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    }<a name="line.51"></a>
+<span class="sourceLineNo">052</span><a name="line.52"></a>
+<span class="sourceLineNo">053</span>    /**<a name="line.53"></a>
+<span class="sourceLineNo">054</span>     * &lt;p&gt;<a name="line.54"></a>
+<span class="sourceLineNo">055</span>     * Find the Fuzzy Score which indicates the similarity score between two<a name="line.55"></a>
+<span class="sourceLineNo">056</span>     * Strings.<a name="line.56"></a>
+<span class="sourceLineNo">057</span>     * &lt;/p&gt;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>     *<a name="line.58"></a>
+<span class="sourceLineNo">059</span>     * &lt;pre&gt;<a name="line.59"></a>
+<span class="sourceLineNo">060</span>     * score.compare(null, null, null)                                    = IllegalArgumentException<a name="line.60"></a>
+<span class="sourceLineNo">061</span>     * score.compare("", "", Locale.ENGLISH)                              = 0<a name="line.61"></a>
+<span class="sourceLineNo">062</span>     * score.compare("Workshop", "b", Locale.ENGLISH)                     = 0<a name="line.62"></a>
+<span class="sourceLineNo">063</span>     * score.compare("Room", "o", Locale.ENGLISH)                         = 1<a name="line.63"></a>
+<span class="sourceLineNo">064</span>     * score.compare("Workshop", "w", Locale.ENGLISH)                     = 1<a name="line.64"></a>
+<span class="sourceLineNo">065</span>     * score.compare("Workshop", "ws", Locale.ENGLISH)                    = 2<a name="line.65"></a>
+<span class="sourceLineNo">066</span>     * score.compare("Workshop", "wo", Locale.ENGLISH)                    = 4<a name="line.66"></a>
+<span class="sourceLineNo">067</span>     * score.compare("Apache Software Foundation", "asf", Locale.ENGLISH) = 3<a name="line.67"></a>
+<span class="sourceLineNo">068</span>     * &lt;/pre&gt;<a name="line.68"></a>
+<span class="sourceLineNo">069</span>     *<a name="line.69"></a>
+<span class="sourceLineNo">070</span>     * @param term a full term that should be matched against, must not be null<a name="line.70"></a>
+<span class="sourceLineNo">071</span>     * @param query the query that will be matched against a term, must not be<a name="line.71"></a>
+<span class="sourceLineNo">072</span>     *            null<a name="line.72"></a>
+<span class="sourceLineNo">073</span>     * @param locale This string matching logic is case insensitive. A locale is<a name="line.73"></a>
+<span class="sourceLineNo">074</span>     *            necessary to normalize both Strings to lower case.<a name="line.74"></a>
+<span class="sourceLineNo">075</span>     * @return result score<a name="line.75"></a>
+<span class="sourceLineNo">076</span>     * @throws IllegalArgumentException if either String input {@code null} or<a name="line.76"></a>
+<span class="sourceLineNo">077</span>     *             Locale input {@code null}<a name="line.77"></a>
+<span class="sourceLineNo">078</span>     */<a name="line.78"></a>
+<span class="sourceLineNo">079</span>    public Integer compare(CharSequence term, CharSequence query, Locale locale) {<a name="line.79"></a>
+<span class="sourceLineNo">080</span>        if (term == null || query == null) {<a name="line.80"></a>
+<span class="sourceLineNo">081</span>            throw new IllegalArgumentException("Strings must not be null");<a name="line.81"></a>
+<span class="sourceLineNo">082</span>        } else if (locale == null) {<a name="line.82"></a>
+<span class="sourceLineNo">083</span>            throw new IllegalArgumentException("Locale must not be null");<a name="line.83"></a>
+<span class="sourceLineNo">084</span>        }<a name="line.84"></a>
+<span class="sourceLineNo">085</span><a name="line.85"></a>
+<span class="sourceLineNo">086</span>        // fuzzy logic is case insensitive. We normalize the Strings to lower<a name="line.86"></a>
+<span class="sourceLineNo">087</span>        // case right from the start. Turning characters to lower case<a name="line.87"></a>
+<span class="sourceLineNo">088</span>        // via Character.toLowerCase(char) is unfortunately insufficient<a name="line.88"></a>
+<span class="sourceLineNo">089</span>        // as it does not accept a locale.<a name="line.89"></a>
+<span class="sourceLineNo">090</span>        final String termLowerCase = term.toString().toLowerCase(locale);<a name="line.90"></a>
+<span class="sourceLineNo">091</span>        final String queryLowerCase = query.toString().toLowerCase(locale);<a name="line.91"></a>
+<span class="sourceLineNo">092</span><a name="line.92"></a>
+<span class="sourceLineNo">093</span>        // the resulting score<a name="line.93"></a>
+<span class="sourceLineNo">094</span>        int score = 0;<a name="line.94"></a>
+<span class="sourceLineNo">095</span><a name="line.95"></a>
+<span class="sourceLineNo">096</span>        // the position in the term which will be scanned next for potential<a name="line.96"></a>
+<span class="sourceLineNo">097</span>        // query character matches<a name="line.97"></a>
+<span class="sourceLineNo">098</span>        int termIndex = 0;<a name="line.98"></a>
+<span class="sourceLineNo">099</span><a name="line.99"></a>
+<span class="sourceLineNo">100</span>        // index of the previously matched character in the term<a name="line.100"></a>
+<span class="sourceLineNo">101</span>        int previousMatchingCharacterIndex = Integer.MIN_VALUE;<a name="line.101"></a>
+<span class="sourceLineNo">102</span><a name="line.102"></a>
+<span class="sourceLineNo">103</span>        for (int queryIndex = 0; queryIndex &lt; queryLowerCase.length(); queryIndex++) {<a name="line.103"></a>
+<span class="sourceLineNo">104</span>            final char queryChar = queryLowerCase.charAt(queryIndex);<a name="line.104"></a>
+<span class="sourceLineNo">105</span><a name="line.105"></a>
+<span class="sourceLineNo">106</span>            boolean termCharacterMatchFound = false;<a name="line.106"></a>
+<span class="sourceLineNo">107</span>            for (; termIndex &lt; termLowerCase.length()<a name="line.107"></a>
+<span class="sourceLineNo">108</span>                    &amp;&amp; !termCharacterMatchFound; termIndex++) {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>                final char termChar = termLowerCase.charAt(termIndex);<a name="line.109"></a>
+<span class="sourceLineNo">110</span><a name="line.110"></a>
+<span class="sourceLineNo">111</span>                if (queryChar == termChar) {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>                    // simple character matches result in one point<a name="line.112"></a>
+<span class="sourceLineNo">113</span>                    score++;<a name="line.113"></a>
+<span class="sourceLineNo">114</span><a name="line.114"></a>
+<span class="sourceLineNo">115</span>                    // subsequent character matches further improve<a name="line.115"></a>
+<span class="sourceLineNo">116</span>                    // the score.<a name="line.116"></a>
+<span class="sourceLineNo">117</span>                    if (previousMatchingCharacterIndex + 1 == termIndex) {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>                        score += 2;<a name="line.118"></a>
+<span class="sourceLineNo">119</span>                    }<a name="line.119"></a>
+<span class="sourceLineNo">120</span><a name="line.120"></a>
+<span class="sourceLineNo">121</span>                    previousMatchingCharacterIndex = termIndex;<a name="line.121"></a>
+<span class="sourceLineNo">122</span><a name="line.122"></a>
+<span class="sourceLineNo">123</span>                    // we can leave the nested loop. Every character in the<a name="line.123"></a>
+<span class="sourceLineNo">124</span>                    // query can match at most one character in the term.<a name="line.124"></a>
+<span class="sourceLineNo">125</span>                    termCharacterMatchFound = true;<a name="line.125"></a>
+<span class="sourceLineNo">126</span>                }<a name="line.126"></a>
+<span class="sourceLineNo">127</span>            }<a name="line.127"></a>
+<span class="sourceLineNo">128</span>        }<a name="line.128"></a>
+<span class="sourceLineNo">129</span><a name="line.129"></a>
+<span class="sourceLineNo">130</span>        return score;<a name="line.130"></a>
+<span class="sourceLineNo">131</span>    }<a name="line.131"></a>
+<span class="sourceLineNo">132</span><a name="line.132"></a>
+<span class="sourceLineNo">133</span>}<a name="line.133"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>
\ No newline at end of file

Propchange: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/FuzzyScore.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/HammingDistance.html
==============================================================================
--- websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/HammingDistance.html (added)
+++ websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/HammingDistance.html Sun Mar  1 12:14:29 2015
@@ -0,0 +1,148 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="de">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a>
+<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<span class="sourceLineNo">003</span> * contributor license agreements.  See the NOTICE file distributed with<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * the License.  You may obtain a copy of the License at<a name="line.7"></a>
+<span class="sourceLineNo">008</span> *<a name="line.8"></a>
+<span class="sourceLineNo">009</span> *      http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<span class="sourceLineNo">010</span> *<a name="line.10"></a>
+<span class="sourceLineNo">011</span> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<span class="sourceLineNo">012</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<span class="sourceLineNo">013</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * limitations under the License.<a name="line.15"></a>
+<span class="sourceLineNo">016</span> */<a name="line.16"></a>
+<span class="sourceLineNo">017</span>package org.apache.commons.text.similarity;<a name="line.17"></a>
+<span class="sourceLineNo">018</span><a name="line.18"></a>
+<span class="sourceLineNo">019</span>/**<a name="line.19"></a>
+<span class="sourceLineNo">020</span> * The hamming distance between two strings of equal length is the number of<a name="line.20"></a>
+<span class="sourceLineNo">021</span> * positions at which the corresponding symbols are different.<a name="line.21"></a>
+<span class="sourceLineNo">022</span> *<a name="line.22"></a>
+<span class="sourceLineNo">023</span> * &lt;p&gt;<a name="line.23"></a>
+<span class="sourceLineNo">024</span> * For further explanation about the Hamming Distance, take a look at its<a name="line.24"></a>
+<span class="sourceLineNo">025</span> * Wikipedia page at http://en.wikipedia.org/wiki/Hamming_distance.<a name="line.25"></a>
+<span class="sourceLineNo">026</span> * &lt;/p&gt;<a name="line.26"></a>
+<span class="sourceLineNo">027</span> */<a name="line.27"></a>
+<span class="sourceLineNo">028</span>public class HammingDistance implements StringMetric&lt;Integer&gt; {<a name="line.28"></a>
+<span class="sourceLineNo">029</span><a name="line.29"></a>
+<span class="sourceLineNo">030</span>    /**<a name="line.30"></a>
+<span class="sourceLineNo">031</span>     * Find the Hamming Distance between two strings with the same<a name="line.31"></a>
+<span class="sourceLineNo">032</span>     * length.<a name="line.32"></a>
+<span class="sourceLineNo">033</span>     *<a name="line.33"></a>
+<span class="sourceLineNo">034</span>     * &lt;p&gt;The distance starts with zero, and for each occurrence of a<a name="line.34"></a>
+<span class="sourceLineNo">035</span>     * different character in either String, it increments the distance<a name="line.35"></a>
+<span class="sourceLineNo">036</span>     * by 1, and finally return its value.&lt;/p&gt;<a name="line.36"></a>
+<span class="sourceLineNo">037</span>     *<a name="line.37"></a>
+<span class="sourceLineNo">038</span>     * &lt;p&gt;Since the Hamming Distance can only be calculated between strings of equal length, input of different lengths<a name="line.38"></a>
+<span class="sourceLineNo">039</span>     * will throw IllegalArgumentException&lt;/p&gt;<a name="line.39"></a>
+<span class="sourceLineNo">040</span>     *<a name="line.40"></a>
+<span class="sourceLineNo">041</span>     * &lt;pre&gt;<a name="line.41"></a>
+<span class="sourceLineNo">042</span>     * distance.compare("", "")               = 0<a name="line.42"></a>
+<span class="sourceLineNo">043</span>     * distance.compare("pappa", "pappa")     = 0<a name="line.43"></a>
+<span class="sourceLineNo">044</span>     * distance.compare("1011101", "1011111") = 1<a name="line.44"></a>
+<span class="sourceLineNo">045</span>     * distance.compare("ATCG", "ACCC")       = 2<a name="line.45"></a>
+<span class="sourceLineNo">046</span>     * distance.compare("karolin", "kerstin"  = 3<a name="line.46"></a>
+<span class="sourceLineNo">047</span>     * &lt;/pre&gt;<a name="line.47"></a>
+<span class="sourceLineNo">048</span>     *<a name="line.48"></a>
+<span class="sourceLineNo">049</span>     * @param left the first CharSequence, must not be null<a name="line.49"></a>
+<span class="sourceLineNo">050</span>     * @param right the second CharSequence, must not be null<a name="line.50"></a>
+<span class="sourceLineNo">051</span>     * @return distance<a name="line.51"></a>
+<span class="sourceLineNo">052</span>     * @throws IllegalArgumentException if either input is {@code null} or<a name="line.52"></a>
+<span class="sourceLineNo">053</span>     *             if they do not have the same length<a name="line.53"></a>
+<span class="sourceLineNo">054</span>     */<a name="line.54"></a>
+<span class="sourceLineNo">055</span>    @Override<a name="line.55"></a>
+<span class="sourceLineNo">056</span>    public Integer compare(CharSequence left, CharSequence right) {<a name="line.56"></a>
+<span class="sourceLineNo">057</span>        if (left == null || right == null) {<a name="line.57"></a>
+<span class="sourceLineNo">058</span>            throw new IllegalArgumentException("Strings must not be null");<a name="line.58"></a>
+<span class="sourceLineNo">059</span>        }<a name="line.59"></a>
+<span class="sourceLineNo">060</span><a name="line.60"></a>
+<span class="sourceLineNo">061</span>        if (left.length() != right.length()) {<a name="line.61"></a>
+<span class="sourceLineNo">062</span>            throw new IllegalArgumentException("Strings must have the same length");<a name="line.62"></a>
+<span class="sourceLineNo">063</span>        }<a name="line.63"></a>
+<span class="sourceLineNo">064</span><a name="line.64"></a>
+<span class="sourceLineNo">065</span>        int distance = 0;<a name="line.65"></a>
+<span class="sourceLineNo">066</span><a name="line.66"></a>
+<span class="sourceLineNo">067</span>        for (int i = 0; i &lt; left.length(); i++) {<a name="line.67"></a>
+<span class="sourceLineNo">068</span>            if (left.charAt(i) != right.charAt(i)) {<a name="line.68"></a>
+<span class="sourceLineNo">069</span>                distance++;<a name="line.69"></a>
+<span class="sourceLineNo">070</span>            }<a name="line.70"></a>
+<span class="sourceLineNo">071</span>        }<a name="line.71"></a>
+<span class="sourceLineNo">072</span><a name="line.72"></a>
+<span class="sourceLineNo">073</span>        return distance;<a name="line.73"></a>
+<span class="sourceLineNo">074</span>    }<a name="line.74"></a>
+<span class="sourceLineNo">075</span><a name="line.75"></a>
+<span class="sourceLineNo">076</span>}<a name="line.76"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</pre>
+</div>
+</body>
+</html>
\ No newline at end of file

Propchange: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/similarity/HammingDistance.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message