<commit_before>require 'nokogiri'
require 'whats_opt/mda_importer'

module WhatsOpt 
    
  class CmdowsMdaImporter < MdaImporter
  
    class CmdowsValidationError < StandardError
    end
    
    class ImportError < StandardError
    end
    
    SCHEMA_FILE = File.join(File.dirname(__FILE__), 'cmdows.xsd')
    XSD = Nokogiri::XML::Schema(File.read(SCHEMA_FILE))
    
    def initialize(filename, mda_name=nil)
      @filename = filename
      @mda_name = mda_name || File.basename(@filename, '.cmdows')
      @doc = Nokogiri::XML(File.read(filename))
      XSD.validate(@doc).each do |error|
        raise CmdowsValidationError.new(error.message)
      end
    end
    
    def get_mda_attributes
      {name: @mda_name}
    end 
    
    def get_disciplines_attributes
      discattrs = []
      disc_ids = @doc.xpath('//designCompetence/@uID').map(&:content)
      disc_ids.each do |duid|<commit_msg>fix MDA default name<commit_after>require 'nokogiri'
require 'whats_opt/mda_importer'

module WhatsOpt 
    
  class CmdowsMdaImporter < MdaImporter
  
    class CmdowsValidationError < StandardError
    end
    
    class ImportError < StandardError
    end
    
    SCHEMA_FILE = File.join(File.dirname(__FILE__), 'cmdows.xsd')
    XSD = Nokogiri::XML::Schema(File.read(SCHEMA_FILE))
    
    def initialize(filename, mda_name=nil)
      @filename = filename
      @mda_name = mda_name || File.basename(@filename, '.cmdows').camelcase
      @doc = Nokogiri::XML(File.read(filename))
      XSD.validate(@doc).each do |error|
        raise CmdowsValidationError.new(error.message)
      end
    end
    
    def get_mda_attributes
      {name: @mda_name}
    end 
    
    def get_disciplines_attributes
      discattrs = []
      disc_ids = @doc.xpath('//designCompetence/@uID').map(&:content)
      disc_ids.each do |duid|
{'fraction_non_alphanumeric': 0.10540688148552703, 'fraction_numerical': 0.0, 'mean_word_length': 3.008752735229759, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6421691', 'n_tokens_mistral': 640, 'n_tokens_neox': 627, 'n_words': 108}