From 7562c69189805a0d765f687e36348e4fd55ab39c Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Tue, 1 Sep 2015 12:36:19 -0700 Subject: [PATCH] Revert change merging embedded metadata. --- lib/rdf/tabular/metadata.rb | 54 ------------------------------------- lib/rdf/tabular/reader.rb | 3 --- 2 files changed, 57 deletions(-) diff --git a/lib/rdf/tabular/metadata.rb b/lib/rdf/tabular/metadata.rb index 39d3812..995ab9e 100644 --- a/lib/rdf/tabular/metadata.rb +++ b/lib/rdf/tabular/metadata.rb @@ -1067,60 +1067,6 @@ def verify_compatible!(other) true end - # Merge metadata into self. This is used only to merge embedded annotations into found metadata. This is limited to titles right now. - def merge!(metadata) - raise "Merging non-equivalent metadata types: #{self.class} vs #{metadata.class}" unless self.class == metadata.class - - case self - when Table - # Normalize A (this) and B (metadata) values into normal form - self.normalize! - metadata = metadata.dup.normalize! - if !self.tableSchema - self.tableSchema = metadata.tableSchema.dup - else - self.tableSchema.merge!(metadata.tableSchema) - end - when Schema - # Merge columns - if !self.columns - self.columns = metadata.columns.dup - else - metadata.columns.each_with_index do |cb, index| - if !(ca = object[:columns][index]) - object[:columns][index] = cb.dup - else - ca.merge!(cb) - end - end - end - when Column - # Add titles, only if no titles are defined - if !(a = object[:titles]) - object[:titles] = metadata.titles - else - b = metadata.titles - debug("merge!: natural_language") { - "A: #{a.inspect}, B: #{b.inspect}" - } - b.each do |k, v| - a[k] = Array(a[k]) + (Array(b[k]) - Array(a[k])) - end - # eliminate titles with no language where the same string exists with a language - #if a.has_key?("und") - # a["und"] = a["und"].reject do |v| - # a.any? {|lang, values| lang != 'und' && values.include?(v)} - # end - # a.delete("und") if a["und"].empty? - #end - object[:titles] = a - end - end - - debug("merge!") {self.inspect} - self - end - def inspect self.class.name + (respond_to?(:to_atd) ? to_atd : object).inspect end diff --git a/lib/rdf/tabular/reader.rb b/lib/rdf/tabular/reader.rb index a5ed5fc..27c94af 100644 --- a/lib/rdf/tabular/reader.rb +++ b/lib/rdf/tabular/reader.rb @@ -100,9 +100,6 @@ def initialize(input = $stdin, options = {}, &block) if (@metadata = @options[:metadata]) && @metadata.tableSchema @metadata.verify_compatible!(embedded_metadata) - - # Add embedded annotations to metadata - @metadata.merge!(embedded_metadata) else @metadata = embedded_metadata.normalize! end