java main program

Ads

 
 

Share on Google+Share on Google+

kaladevi
java main program
0 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners

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;  

 }

}

Ads
View Answers
Ads









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
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
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
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
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
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
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
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
java program for
java program for   java program for printing documents,images and cards
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  A Java Program that print the data on the printer but buttons not to be printed
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 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
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
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
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
What is Public static void main
the rules otherwise your program will not run. Signature of main method in java...[]) //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 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 program to print 1234 567 89 10
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
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
java program
java program  how to write an addition program in java without using arithematic operator

Ads

 
Advertisement null

Ads