All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opensextant.extraction.TextEntity Maven / Gradle / Ivy

There is a newer version: 3.7.3
Show newest version
/*
 *
 * Copyright 2012-2013 The MITRE Corporation.
 *
 * 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.
 */
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
//
// _____                                ____                     __                       __
///\  __`\                             /\  _`\                  /\ \__                   /\ \__
//\ \ \/\ \   _____      __     ___    \ \,\L\_\      __   __  _\ \ ,_\     __       ___ \ \ ,_\
// \ \ \ \ \ /\ '__`\  /'__`\ /' _ `\   \/_\__ \    /'__`\/\ \/'\\ \ \/   /'__`\   /' _ `\\ \ \/
//  \ \ \_\ \\ \ \L\ \/\  __/ /\ \/\ \    /\ \L\ \ /\  __/\/>  = t.start);
    }

    /**
     * Assuming simple whitespace separation or other simple delimiters, is this
     * term following the argument entity?
     * 
     * @param t other entity
     * @return true if t occurs after the current entity
     */
    public boolean isAfter(TextEntity t) {
        return (start - t.end <= 2 && start > t.end);
    }

    /**
     * Assuming simple whitespace separation or other simple delimiters, is this
     * term preceeding the argument entity?
     * 
     * @param t other TextEntity
     * @return true if t is before the current entity
     */
    public boolean isBefore(TextEntity t) {
        return (t.start - end <= 2 && t.start > end);
    }

    public boolean isSameMatch(TextEntity t) {
        return (start == t.start && end == t.end);
    }

    public boolean isRightMatch(TextEntity t) {
        return (start == t.start);
    }

    public boolean isLeftMatch(TextEntity t) {
        return (end == t.end);
    }

    public boolean isOverlap(TextEntity t) {
        // t overlaps with self on the left side
        // OR t overlaps with self on right side
        //
        return (end > t.end && start > t.start && start < t.end) || (end < t.end && start < t.start && end > t.start);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy