Return-Path: X-Original-To: apmail-commons-notifications-archive@minotaur.apache.org Delivered-To: apmail-commons-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C057717C31 for ; Sun, 1 Mar 2015 12:14:35 +0000 (UTC) Received: (qmail 85960 invoked by uid 500); 1 Mar 2015 12:14:35 -0000 Delivered-To: apmail-commons-notifications-archive@commons.apache.org Received: (qmail 85922 invoked by uid 500); 1 Mar 2015 12:14:35 -0000 Mailing-List: contact notifications-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list notifications@commons.apache.org Received: (qmail 85622 invoked by uid 99); 1 Mar 2015 12:14:35 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Mar 2015 12:14:35 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 4E3B3AC082C for ; Sun, 1 Mar 2015 12:14:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r941823 [19/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 -0000 To: notifications@commons.apache.org From: britter@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150301121435.4E3B3AC082C@hades.apache.org> Added: websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/diff/package-summary.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/diff/package-summary.html (added) +++ websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/diff/package-summary.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,114 @@ + + + + + + Apache Commons Text 0.1-SNAPSHOT Reference Package org.apache.commons.text.diff + + + +
+ +
+
+ +
+ +

Package org.apache.commons.text.diff

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Class Summary
+ CommandVisitor +
+ DeleteCommand +
+ EditCommand +
+ EditScript +
+ InsertCommand +
+ KeepCommand +
+ ReplacementsFinder +
+ ReplacementsHandler +
+ Snake +
+ StringsComparator +
+ +
+ +
+
+ +
+
+ + + \ No newline at end of file Propchange: websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/diff/package-summary.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/FuzzyScore.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/FuzzyScore.html (added) +++ websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/FuzzyScore.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,146 @@ + + + +FuzzyScore xref + + + +
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one or more
+3    * contributor license agreements.  See the NOTICE file distributed with
+4    * this work for additional information regarding copyright ownership.
+5    * The ASF licenses this file to You under the Apache License, Version 2.0
+6    * (the "License"); you may not use this file except in compliance with
+7    * the License.  You may obtain a copy of the License at
+8    *
+9    *      http://www.apache.org/licenses/LICENSE-2.0
+10   *
+11   * Unless required by applicable law or agreed to in writing, software
+12   * distributed under the License is distributed on an "AS IS" BASIS,
+13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+14   * See the License for the specific language governing permissions and
+15   * limitations under the License.
+16   */
+17  package org.apache.commons.text.similarity;
+18  
+19  import java.util.Locale;
+20  
+21  /**
+22   * A matching algorithm that is similar to the searching algorithms implemented in editors such
+23   * as Sublime Text, TextMate, Atom and others.
+24   *
+25   * <p>
+26   * One point is given for every matched character. Subsequent matches yield two bonus points. A higher score
+27   * indicates a higher similarity.
+28   * </p>
+29   *
+30   * <p>
+31   * This code has been adapted from Apache Commons Lang 3.3.
+32   * </p>
+33   */
+34  public class FuzzyScore implements StringMetric<Integer> {
+35  
+36      /**
+37       * <p>
+38       * Find the Fuzzy Score which indicates the similarity score between two
+39       * Strings. This method uses the default locale.
+40       * </p>
+41       *
+42       * @param term a full term that should be matched against, must not be null
+43       * @param query the query that will be matched against a term, must not be
+44       *            null
+45       * @return result score
+46       * @throws IllegalArgumentException if either String input {@code null}
+47       */
+48      @Override
+49      public Integer compare(CharSequence term, CharSequence query) {
+50          return compare(term, query, Locale.getDefault());
+51      }
+52  
+53      /**
+54       * <p>
+55       * Find the Fuzzy Score which indicates the similarity score between two
+56       * Strings.
+57       * </p>
+58       *
+59       * <pre>
+60       * score.compare(null, null, null)                                    = IllegalArgumentException
+61       * score.compare("", "", Locale.ENGLISH)                              = 0
+62       * score.compare("Workshop", "b", Locale.ENGLISH)                     = 0
+63       * score.compare("Room", "o", Locale.ENGLISH)                         = 1
+64       * score.compare("Workshop", "w", Locale.ENGLISH)                     = 1
+65       * score.compare("Workshop", "ws", Locale.ENGLISH)                    = 2
+66       * score.compare("Workshop", "wo", Locale.ENGLISH)                    = 4
+67       * score.compare("Apache Software Foundation", "asf", Locale.ENGLISH) = 3
+68       * </pre>
+69       *
+70       * @param term a full term that should be matched against, must not be null
+71       * @param query the query that will be matched against a term, must not be
+72       *            null
+73       * @param locale This string matching logic is case insensitive. A locale is
+74       *            necessary to normalize both Strings to lower case.
+75       * @return result score
+76       * @throws IllegalArgumentException if either String input {@code null} or
+77       *             Locale input {@code null}
+78       */
+79      public Integer compare(CharSequence term, CharSequence query, Locale locale) {
+80          if (term == null || query == null) {
+81              throw new IllegalArgumentException("Strings must not be null");
+82          } else if (locale == null) {
+83              throw new IllegalArgumentException("Locale must not be null");
+84          }
+85  
+86          // fuzzy logic is case insensitive. We normalize the Strings to lower
+87          // case right from the start. Turning characters to lower case
+88          // via Character.toLowerCase(char) is unfortunately insufficient
+89          // as it does not accept a locale.
+90          final String termLowerCase = term.toString().toLowerCase(locale);
+91          final String queryLowerCase = query.toString().toLowerCase(locale);
+92  
+93          // the resulting score
+94          int score = 0;
+95  
+96          // the position in the term which will be scanned next for potential
+97          // query character matches
+98          int termIndex = 0;
+99  
+100         // index of the previously matched character in the term
+101         int previousMatchingCharacterIndex = Integer.MIN_VALUE;
+102 
+103         for (int queryIndex = 0; queryIndex < queryLowerCase.length(); queryIndex++) {
+104             final char queryChar = queryLowerCase.charAt(queryIndex);
+105 
+106             boolean termCharacterMatchFound = false;
+107             for (; termIndex < termLowerCase.length()
+108                     && !termCharacterMatchFound; termIndex++) {
+109                 final char termChar = termLowerCase.charAt(termIndex);
+110 
+111                 if (queryChar == termChar) {
+112                     // simple character matches result in one point
+113                     score++;
+114 
+115                     // subsequent character matches further improve
+116                     // the score.
+117                     if (previousMatchingCharacterIndex + 1 == termIndex) {
+118                         score += 2;
+119                     }
+120 
+121                     previousMatchingCharacterIndex = termIndex;
+122 
+123                     // we can leave the nested loop. Every character in the
+124                     // query can match at most one character in the term.
+125                     termCharacterMatchFound = true;
+126                 }
+127             }
+128         }
+129 
+130         return score;
+131     }
+132 
+133 }
+
+
+ + + \ No newline at end of file Propchange: websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/FuzzyScore.html ------------------------------------------------------------------------------ svn:eol-style = native Added: websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/HammingDistance.html ============================================================================== --- websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/HammingDistance.html (added) +++ websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/HammingDistance.html Sun Mar 1 12:14:29 2015 @@ -0,0 +1,89 @@ + + + +HammingDistance xref + + + +
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one or more
+3    * contributor license agreements.  See the NOTICE file distributed with
+4    * this work for additional information regarding copyright ownership.
+5    * The ASF licenses this file to You under the Apache License, Version 2.0
+6    * (the "License"); you may not use this file except in compliance with
+7    * the License.  You may obtain a copy of the License at
+8    *
+9    *      http://www.apache.org/licenses/LICENSE-2.0
+10   *
+11   * Unless required by applicable law or agreed to in writing, software
+12   * distributed under the License is distributed on an "AS IS" BASIS,
+13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+14   * See the License for the specific language governing permissions and
+15   * limitations under the License.
+16   */
+17  package org.apache.commons.text.similarity;
+18  
+19  /**
+20   * The hamming distance between two strings of equal length is the number of
+21   * positions at which the corresponding symbols are different.
+22   *
+23   * <p>
+24   * For further explanation about the Hamming Distance, take a look at its
+25   * Wikipedia page at http://en.wikipedia.org/wiki/Hamming_distance.
+26   * </p>
+27   */
+28  public class HammingDistance implements StringMetric<Integer> {
+29  
+30      /**
+31       * Find the Hamming Distance between two strings with the same
+32       * length.
+33       *
+34       * <p>The distance starts with zero, and for each occurrence of a
+35       * different character in either String, it increments the distance
+36       * by 1, and finally return its value.</p>
+37       *
+38       * <p>Since the Hamming Distance can only be calculated between strings of equal length, input of different lengths
+39       * will throw IllegalArgumentException</p>
+40       *
+41       * <pre>
+42       * distance.compare("", "")               = 0
+43       * distance.compare("pappa", "pappa")     = 0
+44       * distance.compare("1011101", "1011111") = 1
+45       * distance.compare("ATCG", "ACCC")       = 2
+46       * distance.compare("karolin", "kerstin"  = 3
+47       * </pre>
+48       *
+49       * @param left the first CharSequence, must not be null
+50       * @param right the second CharSequence, must not be null
+51       * @return distance
+52       * @throws IllegalArgumentException if either input is {@code null} or
+53       *             if they do not have the same length
+54       */
+55      @Override
+56      public Integer compare(CharSequence left, CharSequence right) {
+57          if (left == null || right == null) {
+58              throw new IllegalArgumentException("Strings must not be null");
+59          }
+60  
+61          if (left.length() != right.length()) {
+62              throw new IllegalArgumentException("Strings must have the same length");
+63          }
+64  
+65          int distance = 0;
+66  
+67          for (int i = 0; i < left.length(); i++) {
+68              if (left.charAt(i) != right.charAt(i)) {
+69                  distance++;
+70              }
+71          }
+72  
+73          return distance;
+74      }
+75  
+76  }
+
+
+ + + \ No newline at end of file Propchange: websites/production/commons/content/sandbox/commons-text/xref/org/apache/commons/text/similarity/HammingDistance.html ------------------------------------------------------------------------------ svn:eol-style = native