Improves handling of non-fiction classification data.
[quanlib.git] / classify / classset.rb
index 710db7a3c89633c1cc7afbd28839de91b3ecdd59..4613fc746ee8ec5fe5c9d7052e806592ca916a7e 100644 (file)
@@ -67,16 +67,18 @@ class ClassSet
           lcc = row[1]
           grouping = row[2]
           author = row[3]
-          title = row[4]
+          filename = row[4]
+          title = row[5]
           fast = []
-          if nil != row[5]
-            fast = row[5].split(';')
+          if nil != row[6]
+            fast = row[6].split(';')
           end
   
           bookclass = BookClass.new(grouping, title)
           bookclass.ddc = ddc
           bookclass.lcc = lcc
           bookclass.author = author
+          bookclass.filename = filename
   
           fast.each do |id|
             bookclass.add_fast(id)
@@ -84,6 +86,8 @@ class ClassSet
   
           key = construct_key(grouping, title)
           @entries[key] = bookclass
+
+          #puts 'LOADED[' + key.inspect + ']: ' + bookclass.inspect
         end
       end
     end
@@ -91,24 +95,22 @@ class ClassSet
 
   def save(file_name)
     CSV.open(file_name, 'w:UTF-8') do |csv|
-      csv << ['Dewey', 'LCC', 'Grouping', 'Author', 'Title', 'FAST']
+      csv << ['Dewey', 'LCC', 'Grouping', 'Author', 'Filename', 'Title', 'FAST']
 
       @entries.keys.sort.each do |key|
         info = @entries[key]
 
+        #puts 'SAVING[' + key.inspect + ']: ' + info.inspect
+
         ddc = info.ddc
         lcc = info.lcc
         grouping = info.grouping
         author = info.author
+        filename = info.filename
         title = info.title
-        fast_list = info.fast
-        fast_ids = []
-        fast_list.each do |tuple|
-          fast_ids.push(tuple[0])
-        end
-        fast = fast_ids.join(';')
+        fast = info.fast.join(';')
         
-        csv << [ ddc, lcc, grouping, author, title, fast ]
+        csv << [ ddc, lcc, grouping, author, filename, title, fast ]
       end
     end
   end