Sha256: 818fa09cd977b45f9ddd3a34496cf41a3aa9455403ec5bfb88387813db4dbc8c

Contents?: true

Size: 1.65 KB

Versions: 31

Compression:

Stored size: 1.65 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

describe "partial automatic splitting with small partials" do
  
  let(:index) do
    index = Picky::Index.new :automatic_text_splitting do
      indexing removes_characters: /[^a-z\s]/i,
               stopwords: /\b(in|a)\b/
      category :text,
                partial: Picky::Partial::Postfix.new(from: 1)
    end
    index.replace_from id: 1, text: 'Rainbow'
    index
  end

  context 'splitting the text automatically' do
    let(:automatic_splitter) {
      Picky::Splitters::Automatic.new index[:text], partial: true }
    
    # It splits the text correctly.
    #
    it do
      automatic_splitter.segment('rainbow', true).should == [
        ['rainbow'],
        0.0
      ]
    end
  end
  
  context 'splitting the text automatically' do
    let(:automatic_splitter) { Picky::Splitters::Automatic.new index[:text], partial: true }
    
    # It splits the text correctly.
    #
    it { automatic_splitter.split('rainbowrainbow').should == ['rainbow', 'rainbow'] }
    it { automatic_splitter.split('rainbowrain').should == ['rainbow', 'rain'] }
    it { automatic_splitter.split('rain').should == ['rain'] }
    
    # When it can't, it splits it using the partial index (correctly).
    #
    it { automatic_splitter.split('r').should == ['r'] }
    it { automatic_splitter.split('rr').should == ['r', 'r'] }
    it { automatic_splitter.split('rrr').should == ['r', 'r', 'r'] }
    it { automatic_splitter.split('rrrr').should  == ['r', 'r', 'r', 'r'] }
    
    it { automatic_splitter.split('rarara').should == ['ra', 'ra', 'ra'] }
    it { automatic_splitter.split('rainrairar').should  == ['rain', 'rai', 'ra', 'r'] }
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
picky-4.22.0 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.21.2 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.21.1 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.21.0 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.20.2 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.20.1 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.20.0 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.19.7 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.19.6 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.19.5 spec/functional/automatic_segmentation_with_small_partials_spec.rb
picky-4.19.4 spec/functional/automatic_segmentation_with_small_partials_spec.rb