Skip to content

Commit 58ee3c0

Browse files
authored
NoorBayan treebank: import pipeline and SVG rendering (#695)
* add qul-scripts * New Irrab rendering pipeline and imported NoorBayan/Quranic dataset * expand tree levels * fix labels * fix treebank rendering
1 parent c7e0052 commit 58ee3c0

61 files changed

Lines changed: 8219 additions & 68 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/admin/morphology/info.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
ActiveAdmin.register_page 'Morphology Info' do
4+
menu parent: 'Morphology', priority: 1, label: 'Info & Concepts'
5+
6+
content title: 'Morphology & Grammar Datasets' do
7+
render "admin/morphology/docs"
8+
end
9+
end

app/admin/morphology/sentence.rb

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# frozen_string_literal: true
2+
3+
ActiveAdmin.register Morphology::Sentence do
4+
menu parent: 'Morphology'
5+
actions :index, :show
6+
includes :first_verse, :last_verse
7+
8+
filter :sentence_number
9+
filter :chapter_id, as: :numeric
10+
filter :verses_count
11+
filter :tokens_count
12+
13+
index do
14+
id_column
15+
column :sentence_number
16+
column :chapter_id
17+
column :verses do |sentence|
18+
sentence.verse_range
19+
end
20+
column :tokens_count
21+
column :words_count
22+
column :text do |sentence|
23+
span sentence.text_qpc_hafs, class: 'qpc-hafs quran-text'
24+
end
25+
end
26+
27+
show do
28+
attributes_table do
29+
row :sentence_number
30+
row :chapter_id
31+
row :first_verse
32+
row :last_verse
33+
row :verses_count
34+
row :tokens_count
35+
row :words_count
36+
row :text_uthmani
37+
row :text_qpc_hafs do |sentence|
38+
span sentence.text_qpc_hafs, class: 'qpc-hafs quran-text'
39+
end
40+
end
41+
42+
panel 'Tokens' do
43+
tokens = resource.word_tokens.includes(:head_token)
44+
table_for tokens do
45+
column :position_in_sentence
46+
column :location do |token|
47+
link_to token.location || token.token_type, [:cms, token]
48+
end
49+
column :text do |token|
50+
span token.text_qpc_hafs, class: 'qpc-hafs quran-text'
51+
end
52+
column :token_type
53+
column :pos do |token|
54+
token.pos_name
55+
end
56+
column :segment_type
57+
column :relation do |token|
58+
if token.head_token
59+
link_to token.rel_label_name, [:cms, token.head_token]
60+
else
61+
token.rel_label_name
62+
end
63+
end
64+
column :constituent_label
65+
end
66+
end
67+
end
68+
end

app/admin/morphology/word_token.rb

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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

app/assets/stylesheets/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
@import "components/segment_player";
2929
@import "components/syntax_graph";
3030
@import "components/treebank_edit";
31+
@import "components/treebank";
3132
@import "components/mushaf_pages_table";
3233

3334
html,

0 commit comments

Comments
 (0)