public double bigramPMI(String bigram,String []bi) {
        String[] arr = bigram.split(" ");

        int n11 = 0, n12 = 0, n21 = 0, n22 = 0, n1p = 0, np1 = 0, n2p = 0, np2 = 0, npp = 0;
        double m11 = 0, PMI = 0;
        
        for (int i = 0; i < bi.length; i++) {
            
            String temp = bi[i];

            if (bigram.equalsIgnoreCase(temp)) {
                n11++;
            }

            if (temp.startsWith(arr[0]) && !temp.endsWith(arr[1])) {
                n12++;
            }

            if (!temp.startsWith(arr[0]) && temp.endsWith(arr[1])) {
                n21++;
            }
            if (temp.startsWith(arr[0])) {
                n1p++;
            }
            if (temp.endsWith(arr[1])) {
                np1++;
            }
        }
        n22 = bigrame.size() - n11;
        n2p = bigrame.size() - n1p;
        np2 = bigrame.size() - np1;
        npp = bigrame.size();
        m11 = (np1 * n1p) / npp;

        PMI = Math.log(n11 / m11) / Math.log(2);
        return PMI;
    }

the problem is the code evalute if condition with false even it take clear and true data
can any one help
i will be grateful
Thanks all

could you please use [ code ] tags? Also, where is the problem, which if statement?

You can debug this yourself by adding some print statements just before your if tests. Print the raw data that is going to be used in the test, and the results of any methods used in the test. This will immediately show you why your if tests are not giving the expected result.

all if conditions have problems
but i think the problem related to memory address
it compare address by address so it evaluate with false

I think I solve the problem

please use code tags whn posting your code
[ code]
code here
[ /code]

whithout the space in []

code
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.