Sha256: 034ce6188d3d5d9b2eac8d7fb6c064712aa980628f27118e78149d0c52e6c86a
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# encoding: utf-8 require "spec_helper" describe String do before(:each) { String.normalizer = nil; String.tokenizer = nil; } it "should call normalizer" do text = "TOTO" normalizer = double() String.normalizer = normalizer normalizer.stub(:normalize) { |txt| txt.downcase } normalizer.should_receive(:normalize).with(text) text = text.normalize text.should eq "TOTO".downcase normalizer.should_not_receive(:normalize).with(text) text.normalize.should eq "TOTO".downcase end it "should call tokenizer" do text = "TOTO" tokenizer = double() String.tokenizer = tokenizer tokenizer.should_receive(:tokenize).with(text) text.tokenize end it "should call translator" do text = "TOTO" translator = double() translator.should_receive(:translate).with(text) text.translate(translator) end it "should compute similarity" do "il fait chaud".similarity("il fait chaud").should eq 1.0 "il fait chaud".similarity("putin c nul ici").should eq 0.0 "il fait chaud".similarity("youhou ca le fait").should be_within(0.01).of(0.29) "".similarity("il fait chaud").should eq 0.0 "il fait chaud".similarity("").should eq 0.0 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
text_nlp-0.0.2 | spec/string_spec.rb |