Class: TopSecret::Filters::NER
- Inherits:
-
Object
- Object
- TopSecret::Filters::NER
- Defined in:
- lib/top_secret/filters/ner.rb
Overview
Applies Named Entity Recognition (NER) filtering based on tag and confidence score.
Instance Attribute Summary collapse
-
#label ⇒ String
readonly
The label applied to matching entities.
Instance Method Summary collapse
-
#call(entities) ⇒ Array<String>
Filters and extracts entity texts matching the tag and score threshold.
-
#initialize(label:, tag:, min_confidence_score: nil) ⇒ NER
constructor
A new instance of NER.
Constructor Details
#initialize(label:, tag:, min_confidence_score: nil) ⇒ NER
Returns a new instance of NER.
13 14 15 16 17 |
# File 'lib/top_secret/filters/ner.rb', line 13 def initialize(label:, tag:, min_confidence_score: nil) @label = label @tag = tag.upcase.to_s @min_confidence_score = min_confidence_score end |
Instance Attribute Details
#label ⇒ String (readonly)
Returns The label applied to matching entities.
8 9 10 |
# File 'lib/top_secret/filters/ner.rb', line 8 def label @label end |
Instance Method Details
#call(entities) ⇒ Array<String>
Filters and extracts entity texts matching the tag and score threshold.
23 24 25 26 |
# File 'lib/top_secret/filters/ner.rb', line 23 def call(entities) = entities.filter { _1.fetch(:tag) == tag && _1.fetch(:score) >= (min_confidence_score || TopSecret.min_confidence_score) } .map { _1.fetch(:text) } end |