# encoding: utf-8 require "spec_helper" describe TextNlp::Pattern do context "with normalize option" do it "should match or not the pattern" do pattern = TextNlp::Pattern.new("(BD OR 'bande dessinée') AND -samsung") pattern.match?("cette BD est super").should be_true pattern.match?("cette bd est illisible sur samsung NTC").should be_false pattern.match?("cette bande dessinee est illisible sur samsung NTC").should be_false pattern.match?("cette bande dessinee est illisible").should be_true pattern = TextNlp::Pattern.new("'toulouse fc' OR ((toulouse OR tfc) AND (foot OR football OR 'ligue 1' OR 'ligue 2' OR l1 OR l2))") pattern.match?("toulouse est une belle ville").should be_false end end context "with no normalized option" do it "should match or not the pattern" do pattern = TextNlp::Pattern.new("(BD OR 'bande dessinée') AND -samsung", :normalize => false) pattern.match?("cette BD est super").should be_true pattern.match?("cette bd est super").should be_false pattern.match?("cette bande dessinee est illisible").should be_false pattern.match?("cette bande dessinée est illisible").should be_true pattern.match?("cette bande dessinée est illisible sur samsung").should be_false end end end