Java Array Match arrayMatch(String[] strArr1, String[] strArr2)

Here you can find the source of arrayMatch(String[] strArr1, String[] strArr2)

Description

array Match

License

Open Source License

Declaration

public static boolean arrayMatch(String[] strArr1, String[] strArr2) 

Method Source Code

//package com.java2s;
/*//  w  w  w .j a v  a 2 s  .  c om
 JavaRAP: a freely-available JAVA anaphora resolution implementation
 of the classic Lappin and Leass (1994) paper:
    
 An Algorithm for Pronominal Anaphora Resolution.
 Computational Linguistics, 20(4), pp. 535-561.
    
 Copyright (C) 2005,2006  Long Qiu
    
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
    
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
    
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

public class Main {
    public static boolean arrayMatch(String[] strArr1, String[] strArr2) {
        int l1 = strArr1.length;
        int l2 = strArr2.length;
        String str1 = "";
        String str2 = "";

        for (int i = 0; i < l1; i++) {
            str1 += strArr1[i];
        }
        for (int i = 0; i < l2; i++) {
            str2 += strArr2[i];
        }

        if ((float) Math.max(l1, l2) / (float) (Math.min(l1, l2)) > 1.3) {
            if (Math.min(l1, l2) < 4) {
                if (str1.indexOf(str2) == 0 || str2.indexOf(str1) == 0) {
                    //same beginning
                    return true;
                }
                return false;
            }
        }

        return str1.indexOf(str2) >= 0 || str2.indexOf(str1) >= 0;
    }
}