Sha256: 876ccc4d8fdadae8cbbe1ea41eee197fe6acd21d14f6a9da62758d0fe26f0b82

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# coding: utf-8
require 'spec_helper'

module TfIdfSimilarity
  describe Token do
    describe '#valid?' do
      it 'should return false if all of its characters are numbers, punctuation or whitespace characters' do
        Token.new('1 2 3 ! @ #').valid?.should == false
      end

      it 'should return true if not all of its characters are numbers, punctuation or whitespace characters' do
        Token.new('1 2 3 ! @ # a').valid?.should == true
      end
    end

    describe '#lowercase_filter' do
      it 'should lowercase the token' do
        Token.new('HÉTÉROGÉNÉITÉ').lowercase_filter.should == 'hétérogénéité'
      end
    end

    describe '#classic_filter' do
      it 'should remove all periods' do
        Token.new('X.Y.Z.').classic_filter.should == 'XYZ'
      end

      it 'should remove ending possessives' do
        Token.new("foo's").classic_filter.should == 'foo'
      end

      it 'should not remove infix possessives' do
        Token.new("foo's bar").classic_filter.should == "foo's bar"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tf-idf-similarity-0.1.4 spec/token_spec.rb