Class: Metanorma::Plugin::Glossarist::MentionExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/plugin/glossarist/mention_extractor.rb

Overview

Extracts bibliography-citable mention IDs from concept text using Glossarist::ReferenceExtractor as the single canonical parser.

Bibliography relevance = BibliographicReference (from {{bib:id}} mentions) and ConceptReference instances whose #cite? is true (from {{cite:id}} mentions). Other mention kinds (fig/table/formula/urn) reference assets or concepts, not bibliography entries.

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ MentionExtractor

Returns a new instance of MentionExtractor.



15
16
17
# File 'lib/metanorma/plugin/glossarist/mention_extractor.rb', line 15

def initialize(text)
  @text = text
end

Instance Method Details

#bibliography_idsObject



19
20
21
22
23
# File 'lib/metanorma/plugin/glossarist/mention_extractor.rb', line 19

def bibliography_ids
  refs = ::Glossarist::ReferenceExtractor.new
    .extract_from_text(@text.to_s)
  refs.filter_map { |ref| bibliography_id(ref) }.uniq
end