CODE USING JSGRASP: add these classpath to worskspace first: 1.simmectrics.jar 2
ID: 3698214 • Letter: C
Question
CODE USING JSGRASP:
add these classpath to worskspace first:
1.simmectrics.jar
2.commons-codec-1.10jar
3.guava-19.jar
----------------
Write a Java class named AverageOfDistances that meets the following requirements:
1.Create an instance of the simmetrics JaroWinkler class. Use that instance to compute and print the distance between two runtime arguments. The runtime arguments are Strings that come from the args array. Label your results.
2.Create an instance of the simmetrics Levenshtein class. Use that instance to compute and print the distance between two runtime arguments.The runtime arguments are Strings that come from the args array. Label your results.
In requirements 1 and 2 you obtain one number each (a distance). Compute and print the average of those two distances. Label your results.
In requirements 1 and 2 you obtain one number each (a distance). Compute and print the maximum of those two distances. Label your results.
Here is sample output from my solution:
Trial #1
Using two strings: >>>this<<< and >>>those<<<
JaroWinkler: 0.17333335
Levenshtein: 2.0
Average: 1.0866667032241821
Maximum: 2.0
Trial #2
Using two strings: >>>java<<< and >>>programming<<<
JaroWinkler: 0.55303025
Levenshtein: 10.0
Average: 5.276515007019043
Maximum: 10.0
Start with:
Explanation / Answer
import uk.ac.shef.wit.simmetrics.similaritymetrics.*;
public class AverageOfDistances {
/**
* @param args
*/
public static void main(String[] args ) {
// TODO Auto-generated method stub
String a = "java";//args[0];
String b = "programming";//args[1];
float semJaro,semLev;
//Creare Objects
JaroWinkler jaro = new JaroWinkler();
Levenshtein lev = new Levenshtein();
//Calculete Similarities
semJaro = jaro.getSimilarity(a, b);
semLev = lev.getSimilarity(a, b);
System.out.println("JaroWinkler is ==" +semJaro);
System.out.println("Levenshtein is ==" +semLev);
System.out.println("Avrege is ==" +(semJaro+semLev)/2);
if(semJaro > semLev){
System.out.println("Maximaum is JaroWinkler ==" +semJaro);
}
else{
System.out.println("Maximaum is Levenshtein ==" +semLev);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.