Class: UniPropUtils::TypeJudgementer
- Inherits:
-
Object
- Object
- UniPropUtils::TypeJudgementer
- Defined in:
- lib/uniprop/utils.rb
Constant Summary collapse
- RE_SINGLE_CODEPOINT =
/^[0-9A-Fa-f]{4,6}$/
- RE_RANGE_CODEPOINT =
/^[0-9A-Fa-f]{4,6}\.\.[0-9A-Fa-f]{4,6}$/
- RE_STRING =
NFKC_CaseFoldの00ADのように、空文字列を値に持つStringプロパティも存在するため、空文字列もRE_STRINGにマッチするような実装にしてある
/^([0-9A-Fa-f]{4,6}\s*)*$/
- RE_NUMERIC =
/ ^-?\d{1,}$| # integer ^-?\d{1,}.\d{1,}$| # float ^-?\d{1,}\/\d{1,}$ # rational /x
- RE_BINARY =
/^Yes$|^Y$|^No$|^N$/
Class Method Summary collapse
- .validate_binaries(array, properties, threshold) ⇒ Object
- .validate_binaries_for_property(array, property, threshold) ⇒ Object
- .validate_binary(str, property) ⇒ Object
- .validate_codepoint(str) ⇒ Object
- .validate_codepoints(array, threshold) ⇒ Object
- .validate_enumerative(str, property) ⇒ Object
- .validate_numeric(str) ⇒ Object
- .validate_numerics(array, threshold) ⇒ Object
- .validate_range_codepoint(str) ⇒ Object
- .validate_single_codepoint(str) ⇒ Object
- .validate_string(str) ⇒ Object
- .validate_strings(array, threshold) ⇒ Object
Class Method Details
.validate_binaries(array, properties, threshold) ⇒ Object
180 181 182 |
# File 'lib/uniprop/utils.rb', line 180 def validate_binaries(array, properties, threshold) return (array.filter{validate_binary(_1, properties) }.size.to_f / array.size) > threshold end |
.validate_binaries_for_property(array, property, threshold) ⇒ Object
184 185 186 |
# File 'lib/uniprop/utils.rb', line 184 def validate_binaries_for_property(array, property, threshold) return (array.filter{validate_binary_for_property(_1, property) }.size.to_f / array.size) > threshold end |
.validate_binary(str, property) ⇒ Object
158 159 160 |
# File 'lib/uniprop/utils.rb', line 158 def validate_binary(str, property) str.match?(RE_BINARY) || property.has_alias?(str) end |
.validate_codepoint(str) ⇒ Object
142 143 144 |
# File 'lib/uniprop/utils.rb', line 142 def validate_codepoint(str) str.match?(RE_SINGLE_CODEPOINT) || str.match?(RE_RANGE_CODEPOINT) end |
.validate_codepoints(array, threshold) ⇒ Object
168 169 170 |
# File 'lib/uniprop/utils.rb', line 168 def validate_codepoints(array, threshold) return (array.filter{validate_codepoint(_1) }.size.to_f / array.size) > threshold end |
.validate_enumerative(str, property) ⇒ Object
164 165 166 |
# File 'lib/uniprop/utils.rb', line 164 def validate_enumerative(str, property) property.has_property_value?(str) end |
.validate_numeric(str) ⇒ Object
147 148 149 |
# File 'lib/uniprop/utils.rb', line 147 def validate_numeric(str) str.match?(RE_NUMERIC) end |
.validate_numerics(array, threshold) ⇒ Object
172 173 174 |
# File 'lib/uniprop/utils.rb', line 172 def validate_numerics(array, threshold) return (array.filter{validate_numeric(_1) }.size.to_f / array.size) > threshold end |
.validate_range_codepoint(str) ⇒ Object
137 138 139 |
# File 'lib/uniprop/utils.rb', line 137 def validate_range_codepoint(str) str.match?(RE_RANGE_CODEPOINT) end |
.validate_single_codepoint(str) ⇒ Object
132 133 134 |
# File 'lib/uniprop/utils.rb', line 132 def validate_single_codepoint(str) str.match?(RE_SINGLE_CODEPOINT) end |
.validate_string(str) ⇒ Object
152 153 154 |
# File 'lib/uniprop/utils.rb', line 152 def validate_string(str) str.match?(RE_STRING) end |
.validate_strings(array, threshold) ⇒ Object
176 177 178 |
# File 'lib/uniprop/utils.rb', line 176 def validate_strings(array, threshold) return (array.filter{validate_string(_1) }.size.to_f / array.size) > threshold end |