Class: LangExtract::Core::Annotator
- Inherits:
-
Object
- Object
- LangExtract::Core::Annotator
- Defined in:
- lib/langextract/core/annotation.rb
Instance Method Summary collapse
- #annotate(document:, extraction_hashes:, preferred_interval: nil) ⇒ Object
-
#initialize(tokenizer: UnicodeTokenizer.new, fuzzy_threshold: Resolver::DEFAULT_FUZZY_THRESHOLD, suppress_alignment_errors: true) ⇒ Annotator
constructor
A new instance of Annotator.
Constructor Details
#initialize(tokenizer: UnicodeTokenizer.new, fuzzy_threshold: Resolver::DEFAULT_FUZZY_THRESHOLD, suppress_alignment_errors: true) ⇒ Annotator
Returns a new instance of Annotator.
8 9 10 11 12 13 |
# File 'lib/langextract/core/annotation.rb', line 8 def initialize(tokenizer: UnicodeTokenizer.new, fuzzy_threshold: Resolver::DEFAULT_FUZZY_THRESHOLD, suppress_alignment_errors: true) @tokenizer = tokenizer @fuzzy_threshold = fuzzy_threshold @suppress_alignment_errors = suppress_alignment_errors end |
Instance Method Details
#annotate(document:, extraction_hashes:, preferred_interval: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/langextract/core/annotation.rb', line 15 def annotate(document:, extraction_hashes:, preferred_interval: nil) resolver = Resolver.new( text: document.text, tokenizer: tokenizer, fuzzy_threshold: fuzzy_threshold, suppress_alignment_errors: suppress_alignment_errors ) extractions = resolver.resolve( extraction_hashes, document_id: document.id, preferred_interval: preferred_interval ) AnnotatedDocument.new(document: document, extractions: extractions) end |