mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 13:21:01 +00:00
Verify classifer counts
This commit is contained in:
@@ -68,6 +68,15 @@ module Linguist
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: Verify internal counts are consistent.
|
||||||
|
#
|
||||||
|
# Returns Boolean.
|
||||||
|
def verify
|
||||||
|
@languages.inject(0) { |n, (l, c)| n += c } == @languages_total &&
|
||||||
|
@language_tokens.inject(0) { |n, (l, c)| n += c } == @tokens_total &&
|
||||||
|
@tokens.inject(0) { |n, (l, ts)| n += ts.inject(0) { |m, (t, c)| m += c } } == @tokens_total
|
||||||
|
end
|
||||||
|
|
||||||
# Public: Prune infrequent tokens.
|
# Public: Prune infrequent tokens.
|
||||||
#
|
#
|
||||||
# Returns receiver Classifier instance.
|
# Returns receiver Classifier instance.
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ class TestClassifier < Test::Unit::TestCase
|
|||||||
assert results.first[1] < 0.5, results.first.inspect
|
assert results.first[1] < 0.5, results.first.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_verify
|
||||||
|
assert Classifier.instance.verify
|
||||||
|
end
|
||||||
|
|
||||||
def test_gc
|
def test_gc
|
||||||
Classifier.instance.gc
|
Classifier.instance.gc
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user