Home Answers Viewqa Java-Beginners java main program

 
 


kaladevi
java main program
0 Answer(s)      10 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;  

 }

}

View Answers









Related Pages:
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
MAin error
MAin error  Error while running hello program in another dir rather in bin. path is already set. java -version jdk1.6.0_24 no error while compilation but @ d tym of runnin error in main class is generated Exception in thread
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
Can a main method be overloaded?
Can a main method be overloaded?   Hi, Can a main method be overloaded? thanks,   Hi, Yes, In Java program we could having multiple number of main() methods with different Signature and implementation in the class
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
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
What is the return type of the main method?
type of the main method? thanks   Hi, In the java programming the Main() method doesn't return anything hence declared void. In Java, you need... appear in a real Java program. For more visit http://www.roseindia.net/java/java
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 Thread and Child Thread
There are two types of threads in Java Progarm In Java there are Main and Child Threads used in Programming. Main thread is automatically created when program runs. Child Thread gets created by the main thread . Java Main
main method
main method  What is the argument type of a program's main() method
main method
main method  Why is the java main method static
main() method
main() method  Can we define two main() methods having same parameter but with different return type in a program
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
main method
can not make multiple main with in the same class program fails to compile. Compiler gives error that the main method is already defined in the class...main method  hello, Can I make multiple main methods in the same
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 
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
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
What is the first argument of the String array in main() method?
. This article gives your a very easy java program which illustrates about the string...What is the first argument of the String array in main() method?  Hi, What is the first argument of the String array in main() method? Thanks
Understanding public static void main function
function in Java programming language. In this section we will learn about main function. The main method is the first method, which the Java Virtual Machine... method is the entry point in the Java program and java program can't run without
Static keyword in public static void main
://www.roseindia.net/java/learn-java-in-a-day/create-first-program.shtml Explanation... void main(String args[]) { meth(42); } } In the above code, as soon... is initialized to a * 4 or 12. Then main( ) is called, which calls meth( ), passing 42
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
exception in thread main java.lang.unsupportedclassversionerror unsupported major.minor version 50.0 - Java Beginners
!"); } } for example: javac xxx.java-->comping java xxxx:error :exception in thread main... for compilation and execution of java program. Therefore set the path of one java version...exception in thread main java.lang.unsupportedclassversionerror unsupported
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
Why we should use string args[] in main method in java?
Why we should use string args[] in main method in java?  we use only string in the main method not any other one.. specify the reason... and tell me each and every meaning of public static void main(String args[])...   
.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
Programming - Count Vowels - main
Java: Programming - Count Vowels - main Problem Write a program that reads a string and displays the number of vowels in it. This main program program is primarily responsible for handling the input-output issues, and it will call
Main job of cpu
Main job of cpu  What is the Main Job of CPU?   The CPU perform two main task .. 1. It carry out program instructions and also 2. Process the data and information
What is the arguement of main method?
What is the arguement of main method?  hi, What is the arguement of main method? thanks,   Hi, For main() method accepts only an array of String object as arguement. For moe details on http://www.roseindia.net/java
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
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
Exception in thread "main" java.lang.ClassCastException
Exception in thread "main" java.lang.ClassCastException  I am trying.... Anyone help me please. Java Code: import java.sql.*; import org.postgis....){e.printStackTrace();} } } public static void main(String[] argv) { try { Class driver
Exception in thread "main" java.lang.ClassCastException
Exception in thread "main" java.lang.ClassCastException  I am trying.... Anyone help me please. Java Code: import java.sql.; import org.postgis....){e.printStackTrace();} } } public static void main(String[] argv) { try { Class driver
What is the main feature of Hibernate3?
What is the main feature of Hibernate3?  What is the main feature... or local Java API, including a second-level cache browser. · Eclipse support... timings as it supports inheritance, polymorphism, composition and the Java
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
create main page
create main page  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@page import="java.sql.*"%> <%@page import="java.util.*"%> <%@ page session="true
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  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