001/* 002 * Copyright 2017-2022 Product Mog LLC, 2022-2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.lokalized; 018 019import org.jspecify.annotations.NonNull; 020 021import java.util.Arrays; 022import java.util.Collections; 023import java.util.Map; 024import java.util.stream.Collectors; 025 026/** 027 * Generic classifier categories for languages that require measure words or counters. 028 * <p> 029 * This enum is intentionally non-exhaustive. It captures common cross-language semantic buckets used by classifier 030 * systems while remaining small enough to be practical in application code. 031 * 032 * @author <a href="https://revetkn.com">Mark Allen</a> 033 */ 034public enum Classifier implements LanguageForm { 035 /** 036 * General-purpose classifier. 037 */ 038 GENERAL, 039 /** 040 * People or human referents. 041 */ 042 PERSON, 043 /** 044 * Animals or living creatures. 045 */ 046 ANIMAL, 047 /** 048 * Long, thin, or cylindrical objects. 049 */ 050 LONG_THIN, 051 /** 052 * Flat, thin, or sheet-like objects. 053 */ 054 FLAT, 055 /** 056 * Bound volumes such as books or magazines. 057 */ 058 BOUND, 059 /** 060 * Machines, devices, or large pieces of equipment. 061 */ 062 MACHINE, 063 /** 064 * Vehicles. 065 */ 066 VEHICLE; 067 068 @NonNull 069 private static final Map<@NonNull String, @NonNull Classifier> CLASSIFIERS_BY_NAME; 070 071 static { 072 CLASSIFIERS_BY_NAME = Collections.unmodifiableMap(Arrays.stream( 073 Classifier.values()).collect(Collectors.toMap(classifier -> classifier.name(), classifier -> classifier))); 074 } 075 076 /** 077 * Gets the mapping of classifier names to classifier values. 078 * 079 * @return the mapping of classifier names to classifier values, not null 080 */ 081 @NonNull 082 static Map<@NonNull String, @NonNull Classifier> getClassifiersByName() { 083 return CLASSIFIERS_BY_NAME; 084 } 085}