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 <<anchor>> xrefs) 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.



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

def initialize(text)
  @text = text
end

Instance Method Details

#bibliography_idsObject



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

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