Java String Equal areEqualLexemes(String l1, String l2)

Here you can find the source of areEqualLexemes(String l1, String l2)

Description

Sometimes different API methods deliver different results, e.g.

License

Apache License

Parameter

Parameter Description
l1 a parameter
l2 a parameter

Declaration

private static boolean areEqualLexemes(String l1, String l2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright 2012/*w  w  w.  j av  a 2 s .  c om*/
 * Ubiquitous Knowledge Processing (UKP) Lab
 * Technische Universit?t Darmstadt
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

public class Main {
    /**
     * Sometimes different API methods deliver different results, e.g. we can find a synset for a lexeme with underscores with one method, but not with the other.
     * Thus, equal lexemes should be tested a little bit more thoroughly.
     *
     * @param l1
     * @param l2
     * @return
     */
    private static boolean areEqualLexemes(String l1, String l2) {
        if (l1.equals(l2)) {
            return true;
        }

        // replace spaces with underscores.
        String l1_relaxed = l1.replaceAll(" ", "_");
        String l2_relaxed = l2.replaceAll(" ", "_");

        if (l1_relaxed.equals(l2_relaxed)) {
            return true;
        }

        return false;
    }
}

Related

  1. areEqual(String string1, String string2)
  2. areEqual(String thisString, String thatString)
  3. areEqualConstantTime(String a, String b)
  4. areEqualIgnoreCase(String s1, String s2)
  5. areEqualIgnoreNull(String value1, String value2, boolean caseSensitive)
  6. areEquals(final String origin, final String checkWith)
  7. areEquals(final String s1, final String s2)
  8. areEqualsIgnoreCaseAndTrim(final String s1, final String s2)
  9. areEqualXMLValues(String s1, String s2)