Class: Manticore::Client::Highlight
- Inherits:
-
Object
- Object
- Manticore::Client::Highlight
- Defined in:
- lib/manticore/client/models/highlight.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#after_match ⇒ Object
Text inserted after the matched term, typically used for HTML formatting.
-
#allow_empty ⇒ Object
Permits an empty string to be returned as the highlighting result.
-
#around ⇒ Object
Number of words around the match to include in the highlight.
-
#before_match ⇒ Object
Text inserted before the match, typically used for HTML formatting.
-
#emit_zones ⇒ Object
Emits an HTML tag with the enclosing zone name before each highlighted snippet.
-
#encoder ⇒ Object
If set to ‘html’, retains HTML markup when highlighting.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#force_all_words ⇒ Object
Ignores the length limit until the result includes all keywords.
-
#force_snippets ⇒ Object
Forces snippet generation even if limits allow highlighting the entire text.
-
#fragment_size ⇒ Object
Maximum size of the text fragments in highlighted snippets per field.
-
#highlight_query ⇒ Object
Returns the value of attribute highlight_query.
-
#html_strip_mode ⇒ Object
Defines the mode for handling HTML markup in the highlight.
-
#limit ⇒ Object
Maximum size of snippets per field.
-
#limit_snippets ⇒ Object
Maximum number of snippets per field.
-
#limit_words ⇒ Object
Maximum number of words per field.
-
#limits_per_field ⇒ Object
Determines whether the ‘limit’, ‘limit_words’, and ‘limit_snippets’ options operate as individual limits in each field of the document.
-
#no_match_size ⇒ Object
If set to 1, allows an empty string to be returned as a highlighting result.
-
#number_of_fragments ⇒ Object
Total number of highlighted fragments per field.
-
#order ⇒ Object
Sets the sorting order of highlighted snippets.
-
#post_tags ⇒ Object
Text inserted after each highlighted snippet.
-
#pre_tags ⇒ Object
Text inserted before each highlighted snippet.
-
#start_snippet_id ⇒ Object
Sets the starting value of the %SNIPPET_ID% macro.
-
#use_boundaries ⇒ Object
Defines whether to additionally break snippets by phrase boundary characters.
Class Method Summary collapse
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3).
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Highlight
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Highlight
Initializes the object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/manticore/client/models/highlight.rb', line 191 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Manticore::Client::Highlight` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Manticore::Client::Highlight`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'fragment_size') self.fragment_size = attributes[:'fragment_size'] end if attributes.key?(:'limit') self.limit = attributes[:'limit'] end if attributes.key?(:'limit_snippets') self.limit_snippets = attributes[:'limit_snippets'] end if attributes.key?(:'limit_words') self.limit_words = attributes[:'limit_words'] end if attributes.key?(:'number_of_fragments') self.number_of_fragments = attributes[:'number_of_fragments'] end if attributes.key?(:'after_match') self.after_match = attributes[:'after_match'] else self.after_match = '</strong>' end if attributes.key?(:'allow_empty') self.allow_empty = attributes[:'allow_empty'] end if attributes.key?(:'around') self.around = attributes[:'around'] end if attributes.key?(:'before_match') self.before_match = attributes[:'before_match'] else self.before_match = '<strong>' end if attributes.key?(:'emit_zones') self.emit_zones = attributes[:'emit_zones'] end if attributes.key?(:'encoder') self.encoder = attributes[:'encoder'] end if attributes.key?(:'fields') self.fields = attributes[:'fields'] end if attributes.key?(:'force_all_words') self.force_all_words = attributes[:'force_all_words'] end if attributes.key?(:'force_snippets') self.force_snippets = attributes[:'force_snippets'] end if attributes.key?(:'highlight_query') self.highlight_query = attributes[:'highlight_query'] end if attributes.key?(:'html_strip_mode') self.html_strip_mode = attributes[:'html_strip_mode'] end if attributes.key?(:'limits_per_field') self.limits_per_field = attributes[:'limits_per_field'] end if attributes.key?(:'no_match_size') self.no_match_size = attributes[:'no_match_size'] end if attributes.key?(:'order') self.order = attributes[:'order'] end if attributes.key?(:'pre_tags') self. = attributes[:'pre_tags'] else self. = '<strong>' end if attributes.key?(:'post_tags') self. = attributes[:'post_tags'] else self. = '</strong>' end if attributes.key?(:'start_snippet_id') self.start_snippet_id = attributes[:'start_snippet_id'] end if attributes.key?(:'use_boundaries') self.use_boundaries = attributes[:'use_boundaries'] end end |
Instance Attribute Details
#after_match ⇒ Object
Text inserted after the matched term, typically used for HTML formatting
34 35 36 |
# File 'lib/manticore/client/models/highlight.rb', line 34 def after_match @after_match end |
#allow_empty ⇒ Object
Permits an empty string to be returned as the highlighting result. Otherwise, the beginning of the original text would be returned
37 38 39 |
# File 'lib/manticore/client/models/highlight.rb', line 37 def allow_empty @allow_empty end |
#around ⇒ Object
Number of words around the match to include in the highlight
40 41 42 |
# File 'lib/manticore/client/models/highlight.rb', line 40 def around @around end |
#before_match ⇒ Object
Text inserted before the match, typically used for HTML formatting
43 44 45 |
# File 'lib/manticore/client/models/highlight.rb', line 43 def before_match @before_match end |
#emit_zones ⇒ Object
Emits an HTML tag with the enclosing zone name before each highlighted snippet
46 47 48 |
# File 'lib/manticore/client/models/highlight.rb', line 46 def emit_zones @emit_zones end |
#encoder ⇒ Object
If set to ‘html’, retains HTML markup when highlighting
49 50 51 |
# File 'lib/manticore/client/models/highlight.rb', line 49 def encoder @encoder end |
#fields ⇒ Object
Returns the value of attribute fields.
51 52 53 |
# File 'lib/manticore/client/models/highlight.rb', line 51 def fields @fields end |
#force_all_words ⇒ Object
Ignores the length limit until the result includes all keywords
54 55 56 |
# File 'lib/manticore/client/models/highlight.rb', line 54 def force_all_words @force_all_words end |
#force_snippets ⇒ Object
Forces snippet generation even if limits allow highlighting the entire text
57 58 59 |
# File 'lib/manticore/client/models/highlight.rb', line 57 def force_snippets @force_snippets end |
#fragment_size ⇒ Object
Maximum size of the text fragments in highlighted snippets per field
19 20 21 |
# File 'lib/manticore/client/models/highlight.rb', line 19 def fragment_size @fragment_size end |
#highlight_query ⇒ Object
Returns the value of attribute highlight_query.
59 60 61 |
# File 'lib/manticore/client/models/highlight.rb', line 59 def highlight_query @highlight_query end |
#html_strip_mode ⇒ Object
Defines the mode for handling HTML markup in the highlight
62 63 64 |
# File 'lib/manticore/client/models/highlight.rb', line 62 def html_strip_mode @html_strip_mode end |
#limit ⇒ Object
Maximum size of snippets per field
22 23 24 |
# File 'lib/manticore/client/models/highlight.rb', line 22 def limit @limit end |
#limit_snippets ⇒ Object
Maximum number of snippets per field
25 26 27 |
# File 'lib/manticore/client/models/highlight.rb', line 25 def limit_snippets @limit_snippets end |
#limit_words ⇒ Object
Maximum number of words per field
28 29 30 |
# File 'lib/manticore/client/models/highlight.rb', line 28 def limit_words @limit_words end |
#limits_per_field ⇒ Object
Determines whether the ‘limit’, ‘limit_words’, and ‘limit_snippets’ options operate as individual limits in each field of the document
65 66 67 |
# File 'lib/manticore/client/models/highlight.rb', line 65 def limits_per_field @limits_per_field end |
#no_match_size ⇒ Object
If set to 1, allows an empty string to be returned as a highlighting result
68 69 70 |
# File 'lib/manticore/client/models/highlight.rb', line 68 def no_match_size @no_match_size end |
#number_of_fragments ⇒ Object
Total number of highlighted fragments per field
31 32 33 |
# File 'lib/manticore/client/models/highlight.rb', line 31 def number_of_fragments @number_of_fragments end |
#order ⇒ Object
Sets the sorting order of highlighted snippets
71 72 73 |
# File 'lib/manticore/client/models/highlight.rb', line 71 def order @order end |
#post_tags ⇒ Object
Text inserted after each highlighted snippet
77 78 79 |
# File 'lib/manticore/client/models/highlight.rb', line 77 def end |
#pre_tags ⇒ Object
Text inserted before each highlighted snippet
74 75 76 |
# File 'lib/manticore/client/models/highlight.rb', line 74 def end |
#start_snippet_id ⇒ Object
Sets the starting value of the %SNIPPET_ID% macro
80 81 82 |
# File 'lib/manticore/client/models/highlight.rb', line 80 def start_snippet_id @start_snippet_id end |
#use_boundaries ⇒ Object
Defines whether to additionally break snippets by phrase boundary characters
83 84 85 |
# File 'lib/manticore/client/models/highlight.rb', line 83 def use_boundaries @use_boundaries end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/manticore/client/models/highlight.rb', line 438 def self._deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = Manticore::Client.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
137 138 139 |
# File 'lib/manticore/client/models/highlight.rb', line 137 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
142 143 144 |
# File 'lib/manticore/client/models/highlight.rb', line 142 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/manticore/client/models/highlight.rb', line 108 def self.attribute_map { :'fragment_size' => :'fragment_size', :'limit' => :'limit', :'limit_snippets' => :'limit_snippets', :'limit_words' => :'limit_words', :'number_of_fragments' => :'number_of_fragments', :'after_match' => :'after_match', :'allow_empty' => :'allow_empty', :'around' => :'around', :'before_match' => :'before_match', :'emit_zones' => :'emit_zones', :'encoder' => :'encoder', :'fields' => :'fields', :'force_all_words' => :'force_all_words', :'force_snippets' => :'force_snippets', :'highlight_query' => :'highlight_query', :'html_strip_mode' => :'html_strip_mode', :'limits_per_field' => :'limits_per_field', :'no_match_size' => :'no_match_size', :'order' => :'order', :'pre_tags' => :'pre_tags', :'post_tags' => :'post_tags', :'start_snippet_id' => :'start_snippet_id', :'use_boundaries' => :'use_boundaries' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/manticore/client/models/highlight.rb', line 414 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3)
183 184 185 186 187 |
# File 'lib/manticore/client/models/highlight.rb', line 183 def self.openapi_all_of [ :'HighlightFieldOption' ] end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
176 177 178 179 180 |
# File 'lib/manticore/client/models/highlight.rb', line 176 def self.openapi_nullable Set.new([ :'highlight_query', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/manticore/client/models/highlight.rb', line 147 def self.openapi_types { :'fragment_size' => :'Integer', :'limit' => :'Integer', :'limit_snippets' => :'Integer', :'limit_words' => :'Integer', :'number_of_fragments' => :'Integer', :'after_match' => :'String', :'allow_empty' => :'Boolean', :'around' => :'Integer', :'before_match' => :'String', :'emit_zones' => :'Boolean', :'encoder' => :'String', :'fields' => :'HighlightAllOfFields', :'force_all_words' => :'Boolean', :'force_snippets' => :'Boolean', :'highlight_query' => :'QueryFilter', :'html_strip_mode' => :'String', :'limits_per_field' => :'Boolean', :'no_match_size' => :'Integer', :'order' => :'String', :'pre_tags' => :'String', :'post_tags' => :'String', :'start_snippet_id' => :'Integer', :'use_boundaries' => :'Boolean' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/manticore/client/models/highlight.rb', line 371 def ==(o) return true if self.equal?(o) self.class == o.class && fragment_size == o.fragment_size && limit == o.limit && limit_snippets == o.limit_snippets && limit_words == o.limit_words && number_of_fragments == o.number_of_fragments && after_match == o.after_match && allow_empty == o.allow_empty && around == o.around && before_match == o.before_match && emit_zones == o.emit_zones && encoder == o.encoder && fields == o.fields && force_all_words == o.force_all_words && force_snippets == o.force_snippets && highlight_query == o.highlight_query && html_strip_mode == o.html_strip_mode && limits_per_field == o.limits_per_field && no_match_size == o.no_match_size && order == o.order && == o. && == o. && start_snippet_id == o.start_snippet_id && use_boundaries == o.use_boundaries end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/manticore/client/models/highlight.rb', line 509 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#eql?(o) ⇒ Boolean
401 402 403 |
# File 'lib/manticore/client/models/highlight.rb', line 401 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
407 408 409 |
# File 'lib/manticore/client/models/highlight.rb', line 407 def hash [fragment_size, limit, limit_snippets, limit_words, number_of_fragments, after_match, allow_empty, around, before_match, emit_zones, encoder, fields, force_all_words, force_snippets, highlight_query, html_strip_mode, limits_per_field, no_match_size, order, , , start_snippet_id, use_boundaries].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
308 309 310 311 312 |
# File 'lib/manticore/client/models/highlight.rb', line 308 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
485 486 487 |
# File 'lib/manticore/client/models/highlight.rb', line 485 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/manticore/client/models/highlight.rb', line 491 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
479 480 481 |
# File 'lib/manticore/client/models/highlight.rb', line 479 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/manticore/client/models/highlight.rb', line 316 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' encoder_validator = EnumAttributeValidator.new('String', ["default", "html"]) return false unless encoder_validator.valid?(@encoder) html_strip_mode_validator = EnumAttributeValidator.new('String', ["none", "strip", "index", "retain"]) return false unless html_strip_mode_validator.valid?(@html_strip_mode) no_match_size_validator = EnumAttributeValidator.new('Integer', [0, 1]) return false unless no_match_size_validator.valid?(@no_match_size) order_validator = EnumAttributeValidator.new('String', ["asc", "desc", "score"]) return false unless order_validator.valid?(@order) true end |