Class: I18nContextGenerator::ContextExtractor::ExtractionResult
- Inherits:
-
Data
- Object
- Data
- I18nContextGenerator::ContextExtractor::ExtractionResult
- Defined in:
- lib/i18n_context_generator/context_extractor/extraction_result.rb
Overview
Result for a single translation key, including evidence, review state, and run-local provider/cache telemetry.
Instance Attribute Summary collapse
-
#ambiguity_reason ⇒ Object
readonly
Returns the value of attribute ambiguity_reason.
-
#cache_hit ⇒ Object
readonly
Returns the value of attribute cache_hit.
-
#changed_location_groups ⇒ Object
readonly
Returns the value of attribute changed_location_groups.
-
#changed_locations ⇒ Object
readonly
Returns the value of attribute changed_locations.
-
#changed_translation_locations ⇒ Object
readonly
Returns the value of attribute changed_translation_locations.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#input_tokens ⇒ Object
readonly
Returns the value of attribute input_tokens.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#locations ⇒ Object
readonly
Returns the value of attribute locations.
-
#max_length ⇒ Object
readonly
Returns the value of attribute max_length.
-
#output_tokens ⇒ Object
readonly
Returns the value of attribute output_tokens.
-
#request_count ⇒ Object
readonly
Returns the value of attribute request_count.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#tone ⇒ Object
readonly
Returns the value of attribute tone.
-
#translation_key ⇒ Object
readonly
Returns the value of attribute translation_key.
-
#ui_element ⇒ Object
readonly
Returns the value of attribute ui_element.
Instance Method Summary collapse
- #actionable? ⇒ Boolean
-
#initialize(key:, text:, description:, **attributes) ⇒ ExtractionResult
constructor
A new instance of ExtractionResult.
- #to_h ⇒ Object
Constructor Details
#initialize(key:, text:, description:, **attributes) ⇒ ExtractionResult
Returns a new instance of ExtractionResult.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 13 def initialize(key:, text:, description:, **attributes) defaults = { source_file: nil, ui_element: nil, tone: nil, max_length: nil, locations: [], changed_locations: [], changed_location_groups: [], translation_key: key, changed_translation_locations: [], confidence: nil, ambiguity_reason: nil, cache_hit: false, request_count: 0, input_tokens: 0, output_tokens: 0, retries: 0, status: attributes[:error] ? :error : :success, error: nil } values = defaults.merge(attributes) values[:status] = values[:status].to_sym if values[:status].respond_to?(:to_sym) super(key: key, text: text, description: description, **values) end |
Instance Attribute Details
#ambiguity_reason ⇒ Object (readonly)
Returns the value of attribute ambiguity_reason
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def ambiguity_reason @ambiguity_reason end |
#cache_hit ⇒ Object (readonly)
Returns the value of attribute cache_hit
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def cache_hit @cache_hit end |
#changed_location_groups ⇒ Object (readonly)
Returns the value of attribute changed_location_groups
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def changed_location_groups @changed_location_groups end |
#changed_locations ⇒ Object (readonly)
Returns the value of attribute changed_locations
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def changed_locations @changed_locations end |
#changed_translation_locations ⇒ Object (readonly)
Returns the value of attribute changed_translation_locations
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def changed_translation_locations @changed_translation_locations end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def confidence @confidence end |
#description ⇒ Object (readonly)
Returns the value of attribute description
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def description @description end |
#error ⇒ Object (readonly)
Returns the value of attribute error
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def error @error end |
#input_tokens ⇒ Object (readonly)
Returns the value of attribute input_tokens
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def input_tokens @input_tokens end |
#key ⇒ Object (readonly)
Returns the value of attribute key
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def key @key end |
#locations ⇒ Object (readonly)
Returns the value of attribute locations
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def locations @locations end |
#max_length ⇒ Object (readonly)
Returns the value of attribute max_length
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def max_length @max_length end |
#output_tokens ⇒ Object (readonly)
Returns the value of attribute output_tokens
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def output_tokens @output_tokens end |
#request_count ⇒ Object (readonly)
Returns the value of attribute request_count
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def request_count @request_count end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def retries @retries end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def source_file @source_file end |
#status ⇒ Object (readonly)
Returns the value of attribute status
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def status @status end |
#text ⇒ Object (readonly)
Returns the value of attribute text
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def text @text end |
#tone ⇒ Object (readonly)
Returns the value of attribute tone
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def tone @tone end |
#translation_key ⇒ Object (readonly)
Returns the value of attribute translation_key
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def translation_key @translation_key end |
#ui_element ⇒ Object (readonly)
Returns the value of attribute ui_element
7 8 9 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 7 def ui_element @ui_element end |
Instance Method Details
#actionable? ⇒ Boolean
39 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 39 def actionable? = status == :success && error.nil? && !description.to_s.strip.empty? |
#to_h ⇒ Object
41 42 43 |
# File 'lib/i18n_context_generator/context_extractor/extraction_result.rb', line 41 def to_h members.to_h { |member| [member, public_send(member)] } end |