class Vellum::SearchResult

def self.from_json(json_object:)

Returns:
  • (SearchResult) -

Parameters:
  • json_object (JSON) --
def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  text = struct.text
  score = struct.score
  keywords = struct.keywords
  if parsed_json["document"].nil?
    document = nil
  else
    document = parsed_json["document"].to_json
    document = SearchResultDocument.from_json(json_object: document)
  end
  new(text: text, score: score, keywords: keywords, document: document, additional_properties: struct)
end

def self.validate_raw(obj:)

Returns:
  • (Void) -

Parameters:
  • obj (Object) --
def self.validate_raw(obj:)
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
  obj.score.is_a?(Float) != false || raise("Passed value for field obj.score is not the expected type, validation failed.")
  obj.keywords.is_a?(Array) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.")
  SearchResultDocument.validate_raw(obj: obj.document)
end

def initialize(text:, score:, keywords:, document:, additional_properties: nil)

Returns:
  • (SearchResult) -

Parameters:
  • additional_properties (OpenStruct) -- Additional properties unmapped to the current class definition
  • document (SearchResultDocument) -- The document that contains the chunk that matched the search query.
  • keywords (Array) --
  • score (Float) -- A score representing how well the chunk matches the search query.
  • text (String) -- The text of the chunk that matched the search query.
def initialize(text:, score:, keywords:, document:, additional_properties: nil)
  # @type [String] The text of the chunk that matched the search query.
  @text = text
  # @type [Float] A score representing how well the chunk matches the search query.
  @score = score
  # @type [Array<String>]
  @keywords = keywords
  # @type [SearchResultDocument] The document that contains the chunk that matched the search query.
  @document = document
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

def to_json(*_args)

Returns:
  • (JSON) -
def to_json(*_args)
  { "text": @text, "score": @score, "keywords": @keywords, "document": @document }.to_json
end