You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2015/04/12 13:31:09 UTC

[1/2] [text] Remove unused and empty Jaccard files and update distance method name

Repository: commons-text
Updated Branches:
  refs/heads/master 3ccdabb1e -> 376c7c4d8


Remove unused and empty Jaccard files and update distance method name


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/548a7918
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/548a7918
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/548a7918

Branch: refs/heads/master
Commit: 548a7918ef57e2591c3d6aaa9bb3e42e17fa6cbe
Parents: 3ccdabb
Author: Bruno P. Kinoshita <br...@yahoo.com.br>
Authored: Sun Apr 12 23:30:02 2015 +1200
Committer: Bruno P. Kinoshita <br...@yahoo.com.br>
Committed: Sun Apr 12 23:30:02 2015 +1200

----------------------------------------------------------------------
 .../commons/text/similarity/CosineDistance.java |  2 +-
 .../text/similarity/JaccardDistance.java        | 21 --------------------
 .../commons/text/similarity/JaccardIndex.java   | 21 --------------------
 .../text/similarity/CosineDistanceTest.java     |  8 ++++----
 4 files changed, 5 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/548a7918/src/main/java/org/apache/commons/text/similarity/CosineDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/CosineDistance.java b/src/main/java/org/apache/commons/text/similarity/CosineDistance.java
index 69cfad7..f9fcf39 100644
--- a/src/main/java/org/apache/commons/text/similarity/CosineDistance.java
+++ b/src/main/java/org/apache/commons/text/similarity/CosineDistance.java
@@ -41,7 +41,7 @@ public class CosineDistance implements StringMetric<Double> {
     private final CosineSimilarity cosineSimilarity = new CosineSimilarity();
 
     @Override
-    public Double compare(CharSequence left, CharSequence right) {
+    public Double apply(CharSequence left, CharSequence right) {
         CharSequence[] leftTokens = tokenizer.tokenize(left);
         CharSequence[] rightTokens = tokenizer.tokenize(right);
 

http://git-wip-us.apache.org/repos/asf/commons-text/blob/548a7918/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java b/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java
deleted file mode 100644
index 7237244..0000000
--- a/src/main/java/org/apache/commons/text/similarity/JaccardDistance.java
+++ /dev/null
@@ -1,21 +0,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.
- */
-package org.apache.commons.text.similarity;
-
-public class JaccardDistance {
-
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/548a7918/src/main/java/org/apache/commons/text/similarity/JaccardIndex.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/similarity/JaccardIndex.java b/src/main/java/org/apache/commons/text/similarity/JaccardIndex.java
deleted file mode 100644
index ceaa468..0000000
--- a/src/main/java/org/apache/commons/text/similarity/JaccardIndex.java
+++ /dev/null
@@ -1,21 +0,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.
- */
-package org.apache.commons.text.similarity;
-
-public class JaccardIndex {
-
-}

http://git-wip-us.apache.org/repos/asf/commons-text/blob/548a7918/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
index 0d6879a..3912913 100644
--- a/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
@@ -49,10 +49,10 @@ public class CosineDistanceTest {
      */
     @Test
     public void testCosineDistance() {
-        assertEquals(Double.valueOf(0.5d), roundValue(cosineDistance.compare("the house", "da house")));
-        assertEquals(Double.valueOf(0.0d), roundValue(cosineDistance.compare("AB", "AB")));
-        assertEquals(Double.valueOf(1.0d), roundValue(cosineDistance.compare("AB", "BA")));
-        assertEquals(Double.valueOf(0.08d), roundValue(cosineDistance.compare(
+        assertEquals(Double.valueOf(0.5d), roundValue(cosineDistance.apply("the house", "da house")));
+        assertEquals(Double.valueOf(0.0d), roundValue(cosineDistance.apply("AB", "AB")));
+        assertEquals(Double.valueOf(1.0d), roundValue(cosineDistance.apply("AB", "BA")));
+        assertEquals(Double.valueOf(0.08d), roundValue(cosineDistance.apply(
                 "the boy was from tamana shi, kumamoto ken, and the girl was from rio de janeiro, rio",
                 "the boy was from tamana shi, kumamoto, and the boy was from rio de janeiro, rio de janeiro")));
     }


[2/2] [text] Add changes to SANDBOX-490

Posted by ki...@apache.org.
Add changes to SANDBOX-490


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/376c7c4d
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/376c7c4d
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/376c7c4d

Branch: refs/heads/master
Commit: 376c7c4d86d5c0e899da67d4ed81b7dc456fdd58
Parents: 548a791
Author: Bruno P. Kinoshita <br...@yahoo.com.br>
Authored: Sun Apr 12 23:30:58 2015 +1200
Committer: Bruno P. Kinoshita <br...@yahoo.com.br>
Committed: Sun Apr 12 23:30:58 2015 +1200

----------------------------------------------------------------------
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/376c7c4d/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 553d55b..4ac588a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -22,6 +22,7 @@
   <body>
 
   <release version="1.0" date="tba" description="tba">
+    <action issue="SANDBOX-490" type="add" dev="kinow">Add Cosine Similarity and Cosine Distance</action>
     <action issue="SANDBOX-493" type="fix" dev="kinow" due-to="Jonathan Baker">Change (R) StringMetric.compare(CS left, CS right) to "apply" so that it is consistent with BiFunction.</action>
     <action issue="SANDBOX-491" type="fix" dev="kinow" due-to="Jonathan Baker">Allow extra information (e.g. Levenshtein threshold) to be stored as (final) fields in the StringMetric instance.</action>
     <action issue="SANDBOX-486" type="add" dev="kinow">Port Myers algorithm from [collections]</action>