Class: Openphar::Linkers::CrossPublisherLinker

Inherits:
Object
  • Object
show all
Defined in:
lib/openphar/linkers/cross_publisher_linker.rb

Overview

Links pharmacopoeia monographs across different publishers

This class identifies matching substances across pharmacopoeias (e.g., JP and Ph.Int.) by comparing CAS numbers, INN names, and chemical structures.

Constant Summary collapse

CONFIDENCE_HIGH =

Match confidence levels

0.95
CONFIDENCE_MEDIUM =

CAS + INN match

0.80
CONFIDENCE_LOW =

CAS or INN match

0.60

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jp_data_path:, phint_data_path:, output_path:) ⇒ CrossPublisherLinker

Returns a new instance of CrossPublisherLinker.

Parameters:

  • jp_data_path (String)

    Path to JP monographs JSON-LD file

  • phint_data_path (String)

    Path to Ph.Int. monographs JSON-LD file

  • output_path (String)

    Output path for cross-publisher links



23
24
25
26
27
28
29
30
31
# File 'lib/openphar/linkers/cross_publisher_linker.rb', line 23

def initialize(jp_data_path:, phint_data_path:, output_path:)
  @jp_data_path = jp_data_path
  @phint_data_path = phint_data_path
  @output_path = output_path
  @jp_monographs = []
  @phint_monographs = []
  @links = []
  @stats = { total: 0, matches: 0, by_method: Hash.new(0) }
end

Instance Attribute Details

#jp_dataObject (readonly)

Returns the value of attribute jp_data.



13
14
15
# File 'lib/openphar/linkers/cross_publisher_linker.rb', line 13

def jp_data
  @jp_data
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



13
14
15
# File 'lib/openphar/linkers/cross_publisher_linker.rb', line 13

def output_path
  @output_path
end

#phint_dataObject (readonly)

Returns the value of attribute phint_data.



13
14
15
# File 'lib/openphar/linkers/cross_publisher_linker.rb', line 13

def phint_data
  @phint_data
end

Instance Method Details

#runHash

Run the linking process

Returns:

  • (Hash)

    Statistics about the linking



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/openphar/linkers/cross_publisher_linker.rb', line 35

def run
  puts "Starting cross-publisher linking..."
  puts "  JP data: #{@jp_data_path}"
  puts "  Ph.Int. data: #{@phint_data_path}"

  # Load data
  load_data

  # Build indices for efficient lookup
  build_indices

  # Find matches
  find_matches

  # Generate output
  generate_links_file

  # Print statistics
  print_statistics

  @stats
end