Search This Blog

Monday, February 1, 2010

Example of the Correlation Listing Program

This is an example of a simulation program to find the verse from the Koran that had problems in user input.simulation program of this correlation calculation using the assumption that the problem user input and verse in the Koran is the extracted with other text mining method (steming, parsing, tagging).

if you have questions you can write the following comment in this blog . to dwonload this file project (Indonesian Ver) click here


/ **
*
* @ Author M Syaiful Rizal
* /
public class correlation (

public static String problem [] [] = (( "adultery", "2 "},{" women", "1"));
public static String paragraph [] [] = (( "17:32", "adultery", "2", "close", "1", "cruel", "1", "path", "1", " bad "," 1 "},{" 24:2 "," adultery "," 2 "," female "," 1 "," stripes "," 1 "," law "," 1 "),
( "5:54", "apostate", "2", "religion", "1", "the", "1"));

public static String Qur'an [] [] = (( "17:32", "and do not approach adultery adultery is actually an act of evil and a bad path"),
( "24:2", "woman taken in adultery and men who commit adultery then each one deralah each of the two hundred and control stripes"),
( "5:54", "O people who believe whoever among you who apostate from the religion so Allah will bring a people that God loves them"));
private static int pnjiterasi;
static double numerator [], the denominator [], xbar [], ybar [], pmbl, korel [];
private static int x, y;
public static void main (String [] args) (
/ / TODO code application logic here
pnjiterasi = problem.length;
xbar = new double [problem.length];
for (int i = 0; i xbar [i] = hitungxbar (i);
onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'" >)


ayat[][] = {{"17:32","zina","2","dekat","1","keji","1","jalan","1","" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">paragraph
.length];
for (int i = 0; i
paragraph.length; i + +) (
ybar [i] = hitungybar (i);
)

numerator = new double [
paragraph.length];
for (int i = 0; i <
paragraph.length; i + +) (
numerator [i] = numeratorcalculate (i);
)

denominator = new double [ayat.length];
for (int i = 0; i <
paragraph.length; i + +) (
denominator [i] = denomeratorcalculate (i);
)
korel = new double [
paragraph.length];

for (int i = 0; i <
paragraph.length; i + +) (
if (denominator [i] == 0.0)
continue;
else
korel [i] = (numerator [i] / denominator [i]);

System.out.println ( "correlation verse to" + i + "is" + korel [i]);
=(0))&&(korel[i]<=1.0)){" onmouseover="this.style.backgroundColor='#ebeff9'" onmouseout="this.style.backgroundColor='#fff'">if ((korel [i]> = (0 ))&&( korel [i] <= 1.0)) ( System.out.println (Qur'an [i] [0] + "" + Qur'an [i] [1]);
)

)

)

private static double numeratorcalculate (int i) (


/ / Calculate the numerator verse to i
/ / Calculate the value of y
tempY int [] = new int [problems.length];
for (int f = 0; f for (int g = 0; g if (problems [f] [0]. equals (sub [i] [g])) (
tempY [f] = Integer.parseInt (sub [i] [g +1]);
/ / System.out.println ( "y for the verse to" + i + "problem to" + f + "is" + tempY [f]);
)
)
)

/ / Calculate the numerator
double tempi = 0.0;
for (int f = 0; f tempi = tempi + ((Integer.parseInt (problems [f] [1])-xbar [f]) * (tempY [f]-ybar [i]));
)
/ / pmbl = tempi;
System.out.println ( "numerator verse to" + i + "is" + tempi);
return tempi;
)

private static double denumratorcalculate (int i) (
double pnyb = 0.0;
/ / calculate the denominator verse to i
/ / it to calculate the total (x-xbar) ^ 2
Double Load imgs = 0.0;
for (int f = 0; f double stack = (Integer.parseInt (problems [f] [1])-xbar [f]);
Load imgs = Load imgs + Math.pow (stack, 2);
)

/ / Number of Y
tempY int [] = new int [problem.length];
for (int f = 0; f for (int g = 0; g if (problems [f] [0]. equals (sub [i] [g])) (
tempY [f] = Integer.parseInt (sub [i] [g +1]);
/ / System.out.println ( "y for the verse to" + i + "problem to" + f + "is" + tempY [f]);
)
)
)

/ / it to calculate the total (y-ybar) ^ 2
double temp = 0.0;
for (int f = 0; f tempY double stack = [f] - ybar [i];
temp = temp + Math.pow (stack, 2);
)

pnyb = Math.sqrt (Load imgs * temp);
System.out.println ( "denominator verse to" + i + "is" + pnyb);
return pnyb;
)

private static double hitungxbar (int k) (
/ / calculate the total x
double temp = 0;
for (int i = 0; i (
temp = temp + Integer.parseInt (problems [i] [1]);
)

double result = Integer.parseInt (problems [k] [1]) / temp;
System.out.println ( "x bar is" + result);
return result;
)

private static double hitungybar (int i) (

/ / Y bar in the clause to the i
/ / calculate the total y
double temp = 0;





2 comments:

Nanang said...

Kok cuman simulasinya? Mana complete programnya?

Icank said...

tunggu posting selanjutnya..hehehe :)

Calendar