Class: PromptSanitizer::SanitizeResult
- Inherits:
-
Struct
- Object
- Struct
- PromptSanitizer::SanitizeResult
- Defined in:
- lib/prompt_sanitizer/result.rb
Overview
Returned by Sanitizer#sanitize and Session#anonymize_with_result.
Instance Attribute Summary collapse
-
#entities ⇒ Object
Returns the value of attribute entities.
-
#original ⇒ Object
Returns the value of attribute original.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#any? ⇒ Boolean
True if any PII was found.
-
#by_type(type) ⇒ Object
Entities filtered by type.
-
#count ⇒ Object
Number of PII entities detected.
-
#mapping ⇒ Object
Mapping of original values to their replacement tokens.
Instance Attribute Details
#entities ⇒ Object
Returns the value of attribute entities
17 18 19 |
# File 'lib/prompt_sanitizer/result.rb', line 17 def entities @entities end |
#original ⇒ Object
Returns the value of attribute original
17 18 19 |
# File 'lib/prompt_sanitizer/result.rb', line 17 def original @original end |
#text ⇒ Object
Returns the value of attribute text
17 18 19 |
# File 'lib/prompt_sanitizer/result.rb', line 17 def text @text end |
Instance Method Details
#any? ⇒ Boolean
True if any PII was found.
27 |
# File 'lib/prompt_sanitizer/result.rb', line 27 def any? = entities.any? |
#by_type(type) ⇒ Object
Entities filtered by type.
30 |
# File 'lib/prompt_sanitizer/result.rb', line 30 def by_type(type) = entities.select { |e| e.entity_type == type } |
#count ⇒ Object
Number of PII entities detected.
24 |
# File 'lib/prompt_sanitizer/result.rb', line 24 def count = entities.size |
#mapping ⇒ Object
Mapping of original values to their replacement tokens.
33 34 35 |
# File 'lib/prompt_sanitizer/result.rb', line 33 def mapping entities.each_with_object({}) { |e, h| h[e.original] = e.replacement } end |