public class MostFrequentKChars extends Object
| Constructor and Description |
|---|
MostFrequentKChars() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getMostFreqKSimilarity(int[] hash1,
int[] hash2)
Calculate the similarity of the two hashes.
|
static int |
getMostFreqKSimilarity(String hash1,
String hash2)
Calculate the similarity of the two hashes.
|
static String |
getMostFrequentKHash(String string,
int k)
Get the hash for an input string with at most K most frequent characters.
|
static double |
mostFreqKSDF(String inputStr1,
String inputStr2,
int K)
Most freq ksdf.
|
static int |
mostFreqKSDF(String inputStr1,
String inputStr2,
int K,
int maxDistance)
Wrapper function.
|
static String |
toHashString(int[] h1)
Encode a hash array to String.
|
public static String getMostFrequentKHash(String string, int k)
String function MostFreqKHashing (String inputString, int K)
def string outputString
for each distinct character
count occurrence of each character
for i := 0 to K
char c = next most freq ith character (if two chars have same frequency then get the first occurrence in inputString)
int count = number of occurrence of the character
append to outputString, c and count
end for
return outputString
string - the stringk - the kpublic static int getMostFreqKSimilarity(String hash1, String hash2)
hash1 - the hash1hash2 - the hash2public static int getMostFreqKSimilarity(int[] hash1,
int[] hash2)
int function MostFreqKSimilarity (String inputStr1, String inputStr2, int limit)
def int similarity
for each c = next character from inputStr1
lookup c in inputStr2
if c is null
continue
// similarity += frequency of c in inputStr1
similarity += frequency of c in inputStr1 + frequency of c in inputStr2
// return limit - similarity
return similarity
hash1 - the hash1hash2 - the hash2public static int mostFreqKSDF(String inputStr1, String inputStr2, int K, int maxDistance)
int function MostFreqKSDF (string inputStr1, string inputStr2, int K, int maxDistance)
return maxDistance - MostFreqKSimilarity(MostFreqKHashing(inputStr1,K), MostFreqKHashing(inputStr2,K))
inputStr1 - the input str1inputStr2 - the input str2K - the kmaxDistance - the max distancepublic static double mostFreqKSDF(String inputStr1, String inputStr2, int K)
inputStr1 - the input str1inputStr2 - the input str2K - the kpublic static String toHashString(int[] h1)
h1 - hash array as generatedCopyright © 2017 Global Crop Diversity Trust. All rights reserved.