1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.hipparchus.stat;
18
19 import java.util.Locale;
20 import java.util.MissingResourceException;
21 import java.util.ResourceBundle;
22
23 import org.hipparchus.exception.Localizable;
24 import org.hipparchus.exception.UTF8Control;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public enum LocalizedStatFormats implements Localizable {
40
41
42 TIES_ARE_NOT_ALLOWED("Ties are not allowed."),
43
44
45 INSUFFICIENT_DATA_FOR_T_STATISTIC("insufficient data for t statistic, needs at least 2, got {0}"),
46
47
48 NOT_ENOUGH_DATA_REGRESSION("the number of observations is not sufficient to conduct regression"),
49
50
51 INVALID_REGRESSION_OBSERVATION("length of regressor array = {0} does not match the number of variables = {1} in the model"),
52
53
54 NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS("not enough data ({0} rows) for this many predictors ({1} predictors)"),
55
56
57 NOT_SUPPORTED_NAN_STRATEGY("NaN strategy {0} not supported"),
58
59
60 NO_REGRESSORS("Regression model must include at least one regressor"),
61
62
63 COVARIANCE_MATRIX("covariance matrix"),
64
65
66 OUT_OF_BOUNDS_QUANTILE_VALUE("out of bounds quantile value: {0}, must be in (0, 100]"),
67
68
69 OUT_OF_BOUNDS_CONFIDENCE_LEVEL("out of bounds confidence level {0}, must be between {1} and {2}"),
70
71
72 OUT_OF_BOUND_SIGNIFICANCE_LEVEL("out of bounds significance level {0}, must be between {1} and {2}"),
73
74
75 SIGNIFICANCE_LEVEL("significance level ({0})"),
76
77
78 TOO_MANY_REGRESSORS("too many regressors ({0}) specified, only {1} in the model"),
79
80
81 TWO_OR_MORE_CATEGORIES_REQUIRED("two or more categories required, got {0}"),
82
83
84 TWO_OR_MORE_VALUES_IN_CATEGORY_REQUIRED("two or more values required in each category, one has {0}"),
85
86
87 ILLEGAL_STATE_PCA("you must fit the PCA projection before calling {0}");
88
89
90 private final String sourceFormat;
91
92
93
94
95
96
97
98 LocalizedStatFormats(final String sourceFormat) {
99 this.sourceFormat = sourceFormat;
100 }
101
102
103 @Override
104 public String getSourceString() {
105 return sourceFormat;
106 }
107
108
109 @Override
110 public String getLocalizedString(final Locale locale) {
111 try {
112 final String path = LocalizedStatFormats.class.getName()
113 .replaceAll("\\.", "/");
114 ResourceBundle bundle = ResourceBundle
115 .getBundle("assets/" + path, locale, new UTF8Control());
116 if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
117 final String translated = bundle.getString(name());
118 if ((translated != null) && (translated.length() > 0) &&
119 (!translated.toLowerCase(locale).contains("missing translation"))) {
120
121 return translated;
122 }
123 }
124
125 } catch (MissingResourceException mre) {
126
127 }
128
129
130
131 return sourceFormat;
132
133 }
134
135 }