|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +ActiveAdmin.register Morphology::WordToken do |
| 4 | + menu parent: 'Morphology' |
| 5 | + actions :index, :show |
| 6 | + includes :sentence, :word |
| 7 | + |
| 8 | + filter :location_cont, label: 'Location' |
| 9 | + filter :token_type, as: :select, collection: -> { Morphology::WordToken.token_types } |
| 10 | + filter :pos_key, as: :select, collection: -> { Corpus::Morphology::PartOfSpeech.all.map(&:tag).sort } |
| 11 | + filter :segment_type, as: :select, collection: %w[Prefix Stem Suffix] |
| 12 | + filter :rel_label, as: :select, collection: -> { Morphology::WordToken.distinct.pluck(:rel_label).compact.sort } |
| 13 | + filter :nominal_case, as: :select, collection: %w[NOM ACC GEN] |
| 14 | + filter :verb_aspect, as: :select, collection: %w[PERF IMPF IMPV] |
| 15 | + filter :verb_form |
| 16 | + filter :special_group, as: :select, collection: %w[kana inna kada] |
| 17 | + filter :chapter_number |
| 18 | + filter :verse_number |
| 19 | + filter :sentence_id, as: :numeric |
| 20 | + |
| 21 | + index do |
| 22 | + id_column |
| 23 | + column :location do |token| |
| 24 | + token.location || token.token_type |
| 25 | + end |
| 26 | + column :text do |token| |
| 27 | + span token.text_qpc_hafs, class: 'qpc-hafs quran-text' |
| 28 | + end |
| 29 | + column :token_type |
| 30 | + column :pos_key |
| 31 | + column :segment_type |
| 32 | + column :rel_label do |token| |
| 33 | + token.rel_label_name |
| 34 | + end |
| 35 | + column :sentence do |token| |
| 36 | + token.sentence && link_to(token.sentence.sentence_number, [:cms, token.sentence]) |
| 37 | + end |
| 38 | + end |
| 39 | + |
| 40 | + show do |
| 41 | + attributes_table title: 'Position' do |
| 42 | + row :sentence |
| 43 | + row :word |
| 44 | + row :morphology_word |
| 45 | + row :token_type |
| 46 | + row :location |
| 47 | + row :chapter_number |
| 48 | + row :verse_number |
| 49 | + row :word_number |
| 50 | + row :position_in_word |
| 51 | + row :position_in_sentence |
| 52 | + row :word_position_in_sentence |
| 53 | + end |
| 54 | + |
| 55 | + attributes_table title: 'Texts' do |
| 56 | + row :text_uthmani do |token| |
| 57 | + span token.text_uthmani, class: 'qpc-hafs quran-text' |
| 58 | + end |
| 59 | + row :text_qpc_hafs do |token| |
| 60 | + span token.text_qpc_hafs, class: 'qpc-hafs quran-text' |
| 61 | + end |
| 62 | + row :text_imlaai |
| 63 | + row :phonetic |
| 64 | + row :translation_en |
| 65 | + end |
| 66 | + |
| 67 | + attributes_table title: 'Morphology' do |
| 68 | + row :pos_key do |token| |
| 69 | + "#{token.pos_key} — #{token.pos_name}" |
| 70 | + end |
| 71 | + row :segment_type |
| 72 | + row :lemma |
| 73 | + row :lemma_name |
| 74 | + row :root |
| 75 | + row :root_name |
| 76 | + row :verb_form |
| 77 | + row :verb_aspect |
| 78 | + row :verb_mood |
| 79 | + row :verb_voice |
| 80 | + row :nominal_case |
| 81 | + row :nominal_state |
| 82 | + row :derived_noun_type |
| 83 | + row :special_group do |token| |
| 84 | + token.special_group && I18n.t("morphology.special_groups.#{token.special_group}") |
| 85 | + end |
| 86 | + row :prefix_type |
| 87 | + row :suffix_type |
| 88 | + row :pgn |
| 89 | + row :person |
| 90 | + row :gender |
| 91 | + row :number |
| 92 | + row :features |
| 93 | + end |
| 94 | + |
| 95 | + attributes_table title: 'Dependency' do |
| 96 | + row :rel_label do |token| |
| 97 | + token.rel_label_name |
| 98 | + end |
| 99 | + row :rel_governor |
| 100 | + row :ref_token_position |
| 101 | + row :head_token |
| 102 | + row :dependent_is_phrase |
| 103 | + row :head_is_phrase |
| 104 | + end |
| 105 | + |
| 106 | + attributes_table title: 'Constituency' do |
| 107 | + row :is_constituent |
| 108 | + row :constituent_span_start |
| 109 | + row :constituent_span_end |
| 110 | + row :constituent_text do |token| |
| 111 | + token.constituent_text && span(token.constituent_text, class: 'qpc-hafs quran-text') |
| 112 | + end |
| 113 | + row :constituent_label |
| 114 | + end |
| 115 | + |
| 116 | + attributes_table title: 'Source' do |
| 117 | + row :source_meta |
| 118 | + end |
| 119 | + end |
| 120 | +end |
0 commit comments