Class: Rlid::TestProbabilities
- Inherits:
-
LanguageProbabilities
- Object
- LanguageProbabilities
- Rlid::TestProbabilities
- Defined in:
- lib/rlid/probabilities/language_probabilities.rb
Constant Summary
Constants inherited from LanguageProbabilities
LanguageProbabilities::CLASSNAME, LanguageProbabilities::MAX_OUTPUT
Instance Method Summary collapse
-
#initialize(lang, perc_lang = 0.8, perc_lang_and_common = 0.98) ⇒ TestProbabilities
constructor
A new instance of TestProbabilities.
-
#probabilities ⇒ Object
common = [] @common_size.times do common << probs.random_language_and_delete end other = [] @other_size.times do other << probs.random_language_and_delete end.
- #random_permutation ⇒ Object
Methods inherited from LanguageProbabilities
#*, #[], #first, #random_language, #to_a, #to_html, #to_s
Constructor Details
#initialize(lang, perc_lang = 0.8, perc_lang_and_common = 0.98) ⇒ TestProbabilities
Returns a new instance of TestProbabilities.
154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/rlid/probabilities/language_probabilities.rb', line 154 def initialize(lang, perc_lang=0.8, perc_lang_and_common=0.98) @lang = lang @perc_lang = perc_lang common = COMMON_LANGUAGES - [lang] other = LANGUAGES - COMMON_LANGUAGES - [lang] @common_size = common.size @other_size = other.size @perc_common = perc_lang_and_common - perc_lang @perc_other = 1 - perc_lang_and_common super(lang => @perc_lang, common => @perc_common, other => @perc_other) end |
Instance Method Details
#probabilities ⇒ Object
common = []
@common_size.times do
common << probs.random_language_and_delete
end
other = []
@other_size.times do
other << probs.random_language_and_delete
end
LanguageProbabilities.new(
lang => @perc_lang,
common => @perc_common,
other => @perc_other)
194 195 196 |
# File 'lib/rlid/probabilities/language_probabilities.rb', line 194 def probabilities LanguageProbabilities.new(percentage) end |
#random_permutation ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/rlid/probabilities/language_probabilities.rb', line 166 def random_permutation lang = random_language return self if lang == @lang probs = probabilities top_lang = probs.first probs.percentage[lang], probs.percentage[top_lang] = probs.percentage[top_lang], probs.percentage[lang] probs end |