File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
src/info/debatty/java/stringsimilarity Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ public static void main(String[] args) {
1717 NGram twogram = new NGram (2 );
1818
1919 System .out .println (twogram .distance ("ABCD" , "ABTUIO" ));
20+
21+ String s1 = " Buy And Download Cheap OemSoftwares! Adobe CreativeSuite 5 Master Collection from cheap 4zp" ;
22+ String s2 = " Buy And Download Cheap OemSoftwares! Adobe CreativeSuite 5 Master Collection from cheap d1x" ;
23+ NGram ngram = new NGram (4 );
24+ System .out .println (ngram .similarity (s1 , s2 ));
2025 }
2126
2227 private final int n ;
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ public double similarity(String s1, String s2) {
3535
3636 @ Override
3737 public double distance (String s1 , String s2 ) {
38+ if (s1 .length () < n || s2 .length () < n ) {
39+ return 0 ;
40+ }
41+
3842 KShingling sh = new KShingling (n );
3943 sh .parse (s1 );
4044 sh .parse (s2 );
You can’t perform that action at this time.
0 commit comments