Skip to content

Commit

Permalink
fix for java 8 and more recent
Browse files Browse the repository at this point in the history
  • Loading branch information
tdebatty committed May 12, 2020
1 parent aa9ecf2 commit 462a686
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ A library implementing different string similarity and distance measures. A doze


## Download

Using maven:

```
<dependency>
<groupId>info.debatty</groupId>
Expand All @@ -40,6 +42,8 @@ Using maven:

Or check the [releases](https://github.com/tdebatty/java-string-similarity/releases).

This library requires Java 8 or more recent.

## Overview

The main characteristics of each implemented algorithm are presented below. The "cost" column gives an estimation of the computational cost to compute the similarity between two strings of length m and n respectively.
Expand Down
7 changes: 5 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -112,8 +115,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>6</source>
<target>1.6</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/info/debatty/java/stringsimilarity/Cosine.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public Cosine() {
* @return The cosine similarity in the range [0, 1]
* @throws NullPointerException if s1 or s2 is null.
*/
@Override
public final double similarity(final String s1, final String s2) {
if (s1 == null) {
throw new NullPointerException("s1 must not be null");
Expand Down Expand Up @@ -142,12 +143,14 @@ private static double dotProduct(
* @return 1.0 - the cosine similarity in the range [0, 1]
* @throws NullPointerException if s1 or s2 is null.
*/
@Override
public final double distance(final String s1, final String s2) {
return 1.0 - similarity(s1, s2);
}

/**
* {@inheritDoc}
* Compute similarity between precomputed profiles.
*
* @param profile1
* @param profile2
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import info.debatty.java.stringsimilarity.interfaces.NormalizedStringDistance;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;

import net.jcip.annotations.Immutable;

Expand Down

0 comments on commit 462a686

Please sign in to comment.