java main program

java main program

how to write a main program for the following code

public class JaroWinkler

{
private String compOne;

 private String compTwo;  



 private String theMatchA = "";  

 private String theMatchB = "";  

private int mRange = -1;  



 public JaroWinkler()  

 {  

 }  



public JaroWinkler(String s1, String s2)  

 {  

    compOne = s1;  

    compTwo = s2;  

 }  



 public double getSimilarity(String s1, String s2)  

 {  

     compOne = s1;  

     compTwo = s2;  



     mRange = Math.max(compOne.length(), compTwo.length()) / 2 - 1;  



     double res = -1;  



     int m = getMatch();  

    int t = 0;  

     if (getMissMatch(compTwo,compOne) > 0)  

    {  

         t = (getMissMatch(compOne,compTwo) / getMissMatch(compTwo,compOne));  

     }  



    int l1 = compOne.length();  

    int l2 = compTwo.length();  


     double f = 0.3333;  

    double mt = (double)(m-t)/m;  

    double jw = f * ((double)m/l1+(double)m/l2+(double)mt);  

    res = jw + getCommonPrefix(compOne,compTwo) * (0.1*(1.0 - jw));  


     return res;  
}  


 private int getMatch()  

 {  



     theMatchA = "";  

    theMatchB = "";  

    int matches = 0;  

    for (int i = 0; i < compOne.length(); i++)  

     {  

      //Look backward  

         int counter = 0;  
        while(counter <= mRange && i >= 0 && counter <= i)  

         {  


            {  

                matches++;  

                theMatchA = theMatchA + compOne.charAt(i);  

                theMatchB = theMatchB + compTwo.charAt(i);  

           }  

            counter++;                  
        }  



       //Look forward  
       counter = 1;  

         while(counter <= mRange && i < compTwo.length() && counter + i < compTwo.length())  
         {  

             if (compOne.charAt(i) == compTwo.charAt(i + counter))  

             {  
                 matches++;  

                theMatchA = theMatchA + compOne.charAt(i);  
                theMatchB = theMatchB + compTwo.charAt(i);  
             }  

            counter++;  

         }  

     }  

    return matches;  

}  



 private int getMissMatch(String s1, String s2)  
{  
    int transPositions = 0;  



     for (int i = 0; i < theMatchA.length(); i++)  
     {  

         //Look Backward  

        int counter = 0;  

        while(counter <= mRange && i >= 0 && counter <= i)  
         {  

            if (theMatchA.charAt(i) == theMatchB.charAt(i - counter) && counter > 0)  

            {  

                transPositions++;  
            }  

            counter++;  

        }  



         //Look forward  

        counter = 1;  

         while(counter <= mRange && i < theMatchB.length() && (counter + i) < theMatchB.length())  

        {  

             if (theMatchA.charAt(i) == theMatchB.charAt(i + counter) && counter > 0)  

            {  

                transPositions++;  

            }  

             counter++;  

         }  
    }  

    return transPositions;  

 }  


private int getCommonPrefix(String compOne, String compTwo)  

{  

     int cp = 0;  
     for (int i = 0; i < 4; i++)  

     {  

         if (compOne.charAt(i) == compTwo.charAt(i)) cp++;  
    }  

    return cp;  

 }

}

View Answers









Related Tutorials/Questions & Answers:
java main program
java main program  how to write a main program for the following code public class JaroWinkler { private String compOne; private String compTwo; private String theMatchA = ""; private String theMatchB
write a java program for inserting a substring in to the given main string from a given position
write a java program for inserting a substring in to the given main string from a given position  write a java program for inserting a substring in to the given main string from a given position
Advertisements
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... the GUI as it is more reliable and efficent - the current program that i am working
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... the GUI as it is more reliable and efficent - the current program that i am working
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... the GUI as it is more reliable and efficent - the current program that i am working
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... the GUI as it is more reliable and efficent - the current program that i am working
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... the GUI as it is more reliable and efficent - the current program that i am working
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... the GUI as it is more reliable and efficent - the current program that i am working
java sleep in main method
java sleep in main method  Hi, How to write Java program for sleeping in the main method? I want Java program to have sleep in main method. Try to share me the code examples. Thanks
java sleep in main method
java sleep in main method  Hi, How to write Java program for sleeping in the main method? I want Java program to have sleep in main method. Try to share me the code examples. Thanks
main func - Java Beginners
main func  why do we pass array of strings in main function of java?  Hi Friend, It is used to signify that the user may opt to enter parameters to the java program at command line. Thanks
main() syntax - Java Beginners
main() syntax  Hi, I would like to know the complete structure of the main() in jdk1.5 with sample program. Regards, UsmanAli Shaik,   Hi Friend, Structure of Java program: [package declaration
Is main method compulsory in Java?
Is main method compulsory in Java?  Hi, Can we have a executable class in Java without a main method? I am going to write simple Java program..., Main method is import in Java program. This is the point from where JVM star
How to eliminate error," Could not find the main class: filecopy.FileCopy. Program will exit." ?
class: filecopy.FileCopy. Program will exit. Exception in thread "main" Java...How to eliminate error," Could not find the main class: filecopy.FileCopy. Program will exit." ?  run: java.lang.NoClassDefFoundError: filecopy
When is java main method called?
When is java main method called?  When is java main method called? Please explain the main method in Java with the help of code.   In a java class, main(..) method is the first method called by java environment when
problem with main - Java Beginners
a problem. when i compile it appears this message: java.lang.NoSuchMethodError: main Exception in thread "main" . Should i put a main in another file? And how can..., This is an applet code and applet doesn't have main method therefore compile it and run
Main function.. - Java Beginners
Main function..  Hi Friend.. public static void main(String args[]) What does it mean...public - static - void - main -(String args[]) Can u plz... return the value when it exits main(): This is the entry point for the application
Main topics in java for IT corporate working?
Main topics in java for IT corporate working?  What are the main and most important topics in java should be mastered that are usually incorporated in IT corporate world
Listing the Main Attributes in a JAR File Manifest
Listing the Main Attributes in a JAR File Manifest       Jar Manifest: Jar Manifest file is the main... the information syntax with rule and restrictions. Main Attributes in Jar file
What is Public static void main
program how to write a program in java using main method. class Helloworld...[]) //this is most classic signature of main method. Remember the varargs version of java will work in java 1.5 or later version only. Main is the entry point of 
java program
java program  write a java program which shows how to declare and use STATIC member variable inside a java class.   The static variable... void main(String args[]) { System.out.println("a = " + Static.a
java program
java program  write a java program to add or substract days in current date and time value using JAVA calender class.   Add Days import java.util.*; public class AddDaysToDate { public static void main(String
main function in java - Java Interview Questions
main function in java  1....why is function main() define as static in java? 2...drawbacks of using rmi
java program
java program  write a java program to read a file content into a string object using available and read methods of java bufferedinputstream.   Please visit the following link: http://www.roseindia.net/java/example/java
Java program
Java program  Write a Java program that demonstaress multiple inheritance.   Java does not support Multiple Inheritance but you can show... main(String arg[]) { InterfaceExample ex = new InterfaceExample
Java program
Java program  Write a Java program that takes 3 integer numbers from...;Java display maximum number using conditional operator: import java.util.*; class Greatest { public static void main(String[] args) { Scanner
JAva program
JAva program  Write a JAva program that takes various string from command line and display them in sorted order.   Java display strings in sorted order: import java.util.*; class ArraySort{ public static void main
What are the main disadvantages of Java Server Faces 2.0?
What are the main disadvantages of Java Server Faces 2.0?  What are the main disadvantages of Java Server Faces 2.0
Java program
Java program  Write a Java program that tales filename or directo;ry... of files in that directory.   Java Check File import java.io.*; import java.util.*; class CheckFile { public static void main(String[] args
java program
java program  write a program showing two threads working simultaneously upon two objects(in theater one object "cut the ticket" and second object... void main(String args[ ]) throws IOException{ MyClass obj1=new MyClass
Java program
Java program  I'm having troubles writing a program that upon entering your height in inches it changes your height to feet and inches, and then also...*; import java.util.*; class ConvertInches{ public static void main (String[] args
java program
java program  Write a Java program to accept an array list of Employee objects and search for perticular Employee based on Id Number (like ID... getAddress(){ return address; } public static void main(String
java program
java program  write a java program to get current date and time in the following format: current year is:2007 current month is:12 current date is:23... java.text.*; class DateExample { public static void main(String[] args
Java Program
Java Program  I want the answer for this question. Question: Write a program to calculate and print the sum of odd numbers and the sum of even... void main(String[]args)throws Exception{ BufferedReader br=new
main function defnition in class - Java Beginners
and will subsequently invoke all the other methods required by your program. The main method...main function defnition in class  why do we use public infront of a main function   Hi friend, The main method is similar to the main
.jar file keeps giving me " could not find the main class". Program will exit.
.jar file keeps giving me " could not find the main class". Program will exit... click on it, it gives me the message" could not find the main class. Program... netbeans's project properties clearly sets testing2.hihi as my Main class and I have
Java Program
Java Program for accepting numbers from 1 - 999 and printing them in form of words  Program for accepting numbers from 1 - 999 and printing them in form of words   Java Convert Number to Words The given code accept
java program
java program  5 5 4 5 4 3 5 4 3 2 5 4 3 2 1   Here is a code that displays following pattern: 5 5 4 5 4 3 5 4 3 2 5 4 3 2 1 class Pattern{ public static void main(String args[]){ for(int i=1;i<
java program for
java program for   java program for printing documents,images and cards
java program
java program  Hello,I have a java program that i'm working on and i'm... calculations.I am new to java so any help would be appreciated.Many thanks! import java.util.*; public class Taxcalculator{ public static void main(String
Java Program
Java Program  How to Write a Java program which read in a number... out in the standard output. The program should be started like this: java... to be read. In this example, the program should create three threads for reading
java program
java program  arithmetic operation prm using interface concepts in java   Hi Friend, Try the following code: interface Operations...{ System.out.println(b/a); } } } public class Test{ public static void main
Java Program
Java Program  Hi, please share the code to check, if two strings are permutations of each other in java.   Here is an example that prompts...; } } return true; } public static void main
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
Java Program
Java Program  A Java Program that print the data on the printer but buttons not to be printed
java program
java program  write a program to print 1234 567 89 10
java program
java program  Write a program to demonstrate the concept of various possible exceptions arising in a Java Program and the ways to handle them.  ... in Java
java program
java program  write java program for constructor,overriding,overriding,exception handling
java program
java program  how to write an addition program in java without using arithematic operator
java program
java program  write a java program to display array list and calculate the average of given array

Ads