<commit_before>#encoding: utf-8
module SuggestedTypesHelper
  def create_suggested_type_popup_link term_type
    link_name = image('new') + " " + "New #{term_type.humanize.downcase} type"
    url = eval "new_suggested_#{term_type}_type_path"

    return link_to_remote_redbox(link_name,
                                 {:url => url,
                                  :failure => "alert('Sorry, an error has occurred.'); RedBox.close();",
                                  :with => "'term_type=#{term_type}'",
                                  :method => :get
                                 }
    )
  end

  def create_or_update_text
    submit_button_text = action_name=="edit" ? "Update" : "Create"
    submit_button_text
  end


  def all_types_text join_word="and"
    model_class = controller_name.classify.constantize
    model_class.all_term_types.map{|type| type.split("_").join(" ")}.join(" #{join_word} ")
  end


  def cancel_link
    if  is_ajax_request?
      link_to_function("Cancel", "RedBox.close()",:class=>'btn btn-default')
    else
      manage_path = eval "manage_#{self.controller_name}_path"
      cancel_button(manage_path)
    end
  end

  def ontology_editor_display types, selected_uri=nil
    list = []
    Array(types).each do |type|
      list += rendergi_list(type, selected_uri)
    end
    list = list.join("\n").html_safe + "<br/> <em>* Note that it is suggested term.</em>".html_safe
  end

  def render_list type, selected_uri=nil
    reader = reader_for_type(type)
    classes = reader.class_hierarchy
    list = render_ontology_class_tree(classes, selected_uri)
    list
  end

  def render_ontology_class_tree clz, selected_uri, depth=0
    list = []
    uri = clz.uri.try(:to_s)
    clz_li = "<li style=\"margin-left:#{12*depth}px;#{uri == selected_uri ? "background-color: lightblue;" : ""}\">" + (depth>0 ? "└ " : " ") + ontology_class_list_item(clz) + "</li>"
    list << clz_li
    clz.children.each do |ontology_class_or_suggested_type|
      list +=render_ontology_class_tree(ontology_class_or_suggested_type, selected_uri, depth+1)<commit_msg>removed accidentally typed text<commit_after>#encoding: utf-8
module SuggestedTypesHelper
  def create_suggested_type_popup_link term_type
    link_name = image('new') + " " + "New #{term_type.humanize.downcase} type"
    url = eval "new_suggested_#{term_type}_type_path"

    return link_to_remote_redbox(link_name,
                                 {:url => url,
                                  :failure => "alert('Sorry, an error has occurred.'); RedBox.close();",
                                  :with => "'term_type=#{term_type}'",
                                  :method => :get
                                 }
    )
  end

  def create_or_update_text
    submit_button_text = action_name=="edit" ? "Update" : "Create"
    submit_button_text
  end


  def all_types_text join_word="and"
    model_class = controller_name.classify.constantize
    model_class.all_term_types.map{|type| type.split("_").join(" ")}.join(" #{join_word} ")
  end


  def cancel_link
    if  is_ajax_request?
      link_to_function("Cancel", "RedBox.close()",:class=>'btn btn-default')
    else
      manage_path = eval "manage_#{self.controller_name}_path"
      cancel_button(manage_path)
    end
  end

  def ontology_editor_display types, selected_uri=nil
    list = []
    Array(types).each do |type|
      list += render_list(type, selected_uri)
    end
    list = list.join("\n").html_safe + "<br/> <em>* Note that it is suggested term.</em>".html_safe
  end

  def render_list type, selected_uri=nil
    reader = reader_for_type(type)
    classes = reader.class_hierarchy
    list = render_ontology_class_tree(classes, selected_uri)
    list
  end

  def render_ontology_class_tree clz, selected_uri, depth=0
    list = []
    uri = clz.uri.try(:to_s)
    clz_li = "<li style=\"margin-left:#{12*depth}px;#{uri == selected_uri ? "background-color: lightblue;" : ""}\">" + (depth>0 ? "└ " : " ") + ontology_class_list_item(clz) + "</li>"
    list << clz_li
    clz.children.each do |ontology_class_or_suggested_type|
      list +=render_ontology_class_tree(ontology_class_or_suggested_type, selected_uri, depth+1)
{'fraction_non_alphanumeric': 0.12470252260828177, 'fraction_numerical': 0.0028557829604950024, 'mean_word_length': 2.9427767354596623, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3207606', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1368, 'n_words': 254}