Skip to content

Commit bd49707

Browse files
committed
Example file edited to show algorithm names
1 parent c3fc727 commit bd49707

File tree

1 file changed

+15
-1
lines changed
  • src/main/java/info/debatty/java/stringsimilarity/examples

1 file changed

+15
-1
lines changed

src/main/java/info/debatty/java/stringsimilarity/examples/Examples.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ public class Examples {
5050
public static void main(String[] args) {
5151
// Levenshtein
5252
// ===========
53+
System.out.println("\nLevenshtein");
5354
Levenshtein levenshtein = new Levenshtein();
5455
System.out.println(levenshtein.distance("My string", "My $tring"));
5556
System.out.println(levenshtein.distance("My string", "M string2"));
5657
System.out.println(levenshtein.distance("My string", "My $tring"));
5758

5859
// Jaccard index
5960
// =============
61+
System.out.println("\nJaccard");
6062
Jaccard j2 = new Jaccard(2);
6163
// AB BC CD DE DF
6264
// 1 1 1 1 0
@@ -66,6 +68,7 @@ public static void main(String[] args) {
6668

6769
// Jaro-Winkler
6870
// ============
71+
System.out.println("\nJaro-Winkler");
6972
JaroWinkler jw = new JaroWinkler();
7073

7174
// substitution of s and t : 0.9740740656852722
@@ -76,6 +79,7 @@ public static void main(String[] args) {
7679

7780
// Cosine
7881
// ======
82+
System.out.println("\nCosine");
7983
Cosine cos = new Cosine(3);
8084

8185
// ABC BCE
@@ -94,6 +98,7 @@ public static void main(String[] args) {
9498

9599
// Damerau
96100
// =======
101+
System.out.println("\nDamerau");
97102
Damerau damerau = new Damerau();
98103

99104
// 1 substitution
@@ -111,8 +116,10 @@ public static void main(String[] args) {
111116
// All different
112117
System.out.println(damerau.distance("ABCDEF", "POIU"));
113118

114-
// OptimalStringAlignment
119+
120+
// Optimal String Alignment
115121
// =======
122+
System.out.println("\nOptimal String Alignment");
116123
OptimalStringAlignment osa = new OptimalStringAlignment();
117124

118125
// 1 substitution
@@ -132,6 +139,7 @@ public static void main(String[] args) {
132139

133140
// Longest Common Subsequence
134141
// ==========================
142+
System.out.println("\nLongest Common Subsequence");
135143
LongestCommonSubsequence lcs = new LongestCommonSubsequence();
136144

137145
// Will produce 4.0
@@ -143,6 +151,7 @@ public static void main(String[] args) {
143151
// NGram
144152
// =====
145153
// produces 0.416666
154+
System.out.println("\nNGram");
146155
NGram twogram = new NGram(2);
147156
System.out.println(twogram.distance("ABCD", "ABTUIO"));
148157

@@ -154,6 +163,7 @@ public static void main(String[] args) {
154163

155164
// Normalized Levenshtein
156165
// ======================
166+
System.out.println("\nNormalized Levenshtein");
157167
NormalizedLevenshtein l = new NormalizedLevenshtein();
158168

159169
System.out.println(l.distance("My string", "My $tring"));
@@ -162,6 +172,7 @@ public static void main(String[] args) {
162172

163173
// QGram
164174
// =====
175+
System.out.println("\nQGram");
165176
QGram dig = new QGram(2);
166177

167178
// AB BC CD CE
@@ -178,6 +189,7 @@ public static void main(String[] args) {
178189

179190
// Sorensen-Dice
180191
// =============
192+
System.out.println("\nSorensen-Dice");
181193
SorensenDice sd = new SorensenDice(2);
182194

183195
// AB BC CD DE DF FG
@@ -188,6 +200,7 @@ public static void main(String[] args) {
188200

189201
// Weighted Levenshtein
190202
// ====================
203+
System.out.println("\nWeighted Levenshtein");
191204
WeightedLevenshtein wl = new WeightedLevenshtein(
192205
new CharacterSubstitutionInterface() {
193206
public double cost(char c1, char c2) {
@@ -208,6 +221,7 @@ public double cost(char c1, char c2) {
208221
System.out.println(wl.distance("String1", "Srring2"));
209222

210223
// K-Shingling
224+
System.out.println("\nK-Shingling");
211225
s1 = "my string, \n my song";
212226
s2 = "another string, from a song";
213227
KShingling ks = new KShingling(4);

0 commit comments

Comments
 (0)