This repository was archived by the owner on Jan 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
spec/cipherstash/analysis Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ def build_token_filters(array)
4646 TokenFilters ::Downcase . new ( obj )
4747
4848 when "ngram"
49+ if obj [ "tokenLength" ]
50+ raise CipherStash ::Client ::Error ::InternalError , "'tokenLength' is deprecated. Use 'minLength' and 'maxLength' for the ngram filter."
51+ end
52+
4953 unless obj [ "minLength" ] . instance_of? ( Integer ) && obj [ "maxLength" ] . instance_of? ( Integer )
5054 raise CipherStash ::Client ::Error ::InternalError , "The values provided to the min and max length must be of type Integer."
5155 end
Original file line number Diff line number Diff line change 4444 } . to raise_error ( CipherStash ::Client ::Error ::InternalError , "The ngram filter min length must be less than or equal to the max length" )
4545 end
4646
47+ it "raises an error if tokenLength is provided" do
48+ expect {
49+ CipherStash ::Analysis ::TextProcessor . new ( {
50+ "tokenFilters" => [
51+ { "kind" => "downcase" } ,
52+ { "kind" => "ngram" , "tokenLength" => 3 }
53+ ] ,
54+ "tokenizer" => { "kind" => "standard" }
55+ } )
56+ } . to raise_error ( CipherStash ::Client ::Error ::InternalError , "'tokenLength' is deprecated. Use 'minLength' and 'maxLength' for the ngram filter." )
57+ end
58+
4759 it "splits text into ngrams using min length of 3 and max length of 8" do
4860 tokenizer =
4961 CipherStash ::Analysis ::TextProcessor . new ( {
You can’t perform that action at this time.
0 commit comments