<commit_before>module Radian6
  class Topic
    attr_accessor :name, :groups, :id
    
    def initialize(params)
      @name = params[:name]
      @groups   = params[:groups]
      @id       = params[:id]
    end

    def self.system_topics
      # Replace with topic grabbing code!
      t1 = new(:id => 1, :name => 'iPhone', :groups => 'Foos')
      t2 = new(:id => 2, :name => 'Android', :groups => 'Bars')
      t3 = new(:id => 3, :name => 'Nokia', :groups => 'Zoos')
      [t1, t2, t3]
    end

    def self.from_xml(xml)
      doc = Nokogiri::XML(xml)
      xml_topics = doc.root.xpath('//topicFilters/topicFilter')
      topics = []
      xml_topics.each_with_index do |xml_topic, index|
        groups = []
        xml_topic.xpath('./filterGroups/filterGroup').each do |xml_group|
          queries = []
          xml_group.xpath('./filterQueries/filterQuery').each do |xml_query|
            queries << FilterQuery.new({
              :id             => xml_query.xpath('./filterQueryId').text,
              :query          => xml_query.xpath('./query').text,
              :isExcludeQuery => xml_query.xpath('./filterQueryTypeId').text
            })
          end
          
          groups << FilterGroup.new({
            :name     => xml_group.xpath('./name').text,<commit_msg>- Use a seperate Topic model to represent topic data (not the Radian6::Topic class, which is for Radian6 'internal' use) - Add views and cukes to support viewing topic configuration [#14767239] [#14763449]<commit_after>module Radian6
  class Topic
    attr_accessor :name, :groups, :id
    
    def initialize(params)
      @name = params[:name]
      @groups   = params[:groups]
      @id       = params[:id]
    end

    def self.from_xml(xml)
      doc = Nokogiri::XML(xml)
      xml_topics = doc.root.xpath('//topicFilters/topicFilter')
      topics = []
      xml_topics.each_with_index do |xml_topic, index|
        groups = []
        xml_topic.xpath('./filterGroups/filterGroup').each do |xml_group|
          queries = []
          xml_group.xpath('./filterQueries/filterQuery').each do |xml_query|
            queries << FilterQuery.new({
              :id             => xml_query.xpath('./filterQueryId').text,
              :query          => xml_query.xpath('./query').text,
              :isExcludeQuery => xml_query.xpath('./filterQueryTypeId').text
            })
          end
          
          groups << FilterGroup.new({
            :name     => xml_group.xpath('./name').text,
{'fraction_non_alphanumeric': 0.14033680834001605, 'fraction_numerical': 0.011627906976744186, 'mean_word_length': 2.0840543881334983, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '470666', 'n_tokens_mistral': 779, 'n_tokens_neox': 761, 'n_words': 159}