com.basistech.util.NEConstants Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-api Show documentation
Show all versions of common-api Show documentation
Common Java API classes for Rosette
/*
* Copyright 2014-2019 Basis Technology Corp.
*
* 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.
*/
/*
* DO NOT EDIT THIS FILE /home/kt/git/rosette-common-java-api/target/checkout/api/target/generated-sources/com/basistech/util/NEConstants.java
* It has been AutoGen-ed Wed Sep 4 14:12:02 2024
* and the template file /home/kt/git/rosette-common-java-api/target/checkout/api/src/main/templates/NEConstants.java.tpl
*/
package com.basistech.util;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
/**
* Constants used for labeling Named Entities.
*
**/
@SuppressWarnings("PMD")
public final class NEConstants {
/** Start of the user-defined NE type space */
public static final int NE_TYPE_USER_DEFINED_START = 0x1000 << 16;
/** Unknown or uncodable. */
public static final int NE_TYPE_NONE = 0x0000 << 16;
/** Persons */
public static final int NE_TYPE_PERSON = 0x0001 << 16;
/** Organizations. */
public static final int NE_TYPE_ORGANIZATION = 0x0002 << 16;
/** Location name. */
public static final int NE_TYPE_LOCATION = 0x0003 << 16;
/** Facility name. */
public static final int NE_TYPE_FACILITY = 0x0004 << 16;
/** Geo-political entity. */
public static final int NE_TYPE_GPE = 0x0005 << 16;
/** Vehicle types. */
public static final int NE_TYPE_VEHICLE = 0x0006 << 16;
/** Weapon types. */
public static final int NE_TYPE_WEAPON = 0x0007 << 16;
/** Times and Dates. */
public static final int NE_TYPE_TEMPORAL = 0x0008 << 16;
/** Electronic or other ephemeral identifier. */
public static final int NE_TYPE_IDENTIFIER = 0x0009 << 16;
/** Religion types. */
public static final int NE_TYPE_RELIGION = 0x000A << 16;
/** Nationality types. */
public static final int NE_TYPE_NATIONALITY = 0x000B << 16;
/** Title types. */
public static final int NE_TYPE_TITLE = 0x000C << 16;
/** Twitter username including the leading at-mark. */
public static final int NE_TYPE_TWITTER_USERNAME = 0x000D << 16;
/** Hashtag (e.g. #quake) */
public static final int NE_TYPE_HASHTAG = 0x000E << 16;
/** Something that you can buy, certain categories excluded. */
public static final int NE_TYPE_PRODUCT = 0x000F << 16;
/** A document published either in physical or electronic format */
public static final int NE_TYPE_PUBLICATION = 0x0010 << 16;
/** Component of a mailing address */
public static final int NE_TYPE_ADDRESS_FIELD = 0x0011 << 16;
/** A date */
public static final int NE_TYPE_TEMPORAL_DATE = NE_TYPE_TEMPORAL | 0x0001;
/** A time */
public static final int NE_TYPE_TEMPORAL_TIME = NE_TYPE_TEMPORAL | 0x0002;
/** Other temporal instances */
public static final int NE_TYPE_TEMPORAL_OTHER = NE_TYPE_TEMPORAL | 0xFFFF;
/** An E-mail address */
public static final int NE_TYPE_IDENTIFIER_EMAIL = NE_TYPE_IDENTIFIER | 0x0001;
/** A URL */
public static final int NE_TYPE_IDENTIFIER_URL = NE_TYPE_IDENTIFIER | 0x0002;
/** An Internet domain name */
public static final int NE_TYPE_IDENTIFIER_DOMAIN_NAME = NE_TYPE_IDENTIFIER | 0x0003;
/** An Internet IP address */
public static final int NE_TYPE_IDENTIFIER_IP_ADDRESS = NE_TYPE_IDENTIFIER | 0x0004;
/** A telephone (landline, mobile) number */
public static final int NE_TYPE_IDENTIFIER_PHONE_NUMBER = NE_TYPE_IDENTIFIER | 0x0005;
/** A fax number */
public static final int NE_TYPE_IDENTIFIER_FAX_NUMBER = NE_TYPE_IDENTIFIER | 0x0006;
/** Personal ID number, such as a work ID. */
public static final int NE_TYPE_IDENTIFIER_PERSONAL_ID_NUM = NE_TYPE_IDENTIFIER | 0x0007;
/** Latitude Longitude Coordinates */
public static final int NE_TYPE_IDENTIFIER_LATITUDE_LONGITUDE = NE_TYPE_IDENTIFIER | 0x0008;
/** A credit card number */
public static final int NE_TYPE_IDENTIFIER_CREDIT_CARD_NUM = NE_TYPE_IDENTIFIER | 0x0009;
/** Monetary amounts */
public static final int NE_TYPE_IDENTIFIER_MONEY = NE_TYPE_IDENTIFIER | 0x000A;
/** Percentages */
public static final int NE_TYPE_IDENTIFIER_PERCENT = NE_TYPE_IDENTIFIER | 0x000B;
/** Universal Transverse Mercator Coordinates */
public static final int NE_TYPE_IDENTIFIER_UTM = NE_TYPE_IDENTIFIER | 0x000C;
/** Distance */
public static final int NE_TYPE_IDENTIFIER_DISTANCE = NE_TYPE_IDENTIFIER | 0x000D;
/** Number */
public static final int NE_TYPE_IDENTIFIER_NUMBER = NE_TYPE_IDENTIFIER | 0x000E;
/** License Plate */
public static final int NE_TYPE_IDENTIFIER_LICENSE_PLATE = NE_TYPE_IDENTIFIER | 0x000F;
/** Driver's License */
public static final int NE_TYPE_IDENTIFIER_DRIVERS_LICENSE = NE_TYPE_IDENTIFIER | 0x0010;
/** National ID Number, such as a US SSN. */
public static final int NE_TYPE_IDENTIFIER_NATIONAL_ID_NUM = NE_TYPE_IDENTIFIER | 0x0011;
/** An identifier not captured under any other items above */
public static final int NE_TYPE_IDENTIFIER_GENERIC = NE_TYPE_IDENTIFIER | 0x0012;
/** Other identifier instances */
public static final int NE_TYPE_IDENTIFIER_OTHER = NE_TYPE_IDENTIFIER | 0xFFFF;
/** A building or complex name */
public static final int NE_TYPE_ADDRESS_FIELD_HOUSE = NE_TYPE_ADDRESS_FIELD | 0x0001;
/** A road name */
public static final int NE_TYPE_ADDRESS_FIELD_ROAD = NE_TYPE_ADDRESS_FIELD | 0x0002;
/** A city name */
public static final int NE_TYPE_ADDRESS_FIELD_CITY = NE_TYPE_ADDRESS_FIELD | 0x0003;
/** A state name or abbreviation */
public static final int NE_TYPE_ADDRESS_FIELD_STATE = NE_TYPE_ADDRESS_FIELD | 0x0004;
/** A country name */
public static final int NE_TYPE_ADDRESS_FIELD_COUNTRY = NE_TYPE_ADDRESS_FIELD | 0x0005;
/** A house number */
public static final int NE_TYPE_ADDRESS_FIELD_HOUSE_NUMBER = NE_TYPE_ADDRESS_FIELD | 0x0006;
/** A unit or apartment number */
public static final int NE_TYPE_ADDRESS_FIELD_UNIT = NE_TYPE_ADDRESS_FIELD | 0x0007;
/** A post office box number */
public static final int NE_TYPE_ADDRESS_FIELD_PO_BOX = NE_TYPE_ADDRESS_FIELD | 0x0008;
/** A post address */
public static final int NE_TYPE_ADDRESS_FIELD_POST_CODE = NE_TYPE_ADDRESS_FIELD | 0x0009;
/** Other address_field instances */
public static final int NE_TYPE_ADDRESS_FIELD_OTHER = NE_TYPE_ADDRESS_FIELD | 0xFFFF;
/** Printable name for NAMED_ENTITY_NONE */
public static final String NAMED_ENTITY_NONE = "NONE";
/** Printable name for NAMED_ENTITY_PERSON */
public static final String NAMED_ENTITY_PERSON = "PERSON";
/** Printable name for NAMED_ENTITY_ORGANIZATION */
public static final String NAMED_ENTITY_ORGANIZATION = "ORGANIZATION";
/** Printable name for NAMED_ENTITY_LOCATION */
public static final String NAMED_ENTITY_LOCATION = "LOCATION";
/** Printable name for NAMED_ENTITY_FACILITY */
public static final String NAMED_ENTITY_FACILITY = "FACILITY";
/** Printable name for NAMED_ENTITY_GPE */
public static final String NAMED_ENTITY_GPE = "GPE";
/** Printable name for NAMED_ENTITY_VEHICLE */
public static final String NAMED_ENTITY_VEHICLE = "VEHICLE";
/** Printable name for NAMED_ENTITY_WEAPON */
public static final String NAMED_ENTITY_WEAPON = "WEAPON";
/** Printable name for NAMED_ENTITY_TEMPORAL */
public static final String NAMED_ENTITY_TEMPORAL = "TEMPORAL";
/** Printable name for NAMED_ENTITY_TEMPORAL_DATE */
public static final String NAMED_ENTITY_TEMPORAL_DATE = "TEMPORAL:DATE";
/** Printable name for NAMED_ENTITY_TEMPORAL_TIME */
public static final String NAMED_ENTITY_TEMPORAL_TIME = "TEMPORAL:TIME";
/** Printable name for NAMED_ENTITY_TEMPORAL_OTHER */
public static final String NAMED_ENTITY_TEMPORAL_OTHER = "TEMPORAL:OTHER";
/** Printable name for NAMED_ENTITY_IDENTIFIER */
public static final String NAMED_ENTITY_IDENTIFIER = "IDENTIFIER";
/** Printable name for NAMED_ENTITY_IDENTIFIER_EMAIL */
public static final String NAMED_ENTITY_IDENTIFIER_EMAIL = "IDENTIFIER:EMAIL";
/** Printable name for NAMED_ENTITY_IDENTIFIER_URL */
public static final String NAMED_ENTITY_IDENTIFIER_URL = "IDENTIFIER:URL";
/** Printable name for NAMED_ENTITY_IDENTIFIER_DOMAIN_NAME */
public static final String NAMED_ENTITY_IDENTIFIER_DOMAIN_NAME = "IDENTIFIER:DOMAIN_NAME";
/** Printable name for NAMED_ENTITY_IDENTIFIER_IP_ADDRESS */
public static final String NAMED_ENTITY_IDENTIFIER_IP_ADDRESS = "IDENTIFIER:IP_ADDRESS";
/** Printable name for NAMED_ENTITY_IDENTIFIER_PHONE_NUMBER */
public static final String NAMED_ENTITY_IDENTIFIER_PHONE_NUMBER = "IDENTIFIER:PHONE_NUMBER";
/** Printable name for NAMED_ENTITY_IDENTIFIER_FAX_NUMBER */
public static final String NAMED_ENTITY_IDENTIFIER_FAX_NUMBER = "IDENTIFIER:FAX_NUMBER";
/** Printable name for NAMED_ENTITY_IDENTIFIER_PERSONAL_ID_NUM */
public static final String NAMED_ENTITY_IDENTIFIER_PERSONAL_ID_NUM = "IDENTIFIER:PERSONAL_ID_NUM";
/** Printable name for NAMED_ENTITY_IDENTIFIER_LATITUDE_LONGITUDE */
public static final String NAMED_ENTITY_IDENTIFIER_LATITUDE_LONGITUDE = "IDENTIFIER:LATITUDE_LONGITUDE";
/** Printable name for NAMED_ENTITY_IDENTIFIER_CREDIT_CARD_NUM */
public static final String NAMED_ENTITY_IDENTIFIER_CREDIT_CARD_NUM = "IDENTIFIER:CREDIT_CARD_NUM";
/** Printable name for NAMED_ENTITY_IDENTIFIER_MONEY */
public static final String NAMED_ENTITY_IDENTIFIER_MONEY = "IDENTIFIER:MONEY";
/** Printable name for NAMED_ENTITY_IDENTIFIER_PERCENT */
public static final String NAMED_ENTITY_IDENTIFIER_PERCENT = "IDENTIFIER:PERCENT";
/** Printable name for NAMED_ENTITY_IDENTIFIER_UTM */
public static final String NAMED_ENTITY_IDENTIFIER_UTM = "IDENTIFIER:UTM";
/** Printable name for NAMED_ENTITY_IDENTIFIER_DISTANCE */
public static final String NAMED_ENTITY_IDENTIFIER_DISTANCE = "IDENTIFIER:DISTANCE";
/** Printable name for NAMED_ENTITY_IDENTIFIER_NUMBER */
public static final String NAMED_ENTITY_IDENTIFIER_NUMBER = "IDENTIFIER:NUMBER";
/** Printable name for NAMED_ENTITY_IDENTIFIER_LICENSE_PLATE */
public static final String NAMED_ENTITY_IDENTIFIER_LICENSE_PLATE = "IDENTIFIER:LICENSE_PLATE";
/** Printable name for NAMED_ENTITY_IDENTIFIER_DRIVERS_LICENSE */
public static final String NAMED_ENTITY_IDENTIFIER_DRIVERS_LICENSE = "IDENTIFIER:DRIVERS_LICENSE";
/** Printable name for NAMED_ENTITY_IDENTIFIER_NATIONAL_ID_NUM */
public static final String NAMED_ENTITY_IDENTIFIER_NATIONAL_ID_NUM = "IDENTIFIER:NATIONAL_ID_NUM";
/** Printable name for NAMED_ENTITY_IDENTIFIER_GENERIC */
public static final String NAMED_ENTITY_IDENTIFIER_GENERIC = "IDENTIFIER:GENERIC";
/** Printable name for NAMED_ENTITY_IDENTIFIER_OTHER */
public static final String NAMED_ENTITY_IDENTIFIER_OTHER = "IDENTIFIER:OTHER";
/** Printable name for NAMED_ENTITY_RELIGION */
public static final String NAMED_ENTITY_RELIGION = "RELIGION";
/** Printable name for NAMED_ENTITY_NATIONALITY */
public static final String NAMED_ENTITY_NATIONALITY = "NATIONALITY";
/** Printable name for NAMED_ENTITY_TITLE */
public static final String NAMED_ENTITY_TITLE = "TITLE";
/** Printable name for NAMED_ENTITY_TWITTER_USERNAME */
public static final String NAMED_ENTITY_TWITTER_USERNAME = "TWITTER_USERNAME";
/** Printable name for NAMED_ENTITY_HASHTAG */
public static final String NAMED_ENTITY_HASHTAG = "HASHTAG";
/** Printable name for NAMED_ENTITY_PRODUCT */
public static final String NAMED_ENTITY_PRODUCT = "PRODUCT";
/** Printable name for NAMED_ENTITY_PUBLICATION */
public static final String NAMED_ENTITY_PUBLICATION = "PUBLICATION";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD */
public static final String NAMED_ENTITY_ADDRESS_FIELD = "ADDRESS_FIELD";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_HOUSE */
public static final String NAMED_ENTITY_ADDRESS_FIELD_HOUSE = "ADDRESS_FIELD:HOUSE";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_ROAD */
public static final String NAMED_ENTITY_ADDRESS_FIELD_ROAD = "ADDRESS_FIELD:ROAD";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_CITY */
public static final String NAMED_ENTITY_ADDRESS_FIELD_CITY = "ADDRESS_FIELD:CITY";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_STATE */
public static final String NAMED_ENTITY_ADDRESS_FIELD_STATE = "ADDRESS_FIELD:STATE";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_COUNTRY */
public static final String NAMED_ENTITY_ADDRESS_FIELD_COUNTRY = "ADDRESS_FIELD:COUNTRY";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_HOUSE_NUMBER */
public static final String NAMED_ENTITY_ADDRESS_FIELD_HOUSE_NUMBER = "ADDRESS_FIELD:HOUSE_NUMBER";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_UNIT */
public static final String NAMED_ENTITY_ADDRESS_FIELD_UNIT = "ADDRESS_FIELD:UNIT";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_PO_BOX */
public static final String NAMED_ENTITY_ADDRESS_FIELD_PO_BOX = "ADDRESS_FIELD:PO_BOX";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_POST_CODE */
public static final String NAMED_ENTITY_ADDRESS_FIELD_POST_CODE = "ADDRESS_FIELD:POST_CODE";
/** Printable name for NAMED_ENTITY_ADDRESS_FIELD_OTHER */
public static final String NAMED_ENTITY_ADDRESS_FIELD_OTHER = "ADDRESS_FIELD:OTHER";
/** Internal hash for mapping numeric value to string value */
private static Map neMap;
/** Map built-in type string to int value */
private static final Map neTypeMap;
private NEConstants() {
}
/**
* Takes a named entity type constant and returns the human-readable name.
* @param v The named entity type.
* @return Human-readable name.
**/
public static String toString(int v) {
return neMap.get(new Integer(v));
}
/**
* Takes a standard human-readable named entity type name
* and returns the integer constant. Note that only built-in types are
* supported. For custom types, use RLPNENameMap.parse().
* @param s Named entity type name.
* @throws InvalidNamedEntityTypeNameException when an ID for the string can not be found.
* @return Integer constant for the given entity type.
**/
public static int parse(String s) throws InvalidNamedEntityTypeNameException {
// COMN-27: Look for built-in types first to avoid the costly
// reflection below.
String key = s.toUpperCase(Locale.ENGLISH);
if (neTypeMap.containsKey(key)) {
return neTypeMap.get(key);
}
throw new InvalidNamedEntityTypeNameException("No type. Named entity \""
+ key
+ "\" is not supported.");
}
/**
* Takes a source language processor id and returns its human-readable
* name.
* To get processor id, use {@link #extractLP(int) extractLP(int source)}. Return values
* include "statistical", "gazetteer" (exact match), "regex" pattern match), "none".
*
* @param v The source language processor.
* @return Human-readable name.
**/
public static String getSourceLPName(int v) {
switch(v) {
case NEConstants.RLP_LP_NONE:
return "none";
case NEConstants.RLP_LP_STAT:
return "statistical";
case NEConstants.RLP_LP_GAZ:
return "gazetteer";
case NEConstants.RLP_LP_REGEX:
return "regex";
}
return "NONE";
}
/**
* Takes the name of a source language processor and returns the ID.
* Return values include NEConstants.RLP_LP_STAT, NEConstants.RLP_LP_GAZ,
* NEConstants.RLP_LP_REGEX, and NEConstants.RLP_LP_NONE.
* @param s The name: "statistical", "gazetteer" (exact match), or "regex" (pattern match).
* @return The source language processor ID.
**/
public static int getSourceLPID(String s) {
if (s.equals("STAT") || s.equals("statistical")) {
return NEConstants.RLP_LP_STAT;
} else if (s.equals("GAZE") || s.equals("gazetteer")) {
return NEConstants.RLP_LP_GAZ;
} else if (s.equals("REGX") || s.equals("regex")) {
return NEConstants.RLP_LP_REGEX;
}
return NEConstants.RLP_LP_NONE;
}
static {
neMap = new TreeMap();
neMap.put(new Integer(NEConstants.NE_TYPE_NONE),
NEConstants.NAMED_ENTITY_NONE);
neMap.put(new Integer(NEConstants.NE_TYPE_PERSON),
NEConstants.NAMED_ENTITY_PERSON);
neMap.put(new Integer(NEConstants.NE_TYPE_ORGANIZATION),
NEConstants.NAMED_ENTITY_ORGANIZATION);
neMap.put(new Integer(NEConstants.NE_TYPE_LOCATION),
NEConstants.NAMED_ENTITY_LOCATION);
neMap.put(new Integer(NEConstants.NE_TYPE_FACILITY),
NEConstants.NAMED_ENTITY_FACILITY);
neMap.put(new Integer(NEConstants.NE_TYPE_GPE),
NEConstants.NAMED_ENTITY_GPE);
neMap.put(new Integer(NEConstants.NE_TYPE_VEHICLE),
NEConstants.NAMED_ENTITY_VEHICLE);
neMap.put(new Integer(NEConstants.NE_TYPE_WEAPON),
NEConstants.NAMED_ENTITY_WEAPON);
neMap.put(new Integer(NEConstants.NE_TYPE_TEMPORAL),
NEConstants.NAMED_ENTITY_TEMPORAL);
neMap.put(new Integer(NEConstants.NE_TYPE_TEMPORAL_DATE),
NEConstants.NAMED_ENTITY_TEMPORAL_DATE);
neMap.put(new Integer(NEConstants.NE_TYPE_TEMPORAL_TIME),
NEConstants.NAMED_ENTITY_TEMPORAL_TIME);
neMap.put(new Integer(NEConstants.NE_TYPE_TEMPORAL_OTHER),
NEConstants.NAMED_ENTITY_TEMPORAL_OTHER);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER),
NEConstants.NAMED_ENTITY_IDENTIFIER);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_EMAIL),
NEConstants.NAMED_ENTITY_IDENTIFIER_EMAIL);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_URL),
NEConstants.NAMED_ENTITY_IDENTIFIER_URL);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_DOMAIN_NAME),
NEConstants.NAMED_ENTITY_IDENTIFIER_DOMAIN_NAME);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_IP_ADDRESS),
NEConstants.NAMED_ENTITY_IDENTIFIER_IP_ADDRESS);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_PHONE_NUMBER),
NEConstants.NAMED_ENTITY_IDENTIFIER_PHONE_NUMBER);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_FAX_NUMBER),
NEConstants.NAMED_ENTITY_IDENTIFIER_FAX_NUMBER);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_PERSONAL_ID_NUM),
NEConstants.NAMED_ENTITY_IDENTIFIER_PERSONAL_ID_NUM);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_LATITUDE_LONGITUDE),
NEConstants.NAMED_ENTITY_IDENTIFIER_LATITUDE_LONGITUDE);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_CREDIT_CARD_NUM),
NEConstants.NAMED_ENTITY_IDENTIFIER_CREDIT_CARD_NUM);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_MONEY),
NEConstants.NAMED_ENTITY_IDENTIFIER_MONEY);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_PERCENT),
NEConstants.NAMED_ENTITY_IDENTIFIER_PERCENT);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_UTM),
NEConstants.NAMED_ENTITY_IDENTIFIER_UTM);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_DISTANCE),
NEConstants.NAMED_ENTITY_IDENTIFIER_DISTANCE);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_NUMBER),
NEConstants.NAMED_ENTITY_IDENTIFIER_NUMBER);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_LICENSE_PLATE),
NEConstants.NAMED_ENTITY_IDENTIFIER_LICENSE_PLATE);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_DRIVERS_LICENSE),
NEConstants.NAMED_ENTITY_IDENTIFIER_DRIVERS_LICENSE);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_NATIONAL_ID_NUM),
NEConstants.NAMED_ENTITY_IDENTIFIER_NATIONAL_ID_NUM);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_GENERIC),
NEConstants.NAMED_ENTITY_IDENTIFIER_GENERIC);
neMap.put(new Integer(NEConstants.NE_TYPE_IDENTIFIER_OTHER),
NEConstants.NAMED_ENTITY_IDENTIFIER_OTHER);
neMap.put(new Integer(NEConstants.NE_TYPE_RELIGION),
NEConstants.NAMED_ENTITY_RELIGION);
neMap.put(new Integer(NEConstants.NE_TYPE_NATIONALITY),
NEConstants.NAMED_ENTITY_NATIONALITY);
neMap.put(new Integer(NEConstants.NE_TYPE_TITLE),
NEConstants.NAMED_ENTITY_TITLE);
neMap.put(new Integer(NEConstants.NE_TYPE_TWITTER_USERNAME),
NEConstants.NAMED_ENTITY_TWITTER_USERNAME);
neMap.put(new Integer(NEConstants.NE_TYPE_HASHTAG),
NEConstants.NAMED_ENTITY_HASHTAG);
neMap.put(new Integer(NEConstants.NE_TYPE_PRODUCT),
NEConstants.NAMED_ENTITY_PRODUCT);
neMap.put(new Integer(NEConstants.NE_TYPE_PUBLICATION),
NEConstants.NAMED_ENTITY_PUBLICATION);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_HOUSE),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_HOUSE);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_ROAD),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_ROAD);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_CITY),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_CITY);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_STATE),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_STATE);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_COUNTRY),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_COUNTRY);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_HOUSE_NUMBER),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_HOUSE_NUMBER);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_UNIT),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_UNIT);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_PO_BOX),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_PO_BOX);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_POST_CODE),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_POST_CODE);
neMap.put(new Integer(NEConstants.NE_TYPE_ADDRESS_FIELD_OTHER),
NEConstants.NAMED_ENTITY_ADDRESS_FIELD_OTHER);
neTypeMap = new HashMap();
neTypeMap.put(NAMED_ENTITY_NONE, NE_TYPE_NONE);
neTypeMap.put(NAMED_ENTITY_PERSON, NE_TYPE_PERSON);
neTypeMap.put(NAMED_ENTITY_ORGANIZATION, NE_TYPE_ORGANIZATION);
neTypeMap.put(NAMED_ENTITY_LOCATION, NE_TYPE_LOCATION);
neTypeMap.put(NAMED_ENTITY_FACILITY, NE_TYPE_FACILITY);
neTypeMap.put(NAMED_ENTITY_GPE, NE_TYPE_GPE);
neTypeMap.put(NAMED_ENTITY_VEHICLE, NE_TYPE_VEHICLE);
neTypeMap.put(NAMED_ENTITY_WEAPON, NE_TYPE_WEAPON);
neTypeMap.put(NAMED_ENTITY_TEMPORAL, NE_TYPE_TEMPORAL);
neTypeMap.put(NAMED_ENTITY_TEMPORAL_DATE, NE_TYPE_TEMPORAL_DATE);
neTypeMap.put(NAMED_ENTITY_TEMPORAL_TIME, NE_TYPE_TEMPORAL_TIME);
neTypeMap.put(NAMED_ENTITY_TEMPORAL_OTHER, NE_TYPE_TEMPORAL_OTHER);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER, NE_TYPE_IDENTIFIER);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_EMAIL, NE_TYPE_IDENTIFIER_EMAIL);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_URL, NE_TYPE_IDENTIFIER_URL);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_DOMAIN_NAME, NE_TYPE_IDENTIFIER_DOMAIN_NAME);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_IP_ADDRESS, NE_TYPE_IDENTIFIER_IP_ADDRESS);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_PHONE_NUMBER, NE_TYPE_IDENTIFIER_PHONE_NUMBER);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_FAX_NUMBER, NE_TYPE_IDENTIFIER_FAX_NUMBER);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_PERSONAL_ID_NUM, NE_TYPE_IDENTIFIER_PERSONAL_ID_NUM);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_LATITUDE_LONGITUDE, NE_TYPE_IDENTIFIER_LATITUDE_LONGITUDE);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_CREDIT_CARD_NUM, NE_TYPE_IDENTIFIER_CREDIT_CARD_NUM);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_MONEY, NE_TYPE_IDENTIFIER_MONEY);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_PERCENT, NE_TYPE_IDENTIFIER_PERCENT);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_UTM, NE_TYPE_IDENTIFIER_UTM);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_DISTANCE, NE_TYPE_IDENTIFIER_DISTANCE);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_NUMBER, NE_TYPE_IDENTIFIER_NUMBER);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_LICENSE_PLATE, NE_TYPE_IDENTIFIER_LICENSE_PLATE);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_DRIVERS_LICENSE, NE_TYPE_IDENTIFIER_DRIVERS_LICENSE);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_NATIONAL_ID_NUM, NE_TYPE_IDENTIFIER_NATIONAL_ID_NUM);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_GENERIC, NE_TYPE_IDENTIFIER_GENERIC);
neTypeMap.put(NAMED_ENTITY_IDENTIFIER_OTHER, NE_TYPE_IDENTIFIER_OTHER);
neTypeMap.put(NAMED_ENTITY_RELIGION, NE_TYPE_RELIGION);
neTypeMap.put(NAMED_ENTITY_NATIONALITY, NE_TYPE_NATIONALITY);
neTypeMap.put(NAMED_ENTITY_TITLE, NE_TYPE_TITLE);
neTypeMap.put(NAMED_ENTITY_TWITTER_USERNAME, NE_TYPE_TWITTER_USERNAME);
neTypeMap.put(NAMED_ENTITY_HASHTAG, NE_TYPE_HASHTAG);
neTypeMap.put(NAMED_ENTITY_PRODUCT, NE_TYPE_PRODUCT);
neTypeMap.put(NAMED_ENTITY_PUBLICATION, NE_TYPE_PUBLICATION);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD, NE_TYPE_ADDRESS_FIELD);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_HOUSE, NE_TYPE_ADDRESS_FIELD_HOUSE);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_ROAD, NE_TYPE_ADDRESS_FIELD_ROAD);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_CITY, NE_TYPE_ADDRESS_FIELD_CITY);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_STATE, NE_TYPE_ADDRESS_FIELD_STATE);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_COUNTRY, NE_TYPE_ADDRESS_FIELD_COUNTRY);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_HOUSE_NUMBER, NE_TYPE_ADDRESS_FIELD_HOUSE_NUMBER);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_UNIT, NE_TYPE_ADDRESS_FIELD_UNIT);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_PO_BOX, NE_TYPE_ADDRESS_FIELD_PO_BOX);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_POST_CODE, NE_TYPE_ADDRESS_FIELD_POST_CODE);
neTypeMap.put(NAMED_ENTITY_ADDRESS_FIELD_OTHER, NE_TYPE_ADDRESS_FIELD_OTHER);
}
/**
* Returns the major type of the Named Entity Type
* @param t Named entity type ID
* @return Major type
*/
public static int extractType(int t) {
return t & 0xffff0000;
}
/**
* Returns the subtype of the Named Entity Type
* @param t Named entity type ID
* @return Subtype
*/
public static int extractSubtype(int t) {
return t & 0x0000ffff;
}
/**
* Returns the language processor ID of the Named Entity Source.
* Return values include NEConstants.RLP_LP_STAT, NEConstants.RLP_LP_GAZ,
* NEConstants.RLP_LP_REGEX, and NEConstants.RLP_LP_NONE.
*
* @param s Named entity source ID
* @return LP IP
*/
public static int extractLP(int s) {
return s & 0xff000000;
}
/**
* Returns the subsource of the Named Entity Source.
* If source is statistical or regex, return value is 0;
* if source is gazetteer, return value identifies the actual gazetteer.
* @param s Named entity source ID
* @return Subsource
*/
public static int extractSubsource(int s) {
return s & 0x00ffffff;
}
/** unknown NE source language processor ID.*/
public static final int RLP_LP_NONE = 0x00 << 24;
/** Named Entity Extractor source language processor ID.*/
public static final int RLP_LP_STAT = 0x01 << 24;
/** Exact Match Entity Extractor source language processor ID.*/
public static final int RLP_LP_GAZ = 0x02 << 24;
/** Pattern Match Entity Extractor source language processor ID.*/
public static final int RLP_LP_REGEX = 0x03 << 24;
/**
Determines if the named entity is a none.
@param t Named entity type ID
@return true if the named entity is a none , false otherwise.
*/
public static boolean isNONE(int t) {
return extractType(t) == NEConstants.NE_TYPE_NONE;
}
/**
Determines if the named entity is a person.
@param t Named entity type ID
@return true if the named entity is a person , false otherwise.
*/
public static boolean isPERSON(int t) {
return extractType(t) == NEConstants.NE_TYPE_PERSON;
}
/**
Determines if the named entity is a organization.
@param t Named entity type ID
@return true if the named entity is a organization , false otherwise.
*/
public static boolean isORGANIZATION(int t) {
return extractType(t) == NEConstants.NE_TYPE_ORGANIZATION;
}
/**
Determines if the named entity is a location.
@param t Named entity type ID
@return true if the named entity is a location , false otherwise.
*/
public static boolean isLOCATION(int t) {
return extractType(t) == NEConstants.NE_TYPE_LOCATION;
}
/**
Determines if the named entity is a facility.
@param t Named entity type ID
@return true if the named entity is a facility , false otherwise.
*/
public static boolean isFACILITY(int t) {
return extractType(t) == NEConstants.NE_TYPE_FACILITY;
}
/**
Determines if the named entity is a gpe.
@param t Named entity type ID
@return true if the named entity is a gpe , false otherwise.
*/
public static boolean isGPE(int t) {
return extractType(t) == NEConstants.NE_TYPE_GPE;
}
/**
Determines if the named entity is a vehicle.
@param t Named entity type ID
@return true if the named entity is a vehicle , false otherwise.
*/
public static boolean isVEHICLE(int t) {
return extractType(t) == NEConstants.NE_TYPE_VEHICLE;
}
/**
Determines if the named entity is a weapon.
@param t Named entity type ID
@return true if the named entity is a weapon , false otherwise.
*/
public static boolean isWEAPON(int t) {
return extractType(t) == NEConstants.NE_TYPE_WEAPON;
}
/**
Determines if the named entity is a temporal.
@param t Named entity type ID
@return true if the named entity is a temporal , false otherwise.
*/
public static boolean isTEMPORAL(int t) {
return extractType(t) == NEConstants.NE_TYPE_TEMPORAL;
}
/**
Determines if the named entity is a identifier.
@param t Named entity type ID
@return true if the named entity is a identifier , false otherwise.
*/
public static boolean isIDENTIFIER(int t) {
return extractType(t) == NEConstants.NE_TYPE_IDENTIFIER;
}
/**
Determines if the named entity is a religion.
@param t Named entity type ID
@return true if the named entity is a religion , false otherwise.
*/
public static boolean isRELIGION(int t) {
return extractType(t) == NEConstants.NE_TYPE_RELIGION;
}
/**
Determines if the named entity is a nationality.
@param t Named entity type ID
@return true if the named entity is a nationality , false otherwise.
*/
public static boolean isNATIONALITY(int t) {
return extractType(t) == NEConstants.NE_TYPE_NATIONALITY;
}
/**
Determines if the named entity is a title.
@param t Named entity type ID
@return true if the named entity is a title , false otherwise.
*/
public static boolean isTITLE(int t) {
return extractType(t) == NEConstants.NE_TYPE_TITLE;
}
/**
Determines if the named entity is a twitter_username.
@param t Named entity type ID
@return true if the named entity is a twitter_username , false otherwise.
*/
public static boolean isTWITTER_USERNAME(int t) {
return extractType(t) == NEConstants.NE_TYPE_TWITTER_USERNAME;
}
/**
Determines if the named entity is a hashtag.
@param t Named entity type ID
@return true if the named entity is a hashtag , false otherwise.
*/
public static boolean isHASHTAG(int t) {
return extractType(t) == NEConstants.NE_TYPE_HASHTAG;
}
/**
Determines if the named entity is a product.
@param t Named entity type ID
@return true if the named entity is a product , false otherwise.
*/
public static boolean isPRODUCT(int t) {
return extractType(t) == NEConstants.NE_TYPE_PRODUCT;
}
/**
Determines if the named entity is a publication.
@param t Named entity type ID
@return true if the named entity is a publication , false otherwise.
*/
public static boolean isPUBLICATION(int t) {
return extractType(t) == NEConstants.NE_TYPE_PUBLICATION;
}
/**
Determines if the named entity is a address_field.
@param t Named entity type ID
@return true if the named entity is a address_field , false otherwise.
*/
public static boolean isADDRESS_FIELD(int t) {
return extractType(t) == NEConstants.NE_TYPE_ADDRESS_FIELD;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy