LocalizedStatFormats.java

  1. /*
  2.  * Licensed to the Hipparchus project under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The Hipparchus project licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      https://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.hipparchus.stat;

  18. import java.util.Locale;

  19. import org.hipparchus.exception.Localizable;

  20. /**
  21.  * Enumeration for localized messages formats used in exceptions messages.
  22.  * <p>
  23.  * The constants in this enumeration represent the available formats as
  24.  * localized strings. These formats are intended to be localized using simple
  25.  * properties files, using the constant name as the key and the property value
  26.  * as the message format. The source English format is provided in the constants
  27.  * themselves to serve both as a reminder for developers to understand the
  28.  * parameters needed by each format, as a basis for translators to create
  29.  * localized properties files, and as a default format if some translation is
  30.  * missing.
  31.  * </p>
  32.  */
  33. public enum LocalizedStatFormats implements Localizable {

  34.     /** TIES_ARE_NOT_ALLOWED. */
  35.     TIES_ARE_NOT_ALLOWED("Ties are not allowed."),

  36.     /** INSUFFICIENT_DATA_FOR_T_STATISTIC. */
  37.     INSUFFICIENT_DATA_FOR_T_STATISTIC("insufficient data for t statistic, needs at least 2, got {0}"),

  38.     /** NOT_ENOUGH_DATA_REGRESSION. */
  39.     NOT_ENOUGH_DATA_REGRESSION("the number of observations is not sufficient to conduct regression"),

  40.     /** INVALID_REGRESSION_OBSERVATION. */
  41.     INVALID_REGRESSION_OBSERVATION("length of regressor array = {0} does not match the number of variables = {1} in the model"),

  42.     /** NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS. */
  43.     NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS("not enough data ({0} rows) for this many predictors ({1} predictors)"),

  44.     /** NOT_SUPPORTED_NAN_STRATEGY. */
  45.     NOT_SUPPORTED_NAN_STRATEGY("NaN strategy {0} not supported"),

  46.     /** NO_REGRESSORS. */
  47.     NO_REGRESSORS("Regression model must include at least one regressor"),

  48.     /** COVARIANCE_MATRIX. */
  49.     COVARIANCE_MATRIX("covariance matrix"),

  50.     /** OUT_OF_BOUNDS_QUANTILE_VALUE. */
  51.     OUT_OF_BOUNDS_QUANTILE_VALUE("out of bounds quantile value: {0}, must be in (0, 100]"),

  52.     /** OUT_OF_BOUNDS_CONFIDENCE_LEVEL. */
  53.     OUT_OF_BOUNDS_CONFIDENCE_LEVEL("out of bounds confidence level {0}, must be between {1} and {2}"),

  54.     /** OUT_OF_BOUND_SIGNIFICANCE_LEVEL. */
  55.     OUT_OF_BOUND_SIGNIFICANCE_LEVEL("out of bounds significance level {0}, must be between {1} and {2}"),

  56.     /** SIGNIFICANCE_LEVEL. */
  57.     SIGNIFICANCE_LEVEL("significance level ({0})"),

  58.     /** TOO_MANY_REGRESSORS. */
  59.     TOO_MANY_REGRESSORS("too many regressors ({0}) specified, only {1} in the model"),

  60.     /** TWO_OR_MORE_CATEGORIES_REQUIRED. */
  61.     TWO_OR_MORE_CATEGORIES_REQUIRED("two or more categories required, got {0}"),

  62.     /** TWO_OR_MORE_VALUES_IN_CATEGORY_REQUIRED. */
  63.     TWO_OR_MORE_VALUES_IN_CATEGORY_REQUIRED("two or more values required in each category, one has {0}"),

  64.     /** ILLEGAL_STATE_PCA. */
  65.     ILLEGAL_STATE_PCA("you must fit the PCA projection before calling {0}");

  66.     /** Source English format. */
  67.     private final String sourceFormat;

  68.     /**
  69.      * Simple constructor.
  70.      *
  71.      * @param sourceFormat source English format to use when no localized
  72.      *        version is available
  73.      */
  74.     LocalizedStatFormats(final String sourceFormat) {
  75.         this.sourceFormat = sourceFormat;
  76.     }

  77.     /** {@inheritDoc} */
  78.     @Override
  79.     public String getSourceString() {
  80.         return sourceFormat;
  81.     }

  82.     /** {@inheritDoc} */
  83.     @Override
  84.     public String getLocalizedString(final Locale locale) {
  85.         return getLocalizedString("assets/" + LocalizedStatFormats.class.getName().replaceAll("\\.", "/"),
  86.                                   name(), locale);
  87.     }

  88. }