Sha256: d7fd97659504b590ba5381c04efba9a98e1510a60d8c0fe36c6a65a8054c3973

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module ChemScanner
  module Interpreter
    using Extension

    module PostProcess
      def replace_label_by_molecule
        @reactions.each do |r|
          @arrow_map[r.arrow_id].text_arr.each do |tid|
            text = @text_map[tid]

            bolds = text.bold_text.strip.split(ABB_DELIM).reject(&:empty?)
            bolds.each do |bold|
              mol = @mol_map.detect { |_, m| m.label == bold }
              next if mol.nil?

              mid = mol[0]
              r.reagent_ids.push(mid) unless r.reagent_ids.include?(mid)
            end

            non_bolds = text.non_bold_text.strip.split(ABB_DELIM)
            non_bolds.reject(&:empty?).each do |plain|
              next if plain.length < 3 || !(plain =~ /eq(uiv)?\.?/).nil?

              mol = @mol_map.detect { |_, m| m.text.strip == plain.strip }
              next if mol.nil?

              mid = mol[0]
              r.reagent_ids.push(mid) unless r.reagent_ids.include?(mid)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chem_scanner-0.1.3 lib/chem_scanner/interpreter/post_process/label_by_molecule.rb