Skip to content

Commit 7b64154

Browse files
yaronskayaanatolystansler
authored andcommitted
feat: probas for langs with small number of libraries(#239) (#252)
1 parent d161d08 commit 7b64154

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/kotlin/app/extractors/ExtractorInterface.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ interface ExtractorInterface {
203203
probabilities[libraries.indexOf(it)] >= 0.2 * maxProbability
204204
}
205205

206+
// For languages with small number of libraries(e.g. less than 20).
207+
// When found high probability then there won't be two or more
208+
// values with high probability. And vise versa,
209+
// if several values with high probability are found
210+
// then the prediction is unsure. So we don't take them into account.
211+
if (libraries.size < 20 && selectedCategories.size > 1) {
212+
return emptyList()
213+
}
214+
206215
if (maxProbabilityCategory == languageLabel) {
207216
return emptyList()
208217
}

src/test/kotlin/test/tests/extractors/ExtractorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ExtractorTest : Spek({
112112
}
113113

114114
it("ruby extractor extracts rails") {
115-
val line = "class Article < ApplicationRecord"
115+
val line = "class Article < ActiveRecord::Base"
116116
assertExtractsLineLibraries("rails",
117117
line, RubyExtractor())
118118
}

0 commit comments

Comments
 (0)