mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Verify classifer counts
This commit is contained in:
		@@ -68,6 +68,15 @@ module Linguist
 | 
			
		||||
      nil
 | 
			
		||||
    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.
 | 
			
		||||
    #
 | 
			
		||||
    # Returns receiver Classifier instance.
 | 
			
		||||
 
 | 
			
		||||
@@ -55,6 +55,10 @@ class TestClassifier < Test::Unit::TestCase
 | 
			
		||||
    assert results.first[1] < 0.5, results.first.inspect
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_verify
 | 
			
		||||
    assert Classifier.instance.verify
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_gc
 | 
			
		||||
    Classifier.instance.gc
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user