app/helpers/application_helper.rb
# TODO: Add rules here based on language of name and perspective.
Add rules here based on language of name and perspective.
Add rules here based on language of name and perspective .
def apply_name_preference(names)
    return [] if names.empty?
    filtered = []
    latin_names = names.select {|n| !n.writing_system.blank? and n.writing_system.is_latin?}
    latin_names.each do |name|
      unless name.language.blank?
        filtered << name if name.language.is_english?
        if name.language.is_chinese?
          related_name = name.relations.select {|r| !r.phonetic_system.blank? and r.phonetic_system.is_pinyin? }
          filtered << related_name.first.child_node unless related_name.empty?
        end
        if name.language.is_nepali?
          related_name = name.relations.select {|r| !r.phonetic_system.blank? and r.phonetic_system.is_ind_transcrip? }
          filtered << related_name.first.child_node unless related_name.empty?
          filtered << name if name.is_original? and related_name.empty?
        end
        if name.language.is_tibetan?
          related_name = name.relations.select {|r| !r.phonetic_system.blank? and r.phonetic_system.is_thl_simple_transcrip? }
          filtered << related_name.first.child_node unless related_name.empty?
        end
      end
    end
    if filtered.empty?
      latin_names
    else
      filtered.uniq 
    end
  end
def apply_name_preference ( names ) return [ ] if names . empty? filtered = [ ] latin_names = names . select { | n | ! n . writing_system . blank? and n . writing_system . is_latin? } latin_names . each do | name | unless name . language . blank? filtered << name if name . language . is_english? if name . language . is_chinese? related_name = name . relations . select { | r | ! r . phonetic_system . blank? and r . phonetic_system . is_pinyin? } filtered << related_name . first . child_node unless related_name . empty? end if name . language . is_nepali? related_name = name . relations . select { | r | ! r . phonetic_system . blank? and r . phonetic_system . is_ind_transcrip? } filtered << related_name . first . child_node unless related_name . empty? filtered << name if name . is_original? and related_name . empty? end if name . language . is_tibetan? related_name = name . relations . select { | r | ! r . phonetic_system . blank? and r . phonetic_system . is_thl_simple_transcrip? } filtered << related_name . first . child_node unless related_name . empty? end end end if filtered . empty? latin_names else filtered . uniq end end
TODO: Add rules here based on language of name and perspective.
TODO : Add rules here based on language of name and perspective .
# FIXME: This should be cleaned up; most direct implementation to get something working # TODO: improve fallback. For now names transcript in latin script are better than nothing. # in case any dupes get added
names
<not_specific>