line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WordNet::Similarity::Visual; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
WordNet::Similarity::Visual - Perl extension for providing visualization tools |
6
|
|
|
|
|
|
|
for WordNet::Similarity |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head2 Basic Usage Example |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use WordNet::Similarity::Visual; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$gui = WordNet::Similarity::Visual->new; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$gui->initialize; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This package provides a graphical extension for WordNet::Similarity. |
21
|
|
|
|
|
|
|
It provides a gui for WordNet::Similarity and visualization tools for |
22
|
|
|
|
|
|
|
the various edge counting measures like path, wup, lch and hso. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 Methods |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
The following methods are defined in this package: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head3 Public methods |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
22432
|
use 5.008004; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
42
|
|
35
|
1
|
|
|
1
|
|
6561
|
use WordNet::Similarity::Visual::QueryDataInterface; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use WordNet::Similarity::Visual::GUI_Window; |
37
|
|
|
|
|
|
|
use WordNet::Similarity::Visual::SimilarityInterface; |
38
|
|
|
|
|
|
|
use Gtk2 '-init'; |
39
|
|
|
|
|
|
|
use strict; |
40
|
|
|
|
|
|
|
use warnings; |
41
|
|
|
|
|
|
|
use constant TRUE => 1; |
42
|
|
|
|
|
|
|
use constant FALSE => 0; |
43
|
|
|
|
|
|
|
my $main_window; |
44
|
|
|
|
|
|
|
my $querydata_vbox; |
45
|
|
|
|
|
|
|
my $similarity_vbox; |
46
|
|
|
|
|
|
|
my $similarity_interface; |
47
|
|
|
|
|
|
|
my $querydata_interface; |
48
|
|
|
|
|
|
|
my $trace_result_box; |
49
|
|
|
|
|
|
|
my $values_result_box; |
50
|
|
|
|
|
|
|
my $querydata_result_box; |
51
|
|
|
|
|
|
|
my $progbar; |
52
|
|
|
|
|
|
|
my $initial_flag; |
53
|
|
|
|
|
|
|
my $start_window; |
54
|
|
|
|
|
|
|
my $tooltip; |
55
|
|
|
|
|
|
|
my $toolflag; |
56
|
|
|
|
|
|
|
my $tooltip_label; |
57
|
|
|
|
|
|
|
my $vpaned; |
58
|
|
|
|
|
|
|
my $main_statusbar; |
59
|
|
|
|
|
|
|
my $canvas; |
60
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item $obj->new |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
The constructor for WordNet::Similarity::Visual objects. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Return value: the new blessed object |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub new |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
my ($class) = @_; |
74
|
|
|
|
|
|
|
my $self = {}; |
75
|
|
|
|
|
|
|
bless $self, $class; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item $obj->initialize |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
To initialize the Graphical User Interface and pass the control to it. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub initialize |
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
my ($self)=@_; |
87
|
|
|
|
|
|
|
$self->configure; |
88
|
|
|
|
|
|
|
$self->{ initial_flag }=0; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
################################################################################# |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$self->{ tooltip_label } = Gtk2::Label->new; |
93
|
|
|
|
|
|
|
$self->{ tooltip } = Gtk2::Window->new('popup'); |
94
|
|
|
|
|
|
|
$self->{ tooltip }->set_decorated(FALSE); |
95
|
|
|
|
|
|
|
$self->{ tooltip }->set_destroy_with_parent(TRUE); |
96
|
|
|
|
|
|
|
$self->{ tooltip }->set_position('mouse'); |
97
|
|
|
|
|
|
|
$self->{ tooltip }->modify_bg ('normal', Gtk2::Gdk::Color->parse('yellow')); |
98
|
|
|
|
|
|
|
$self->{ tooltip }->add($self->{ tooltip_label }); |
99
|
|
|
|
|
|
|
$self->{ toolflag }=0; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
################################################################################# |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$self->{ querydata_interface } = WordNet::Similarity::Visual::QueryDataInterface->new; |
104
|
|
|
|
|
|
|
$self->{ similarity_interface } = WordNet::Similarity::Visual::SimilarityInterface->new; |
105
|
|
|
|
|
|
|
$self->{ start_window }= Gtk2::Window->new("toplevel"); |
106
|
|
|
|
|
|
|
$self->{ start_window }->set_resizable(FALSE); |
107
|
|
|
|
|
|
|
$self->{ start_window }->set_position("GTK_WIN_POS_CENTER"); |
108
|
|
|
|
|
|
|
$self->{ start_window }->set_skip_taskbar_hint(TRUE); |
109
|
|
|
|
|
|
|
$self->{ start_window }->set_destroy_with_parent(TRUE); |
110
|
|
|
|
|
|
|
$self->{ start_window }->set_size_request(300,300); |
111
|
|
|
|
|
|
|
$self->{ start_window }->set_decorated(FALSE); |
112
|
|
|
|
|
|
|
$self->{ start_window }->stick; |
113
|
|
|
|
|
|
|
my $start_vbox = Gtk2::VBox->new; |
114
|
|
|
|
|
|
|
$self->{ progbar } = Gtk2::ProgressBar->new; |
115
|
|
|
|
|
|
|
$self->{ progbar }->set_text("Initializing WordNet::Similarity...."); |
116
|
|
|
|
|
|
|
$self->{ progbar }->set_fraction(0); |
117
|
|
|
|
|
|
|
$self->{ progbar }->set_pulse_step(0.05); |
118
|
|
|
|
|
|
|
my $start_canvas = Gnome2::Canvas->new; |
119
|
|
|
|
|
|
|
$start_canvas->set_size_request(300,250); |
120
|
|
|
|
|
|
|
$start_vbox->add($start_canvas); |
121
|
|
|
|
|
|
|
$start_vbox->add($self->{ progbar }); |
122
|
|
|
|
|
|
|
$self->{ start_window }->add($start_vbox); |
123
|
|
|
|
|
|
|
my $timer = Glib::Timeout->add(100,\&update_progressbar,$self); |
124
|
|
|
|
|
|
|
$self->{ start_window }->signal_connect(destroy=> sub { |
125
|
|
|
|
|
|
|
my($self)=@_; |
126
|
|
|
|
|
|
|
Gtk2->main_quit; |
127
|
|
|
|
|
|
|
}); |
128
|
|
|
|
|
|
|
$self->{ start_window }->show_all; |
129
|
|
|
|
|
|
|
Gtk2->main; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
########################################################################################### |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
$self->{ main_window } = WordNet::Similarity::Visual::GUI_Window->new; |
134
|
|
|
|
|
|
|
$self->{ main_window }->initialize("WordNet::Similarity GUI",0, 800,600); |
135
|
|
|
|
|
|
|
$self->{ main_statusbar } = Gtk2::Statusbar->new; |
136
|
|
|
|
|
|
|
my $main_menu = Gtk2::MenuBar->new(); |
137
|
|
|
|
|
|
|
$self->{ main_window }->pack_start($main_menu,FALSE, FALSE, 0); |
138
|
|
|
|
|
|
|
my $tabbedwindow = Gtk2::Notebook->new; |
139
|
|
|
|
|
|
|
$tabbedwindow->set_show_border(0); |
140
|
|
|
|
|
|
|
my $querydata_scrollwindow = Gtk2::ScrolledWindow->new; |
141
|
|
|
|
|
|
|
my $similarity_scrollwindow = Gtk2::ScrolledWindow->new; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
########################################################################################### |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
$self->{ similarity_vbox } = Gtk2::VBox->new(FALSE, 6); |
146
|
|
|
|
|
|
|
$self->{ similarity_vbox }->set_border_width(6); |
147
|
|
|
|
|
|
|
my $similarity_entry_align = Gtk2::Alignment->new(0.0,0.0,0.3,0.0); |
148
|
|
|
|
|
|
|
my $similarity_entry_hbox = Gtk2::HBox->new(FALSE,6); |
149
|
|
|
|
|
|
|
my $word1_similarity_entry = Gtk2::Entry->new; |
150
|
|
|
|
|
|
|
my $word2_similarity_entry = Gtk2::Entry->new; |
151
|
|
|
|
|
|
|
my $measure_touse = Gtk2::ComboBox->new_text; |
152
|
|
|
|
|
|
|
$measure_touse->append_text("All Measures"); |
153
|
|
|
|
|
|
|
$measure_touse->append_text("Hist & St-Onge"); |
154
|
|
|
|
|
|
|
$measure_touse->append_text("Leacock & Chodorow"); |
155
|
|
|
|
|
|
|
$measure_touse->append_text("Adapted Lesk"); |
156
|
|
|
|
|
|
|
$measure_touse->append_text("Lin"); |
157
|
|
|
|
|
|
|
$measure_touse->append_text("Jiang & Conrath"); |
158
|
|
|
|
|
|
|
$measure_touse->append_text("Path length"); |
159
|
|
|
|
|
|
|
$measure_touse->append_text("Random numbers"); |
160
|
|
|
|
|
|
|
$measure_touse->append_text("Resnik"); |
161
|
|
|
|
|
|
|
$measure_touse->append_text("Context vector"); |
162
|
|
|
|
|
|
|
$measure_touse->append_text("Wu & Palmer"); |
163
|
|
|
|
|
|
|
$measure_touse->set_active(0); |
164
|
|
|
|
|
|
|
my $compute_button = Gtk2::Button->new('_Compute'); |
165
|
|
|
|
|
|
|
my $stop_button = Gtk2::Button->new('_Stop'); |
166
|
|
|
|
|
|
|
# my $save_button = Gtk2::Button->new('_Save'); |
167
|
|
|
|
|
|
|
$similarity_entry_hbox->pack_start($word1_similarity_entry, TRUE, TRUE, 0); |
168
|
|
|
|
|
|
|
$similarity_entry_hbox->pack_start($word2_similarity_entry, TRUE, TRUE, 0); |
169
|
|
|
|
|
|
|
$similarity_entry_hbox->pack_start($measure_touse, TRUE, TRUE, 0); |
170
|
|
|
|
|
|
|
$similarity_entry_hbox->pack_start($compute_button,FALSE, FALSE, 0); |
171
|
|
|
|
|
|
|
$compute_button->signal_connect(clicked=>sub { |
172
|
|
|
|
|
|
|
my ($self, $gui)=@_; |
173
|
|
|
|
|
|
|
$gui->{ similarity_interface }->{ STOPPED }=0; |
174
|
|
|
|
|
|
|
$gui->set_statusmessage("Similarity", "Computing the Similarity Scores"); |
175
|
|
|
|
|
|
|
my $word1 = $word1_similarity_entry->get_text(); |
176
|
|
|
|
|
|
|
my $word2 = $word2_similarity_entry->get_text(); |
177
|
|
|
|
|
|
|
my $measure = $measure_touse->get_active(); |
178
|
|
|
|
|
|
|
my ($result,$errors,$traces)=$gui->{ similarity_interface }->compute_similarity($word1, $word2,$measure); |
179
|
|
|
|
|
|
|
$gui->display_similarity_results($result,$errors,$traces,$measure); |
180
|
|
|
|
|
|
|
}, $self); |
181
|
|
|
|
|
|
|
$stop_button->signal_connect(clicked=>sub { |
182
|
|
|
|
|
|
|
my ($self,$gui)=@_; |
183
|
|
|
|
|
|
|
$gui->{ similarity_interface }->{ STOPPED }=1; |
184
|
|
|
|
|
|
|
}, $self); |
185
|
|
|
|
|
|
|
$similarity_entry_hbox->pack_start($stop_button,FALSE, FALSE, 0); |
186
|
|
|
|
|
|
|
# ############################################################################################ |
187
|
|
|
|
|
|
|
# # ##Change |
188
|
|
|
|
|
|
|
# $save_button->signal_connect(clicked=>sub { |
189
|
|
|
|
|
|
|
# my ($self,$gui)=@_; |
190
|
|
|
|
|
|
|
# my $file_selector = Gtk2::FileSelection->new("Save File as..."); |
191
|
|
|
|
|
|
|
# $file_selector->set_select_multiple(FALSE); |
192
|
|
|
|
|
|
|
# $file_selector->ok_button->set_label("Save"); |
193
|
|
|
|
|
|
|
# my @data = ($file_selector, $gui); |
194
|
|
|
|
|
|
|
# $file_selector->ok_button->signal_connect(clicked=>sub { |
195
|
|
|
|
|
|
|
# my ($self,$data)=@_; |
196
|
|
|
|
|
|
|
# my $file_selector = $data->[0]; |
197
|
|
|
|
|
|
|
# my $gui = $data->[1]; |
198
|
|
|
|
|
|
|
# my $file_name=$file_selector->get_filename(); |
199
|
|
|
|
|
|
|
# print $file_name; |
200
|
|
|
|
|
|
|
# $gui->save_file($file_name); |
201
|
|
|
|
|
|
|
# $file_selector->destroy; |
202
|
|
|
|
|
|
|
# },\@data); |
203
|
|
|
|
|
|
|
# $file_selector->ok_button->signal_connect(clicked=>sub { |
204
|
|
|
|
|
|
|
# my ($self,$file_selector)=@_; |
205
|
|
|
|
|
|
|
# $file_selector->destroy; |
206
|
|
|
|
|
|
|
# },$file_selector); |
207
|
|
|
|
|
|
|
# |
208
|
|
|
|
|
|
|
# $file_selector->show_all; |
209
|
|
|
|
|
|
|
# }, $self); |
210
|
|
|
|
|
|
|
# ########################################################################################### |
211
|
|
|
|
|
|
|
# $similarity_entry_hbox->pack_start($save_button,FALSE, FALSE, 0); |
212
|
|
|
|
|
|
|
$similarity_entry_align->add($similarity_entry_hbox); |
213
|
|
|
|
|
|
|
$self->{ similarity_vbox }->pack_start($similarity_entry_align, FALSE, FALSE, 0); |
214
|
|
|
|
|
|
|
my $hseparator = Gtk2::HSeparator->new; |
215
|
|
|
|
|
|
|
$self->{ similarity_vbox }->pack_start($hseparator, FALSE, FALSE, 0); |
216
|
|
|
|
|
|
|
$self->{ trace_result_box }=Gtk2::VBox->new(FALSE,4); |
217
|
|
|
|
|
|
|
$self->{ values_result_box }=Gtk2::VBox->new(FALSE,4); |
218
|
|
|
|
|
|
|
my $hpaned = Gtk2::HPaned->new; |
219
|
|
|
|
|
|
|
$self->{ vpaned } = Gtk2::VPaned->new; |
220
|
|
|
|
|
|
|
my $trace_scrollwindow = Gtk2::ScrolledWindow->new; |
221
|
|
|
|
|
|
|
$trace_scrollwindow->add_with_viewport($self->{ trace_result_box }); |
222
|
|
|
|
|
|
|
$trace_scrollwindow->set_policy("GTK_POLICY_AUTOMATIC", "GTK_POLICY_AUTOMATIC"); |
223
|
|
|
|
|
|
|
my $values_scrollwindow = Gtk2::ScrolledWindow->new; |
224
|
|
|
|
|
|
|
$values_scrollwindow->add_with_viewport($self->{ values_result_box }); |
225
|
|
|
|
|
|
|
$values_scrollwindow->set_policy("GTK_POLICY_AUTOMATIC", "GTK_POLICY_AUTOMATIC"); |
226
|
|
|
|
|
|
|
$hpaned->add1($values_scrollwindow); |
227
|
|
|
|
|
|
|
$self->{ vpaned }->add1($trace_scrollwindow); |
228
|
|
|
|
|
|
|
$hpaned->add2($self->{ vpaned }); |
229
|
|
|
|
|
|
|
$hpaned->set_position(320); |
230
|
|
|
|
|
|
|
$self->{ similarity_vbox }->pack_start($hpaned, TRUE, TRUE, 0); |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
#####################################################################################################################333 |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
$self->{ querydata_vbox }= Gtk2::VBox->new(FALSE, 6); |
235
|
|
|
|
|
|
|
$self->{ querydata_vbox }->set_border_width(6); |
236
|
|
|
|
|
|
|
my $querydata_entry_align = Gtk2::Alignment->new(0.0,0.0,0.3,0.0); |
237
|
|
|
|
|
|
|
my $querydata_entry_hbox = Gtk2::HBox->new(FALSE,6); |
238
|
|
|
|
|
|
|
# my $back_button = Gtk2::Button->new('<< _Back'); |
239
|
|
|
|
|
|
|
# my $forward_button = Gtk2::Button->new('_Forward >>'); |
240
|
|
|
|
|
|
|
my $searchword_entry = Gtk2::Entry->new; |
241
|
|
|
|
|
|
|
my $querydata_search_button = Gtk2::Button->new('_Search'); |
242
|
|
|
|
|
|
|
my $print_button = Gtk2::Button->new('_Print'); |
243
|
|
|
|
|
|
|
# $querydata_entry_hbox->pack_start($back_button,FALSE, FALSE, 0); |
244
|
|
|
|
|
|
|
# $querydata_entry_hbox->pack_start($forward_button,FALSE, FALSE, 0); |
245
|
|
|
|
|
|
|
$querydata_entry_hbox->pack_start($searchword_entry, TRUE, TRUE, 0); |
246
|
|
|
|
|
|
|
$querydata_entry_hbox->pack_start($querydata_search_button,FALSE, FALSE, 0); |
247
|
|
|
|
|
|
|
$querydata_entry_hbox->pack_start($print_button,FALSE, FALSE, 0); |
248
|
|
|
|
|
|
|
$querydata_search_button->signal_connect(clicked=>sub { |
249
|
|
|
|
|
|
|
my ($self, $gui)=@_; |
250
|
|
|
|
|
|
|
$gui->set_statusmessage("QueryData", "Crawling Through WordNet for Senses!"); |
251
|
|
|
|
|
|
|
my $word = $searchword_entry->get_text(); |
252
|
|
|
|
|
|
|
my $result_wps = $gui->{ querydata_interface }->search_senses($word); |
253
|
|
|
|
|
|
|
$gui->display_querydata_results($result_wps); |
254
|
|
|
|
|
|
|
}, $self); |
255
|
|
|
|
|
|
|
$querydata_entry_align->add($querydata_entry_hbox); |
256
|
|
|
|
|
|
|
$self->{ querydata_vbox }->pack_start($querydata_entry_align, FALSE, FALSE, 0); |
257
|
|
|
|
|
|
|
my $querydata_hseparator = Gtk2::HSeparator->new; |
258
|
|
|
|
|
|
|
$self->{ querydata_vbox }->pack_start($querydata_hseparator, FALSE, FALSE, 0); |
259
|
|
|
|
|
|
|
$self->{ querydata_result_box }=Gtk2::VBox->new(FALSE,4); |
260
|
|
|
|
|
|
|
$self->{ querydata_vbox }->pack_start($self->{ querydata_result_box }, TRUE, TRUE, 0); |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
########################################################################################### |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
$similarity_scrollwindow->add_with_viewport($self->{ similarity_vbox }); |
266
|
|
|
|
|
|
|
$similarity_scrollwindow->set_policy("GTK_POLICY_NEVER", "GTK_POLICY_AUTOMATIC"); |
267
|
|
|
|
|
|
|
$querydata_scrollwindow->add_with_viewport($self->{ querydata_vbox }); |
268
|
|
|
|
|
|
|
$querydata_scrollwindow->set_policy("GTK_POLICY_NEVER", "GTK_POLICY_AUTOMATIC"); |
269
|
|
|
|
|
|
|
$tabbedwindow->append_page($querydata_scrollwindow, "WordNet::QueryData"); |
270
|
|
|
|
|
|
|
$tabbedwindow->append_page($similarity_scrollwindow, "WordNet::Similarity"); |
271
|
|
|
|
|
|
|
$self->{ main_window }->pack_start($tabbedwindow,TRUE, TRUE,0); |
272
|
|
|
|
|
|
|
$self->{ main_window }->pack_end($self->{ main_statusbar },FALSE, FALSE, 0); |
273
|
|
|
|
|
|
|
$self->{ main_window }->display; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
###############################################################################################3 |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub update_progressbar |
279
|
|
|
|
|
|
|
{ |
280
|
|
|
|
|
|
|
my ($gui)=@_; |
281
|
|
|
|
|
|
|
if($gui->{ initial_flag }<2) |
282
|
|
|
|
|
|
|
{ |
283
|
|
|
|
|
|
|
if($gui->{ initial_flag }==0) |
284
|
|
|
|
|
|
|
{ |
285
|
|
|
|
|
|
|
while (Gtk2->events_pending) |
286
|
|
|
|
|
|
|
{ |
287
|
|
|
|
|
|
|
Gtk2->main_iteration; |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
$gui->{ querydata_interface }->initialize; |
290
|
|
|
|
|
|
|
$gui->{ progbar }->set_fraction($gui->{ progbar }->get_fraction+0.1); |
291
|
|
|
|
|
|
|
while (Gtk2->events_pending) |
292
|
|
|
|
|
|
|
{ |
293
|
|
|
|
|
|
|
Gtk2->main_iteration; |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
$gui->{ similarity_interface }->initialize; |
296
|
|
|
|
|
|
|
$gui->{ initial_flag }=1; |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
if($gui->{ progbar }->get_fraction >= 1) |
299
|
|
|
|
|
|
|
{ |
300
|
|
|
|
|
|
|
$gui->{ start_window }->destroy; |
301
|
|
|
|
|
|
|
$gui->{ initial_flag }=2; |
302
|
|
|
|
|
|
|
return TRUE; |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
else |
305
|
|
|
|
|
|
|
{ |
306
|
|
|
|
|
|
|
$gui->{ progbar }->set_fraction($gui->{ progbar }->get_fraction+0.1); |
307
|
|
|
|
|
|
|
$gui->{ start_window }->show_all; |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
return TRUE; |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
sub display_querydata_results |
318
|
|
|
|
|
|
|
{ |
319
|
|
|
|
|
|
|
my ($self, $result)=@_; |
320
|
|
|
|
|
|
|
my $wps; |
321
|
|
|
|
|
|
|
my %labels; |
322
|
|
|
|
|
|
|
my %hbox; |
323
|
|
|
|
|
|
|
my %txtview; |
324
|
|
|
|
|
|
|
my %txtbuffer; |
325
|
|
|
|
|
|
|
my $children; |
326
|
|
|
|
|
|
|
my @prev_results = $self->{ querydata_result_box }->get_children(); |
327
|
|
|
|
|
|
|
foreach $children (@prev_results) |
328
|
|
|
|
|
|
|
{ |
329
|
|
|
|
|
|
|
$self->{ querydata_result_box }->remove($children); |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
foreach $wps (sort keys %$result) |
332
|
|
|
|
|
|
|
{ |
333
|
|
|
|
|
|
|
$labels{$wps}=Gtk2::Label->new($wps); |
334
|
|
|
|
|
|
|
$hbox{$wps}=Gtk2::HBox->new(); |
335
|
|
|
|
|
|
|
$txtbuffer{$wps}=Gtk2::TextBuffer->new(); |
336
|
|
|
|
|
|
|
$txtbuffer{$wps}->set_text($result->{$wps}); |
337
|
|
|
|
|
|
|
$txtview{$wps}=Gtk2::TextView->new; |
338
|
|
|
|
|
|
|
$txtview{$wps}->set_editable(FALSE); |
339
|
|
|
|
|
|
|
$txtview{$wps}->set_cursor_visible(FALSE); |
340
|
|
|
|
|
|
|
$txtview{$wps}->set_wrap_mode("word"); |
341
|
|
|
|
|
|
|
$txtview{$wps}->set_buffer($txtbuffer{$wps}); |
342
|
|
|
|
|
|
|
$hbox{$wps}->pack_start($labels{$wps},FALSE,FALSE,0); |
343
|
|
|
|
|
|
|
$hbox{$wps}->pack_start($txtview{$wps},TRUE, TRUE, 0); |
344
|
|
|
|
|
|
|
$self->{ querydata_result_box}->pack_start($hbox{$wps},FALSE, FALSE, 4); |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
$self->{ querydata_result_box}->show_all; |
347
|
|
|
|
|
|
|
$self->update_ui; |
348
|
|
|
|
|
|
|
} |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
# This function writes the initial configuration files for the various measures. |
356
|
|
|
|
|
|
|
sub configure |
357
|
|
|
|
|
|
|
{ |
358
|
|
|
|
|
|
|
if (!chdir($ENV{ HOME } . "/.wordnet-similarity")) |
359
|
|
|
|
|
|
|
{ |
360
|
|
|
|
|
|
|
mkdir ($ENV{ HOME } . "/.wordnet-similarity"); |
361
|
|
|
|
|
|
|
open CONFIG, "+>".$ENV{ HOME } . "/.wordnet-similarity/config-path.conf"; |
362
|
|
|
|
|
|
|
print CONFIG "WordNet::Similarity::path\ntrace::1\ncache::0\nmaxCacheSize::5000\nrootNode::1"; |
363
|
|
|
|
|
|
|
close CONFIG; |
364
|
|
|
|
|
|
|
open CONFIG, "+>".$ENV{ HOME } . "/.wordnet-similarity/config-wup.conf"; |
365
|
|
|
|
|
|
|
print CONFIG "WordNet::Similarity::wup\ntrace::1\ncache::0\nmaxCacheSize::5000\nrootNode::1"; |
366
|
|
|
|
|
|
|
close CONFIG; |
367
|
|
|
|
|
|
|
open CONFIG, "+>".$ENV{ HOME } . "/.wordnet-similarity/config-hso.conf"; |
368
|
|
|
|
|
|
|
print CONFIG "WordNet::Similarity::hso\ntrace::1\ncache::0\nmaxCacheSize::5000"; |
369
|
|
|
|
|
|
|
close CONFIG; |
370
|
|
|
|
|
|
|
open CONFIG, "+>".$ENV{ HOME } . "/.wordnet-similarity/config-lch.conf"; |
371
|
|
|
|
|
|
|
print CONFIG "WordNet::Similarity::lch\ntrace::1\ncache::0\nmaxCacheSize::5000\nrootNode::1"; |
372
|
|
|
|
|
|
|
close CONFIG; |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
sub update_ui |
378
|
|
|
|
|
|
|
{ |
379
|
|
|
|
|
|
|
my ($self) = @_; |
380
|
|
|
|
|
|
|
$self->{ main_window }->update_ui(); |
381
|
|
|
|
|
|
|
} |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
sub set_statusmessage |
385
|
|
|
|
|
|
|
{ |
386
|
|
|
|
|
|
|
my ($self, $context, $message) = @_; |
387
|
|
|
|
|
|
|
my $status_context_id = $self->{ main_statusbar }->get_context_id("MainStatusBar"); |
388
|
|
|
|
|
|
|
$self->{ main_statusbar }->push($status_context_id,$message); |
389
|
|
|
|
|
|
|
$self->{ main_window }->update_ui(); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
sub display_similarity_results |
394
|
|
|
|
|
|
|
{ |
395
|
|
|
|
|
|
|
my ($self, $values, $errors, $traces, $measure_index) = @_; |
396
|
|
|
|
|
|
|
my @allmeasures = ("hso","lch","lesk","lin","jcn","path","random","res","vector_pairs","wup"); |
397
|
|
|
|
|
|
|
my $measure; |
398
|
|
|
|
|
|
|
my $synset1; |
399
|
|
|
|
|
|
|
my $synset2; |
400
|
|
|
|
|
|
|
my $button; |
401
|
|
|
|
|
|
|
my $str; |
402
|
|
|
|
|
|
|
my $children; |
403
|
|
|
|
|
|
|
my @prev_results = $self->{ values_result_box }->get_children(); |
404
|
|
|
|
|
|
|
foreach $children (@prev_results) |
405
|
|
|
|
|
|
|
{ |
406
|
|
|
|
|
|
|
$self->{ values_result_box }->remove($children); |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
if($measure_index!=0) |
409
|
|
|
|
|
|
|
{ |
410
|
|
|
|
|
|
|
$measure = $allmeasures[$measure_index-1]; |
411
|
|
|
|
|
|
|
foreach $synset1 (keys %$values) |
412
|
|
|
|
|
|
|
{ |
413
|
|
|
|
|
|
|
foreach $synset2 (keys %{$values->{$synset1}}) |
414
|
|
|
|
|
|
|
{ |
415
|
|
|
|
|
|
|
if($values->{$synset1}{$synset2}!=-1) |
416
|
|
|
|
|
|
|
{ |
417
|
|
|
|
|
|
|
$str = sprintf("The Relatedness of %s and %s is %.4f",$synset1, $synset2, $values->{$synset1}{$synset2}); |
418
|
|
|
|
|
|
|
$button=Gtk2::Button->new_with_label($str); |
419
|
|
|
|
|
|
|
$button->signal_connect(clicked=>sub { |
420
|
|
|
|
|
|
|
my ($self,$gui)=@_; |
421
|
|
|
|
|
|
|
my $word1; |
422
|
|
|
|
|
|
|
my $word2; |
423
|
|
|
|
|
|
|
my @splitlabel; |
424
|
|
|
|
|
|
|
my $measure; |
425
|
|
|
|
|
|
|
my $string = $self->get_label(); |
426
|
|
|
|
|
|
|
@splitlabel=split " ",$string; |
427
|
|
|
|
|
|
|
$measure = $allmeasures[$measure_index-1]; |
428
|
|
|
|
|
|
|
$word1 = $splitlabel[3]; |
429
|
|
|
|
|
|
|
$word2 = $splitlabel[5]; |
430
|
|
|
|
|
|
|
$gui->trace_results($word1,$word2,$measure,$traces); |
431
|
|
|
|
|
|
|
$gui->update_ui; |
432
|
|
|
|
|
|
|
}, $self); |
433
|
|
|
|
|
|
|
$button->set_relief("none"); |
434
|
|
|
|
|
|
|
$self->{ values_result_box }->pack_start($button,FALSE, FALSE, 4); |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
else |
440
|
|
|
|
|
|
|
{ |
441
|
|
|
|
|
|
|
foreach $synset1 (keys %$values) |
442
|
|
|
|
|
|
|
{ |
443
|
|
|
|
|
|
|
foreach $synset2 (keys %{$values->{$synset1}}) |
444
|
|
|
|
|
|
|
{ |
445
|
|
|
|
|
|
|
for $measure (keys %{$values->{$synset1}{$synset2}}) |
446
|
|
|
|
|
|
|
{ |
447
|
|
|
|
|
|
|
if($errors->{$synset1}{$synset2}{$measure}) |
448
|
|
|
|
|
|
|
{ |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
else |
451
|
|
|
|
|
|
|
{ |
452
|
|
|
|
|
|
|
$str = sprintf("The Relatedness of %s and %s using %s is %.4f",$synset1, $synset2, $measure, $values->{$synset1}{$synset2}{$measure}); |
453
|
|
|
|
|
|
|
$button=Gtk2::Button->new_with_label($str); |
454
|
|
|
|
|
|
|
$button->signal_connect(clicked=>sub { |
455
|
|
|
|
|
|
|
my ($self,$gui)=@_; |
456
|
|
|
|
|
|
|
my $word1; |
457
|
|
|
|
|
|
|
my $word2; |
458
|
|
|
|
|
|
|
my $measure; |
459
|
|
|
|
|
|
|
my @splitlabel; |
460
|
|
|
|
|
|
|
my $string = $self->get_label(); |
461
|
|
|
|
|
|
|
@splitlabel=split " ",$string; |
462
|
|
|
|
|
|
|
$word1 = $splitlabel[3]; |
463
|
|
|
|
|
|
|
$word2 = $splitlabel[5]; |
464
|
|
|
|
|
|
|
$measure = $splitlabel[7]; |
465
|
|
|
|
|
|
|
$gui->trace_results($word1,$word2,$measure,$traces); |
466
|
|
|
|
|
|
|
$gui->update_ui; |
467
|
|
|
|
|
|
|
}, $self); |
468
|
|
|
|
|
|
|
$button->set_relief("none"); |
469
|
|
|
|
|
|
|
$self->{ values_result_box }->pack_start($button,FALSE, FALSE, 4); |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
} |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
$self->{ values_result_box }->show_all; |
476
|
|
|
|
|
|
|
$self->update_ui; |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
sub trace_results |
481
|
|
|
|
|
|
|
{ |
482
|
|
|
|
|
|
|
my ($self, $word1, $word2, $measure, $traces)=@_; |
483
|
|
|
|
|
|
|
my $meta; |
484
|
|
|
|
|
|
|
my $children; |
485
|
|
|
|
|
|
|
my @prev_results = $self->{ trace_result_box }->get_children(); |
486
|
|
|
|
|
|
|
foreach $children (@prev_results) |
487
|
|
|
|
|
|
|
{ |
488
|
|
|
|
|
|
|
$self->{ trace_result_box }->remove($children); |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
if($measure=~/path/) |
491
|
|
|
|
|
|
|
{ |
492
|
|
|
|
|
|
|
$meta = $self->{ similarity_interface }->convert_to_meta($word1,$word2,$traces->{$word1}{$word2}{$measure},$measure); |
493
|
|
|
|
|
|
|
my $canvas = $self->display_tree($meta,450,450); |
494
|
|
|
|
|
|
|
$self->{ trace_result_box }->pack_start($canvas, TRUE, TRUE, 0); |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
elsif($measure=~/wup/) |
497
|
|
|
|
|
|
|
{ |
498
|
|
|
|
|
|
|
$meta = $self->{ similarity_interface }->convert_to_meta($word1,$word2,$traces->{$word1}{$word2}{$measure},$measure); |
499
|
|
|
|
|
|
|
my $canvas = $self->display_tree($meta,450,450); |
500
|
|
|
|
|
|
|
$self->{ trace_result_box }->pack_start($canvas, TRUE, TRUE, 0); |
501
|
|
|
|
|
|
|
} |
502
|
|
|
|
|
|
|
elsif($measure=~/lch/) |
503
|
|
|
|
|
|
|
{ |
504
|
|
|
|
|
|
|
$meta = $self->{ similarity_interface }->convert_to_meta($word1,$word2,$traces->{$word1}{$word2}{$measure},$measure); |
505
|
|
|
|
|
|
|
my $canvas = $self->display_tree($meta,450,450); |
506
|
|
|
|
|
|
|
$self->{ trace_result_box }->pack_start($canvas, TRUE, TRUE, 0); |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
elsif($measure=~/hso/) |
509
|
|
|
|
|
|
|
{ |
510
|
|
|
|
|
|
|
if($traces->{$word1}{$word2}{$measure}=~/MedStrong\srelation\spath\.\.\./) |
511
|
|
|
|
|
|
|
{ |
512
|
|
|
|
|
|
|
$meta = $self->{ similarity_interface }->convert_to_meta($word1,$word2,$traces->{$word1}{$word2}{$measure},$measure); |
513
|
|
|
|
|
|
|
my $canvas = $self->display_tree($meta,450,450); |
514
|
|
|
|
|
|
|
$self->{ trace_result_box }->pack_start($canvas, TRUE, TRUE, 0); |
515
|
|
|
|
|
|
|
} |
516
|
|
|
|
|
|
|
elsif($traces->{$word1}{$word2}{$measure}=~/Strong\sRel\s\(Synset\sMatch\)/) |
517
|
|
|
|
|
|
|
{ |
518
|
|
|
|
|
|
|
$meta = $self->{ similarity_interface }->convert_to_meta($word1,$word2,$traces->{$word1}{$word2}{$measure},$measure); |
519
|
|
|
|
|
|
|
my $canvas = $self->display_tree($meta,450,450); |
520
|
|
|
|
|
|
|
$self->{ trace_result_box }->pack_start($canvas, TRUE, TRUE, 0); |
521
|
|
|
|
|
|
|
} |
522
|
|
|
|
|
|
|
else |
523
|
|
|
|
|
|
|
{ |
524
|
|
|
|
|
|
|
$meta = $traces->{$word1}{$word2}{$measure}."\nNo strong relation path found!!"; |
525
|
|
|
|
|
|
|
my $txtbuffer = Gtk2::TextBuffer->new(); |
526
|
|
|
|
|
|
|
$txtbuffer->set_text($meta); |
527
|
|
|
|
|
|
|
my $txtview = Gtk2::TextView->new; |
528
|
|
|
|
|
|
|
$txtview->set_editable(FALSE); |
529
|
|
|
|
|
|
|
$txtview->set_cursor_visible(FALSE); |
530
|
|
|
|
|
|
|
$txtview->set_wrap_mode("word"); |
531
|
|
|
|
|
|
|
$txtview->set_buffer($txtbuffer); |
532
|
|
|
|
|
|
|
$self->{ trace_result_box }->pack_start($txtview, TRUE, TRUE, 0); |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
else |
536
|
|
|
|
|
|
|
{ |
537
|
|
|
|
|
|
|
$meta = $traces->{$word1}{$word2}{$measure}; |
538
|
|
|
|
|
|
|
my $txtbuffer = Gtk2::TextBuffer->new(); |
539
|
|
|
|
|
|
|
$txtbuffer->set_text($meta); |
540
|
|
|
|
|
|
|
my $txtview = Gtk2::TextView->new; |
541
|
|
|
|
|
|
|
$txtview->set_editable(FALSE); |
542
|
|
|
|
|
|
|
$txtview->set_cursor_visible(FALSE); |
543
|
|
|
|
|
|
|
$txtview->set_wrap_mode("word"); |
544
|
|
|
|
|
|
|
$txtview->set_buffer($txtbuffer); |
545
|
|
|
|
|
|
|
$self->{ trace_result_box }->pack_start($txtview, TRUE, TRUE, 0); |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
$self->{ trace_result_box }->show_all; |
548
|
|
|
|
|
|
|
} |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
sub display_tree |
552
|
|
|
|
|
|
|
{ |
553
|
|
|
|
|
|
|
my ($self, $string, $width, $height)=@_; |
554
|
|
|
|
|
|
|
my @trace_strings = split "\n",$string; |
555
|
|
|
|
|
|
|
my $i; |
556
|
|
|
|
|
|
|
my @wps; |
557
|
|
|
|
|
|
|
my $diffx; |
558
|
|
|
|
|
|
|
my $diffy; |
559
|
|
|
|
|
|
|
my $x = 0; |
560
|
|
|
|
|
|
|
my $y = $height; |
561
|
|
|
|
|
|
|
my $word; |
562
|
|
|
|
|
|
|
my %wpspos = (); |
563
|
|
|
|
|
|
|
my $prevx; |
564
|
|
|
|
|
|
|
my $prevy; |
565
|
|
|
|
|
|
|
my $maxx=0; |
566
|
|
|
|
|
|
|
my $maxy=0; |
567
|
|
|
|
|
|
|
my $minx=0; |
568
|
|
|
|
|
|
|
my $miny=0; |
569
|
|
|
|
|
|
|
my $hx; |
570
|
|
|
|
|
|
|
my $hy; |
571
|
|
|
|
|
|
|
my @vbox; |
572
|
|
|
|
|
|
|
my $j; |
573
|
|
|
|
|
|
|
my $center; |
574
|
|
|
|
|
|
|
my %text; |
575
|
|
|
|
|
|
|
my %line; |
576
|
|
|
|
|
|
|
my $rflag=0; |
577
|
|
|
|
|
|
|
my $jflag=0; |
578
|
|
|
|
|
|
|
my $mpflag=0; |
579
|
|
|
|
|
|
|
my @connectedto; |
580
|
|
|
|
|
|
|
my $connect; |
581
|
|
|
|
|
|
|
my @roots; |
582
|
|
|
|
|
|
|
my @mult_wps1_path; |
583
|
|
|
|
|
|
|
my @mult_wps2_path; |
584
|
|
|
|
|
|
|
my $wps1_path; |
585
|
|
|
|
|
|
|
my $wps2_path; |
586
|
|
|
|
|
|
|
my $notebook; |
587
|
|
|
|
|
|
|
my $color; |
588
|
|
|
|
|
|
|
my $k=0; |
589
|
|
|
|
|
|
|
my @colorpos; |
590
|
|
|
|
|
|
|
my @canvas; |
591
|
|
|
|
|
|
|
my $lcs_x; |
592
|
|
|
|
|
|
|
my $lcs_y; |
593
|
|
|
|
|
|
|
my @canvas_root; |
594
|
|
|
|
|
|
|
my @shortest_path_group; |
595
|
|
|
|
|
|
|
my @root_group; |
596
|
|
|
|
|
|
|
my @shortest_path_group_wps1; |
597
|
|
|
|
|
|
|
my @shortest_path_group_wps2; |
598
|
|
|
|
|
|
|
if($trace_strings[0]=~/path/) |
599
|
|
|
|
|
|
|
{ |
600
|
|
|
|
|
|
|
@mult_wps1_path = split /\sOR\s/, $trace_strings[1]; |
601
|
|
|
|
|
|
|
@mult_wps2_path = split /\sOR\s/, $trace_strings[2]; |
602
|
|
|
|
|
|
|
if($#mult_wps1_path+$#mult_wps2_path+1>1) |
603
|
|
|
|
|
|
|
{ |
604
|
|
|
|
|
|
|
$notebook = Gtk2::Notebook->new; |
605
|
|
|
|
|
|
|
# $notebook->signal_connect(switch_page=>sub { |
606
|
|
|
|
|
|
|
# my ($self,$gui) = @_; |
607
|
|
|
|
|
|
|
# my $child=$self->get_current_page; |
608
|
|
|
|
|
|
|
# print $child; |
609
|
|
|
|
|
|
|
# my @children = $self->get_children; |
610
|
|
|
|
|
|
|
# $gui->{ canvas }= $children[$child]; |
611
|
|
|
|
|
|
|
# },$self); |
612
|
|
|
|
|
|
|
$mpflag = 1; |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
else |
615
|
|
|
|
|
|
|
{ |
616
|
|
|
|
|
|
|
$notebook = Gtk2::VBox->new; |
617
|
|
|
|
|
|
|
} |
618
|
|
|
|
|
|
|
foreach $wps1_path (@mult_wps1_path) |
619
|
|
|
|
|
|
|
{ |
620
|
|
|
|
|
|
|
foreach $wps2_path (@mult_wps2_path) |
621
|
|
|
|
|
|
|
{ |
622
|
|
|
|
|
|
|
$canvas[$k] = Gnome2::Canvas->new; |
623
|
|
|
|
|
|
|
$canvas_root[$k] = $canvas[$k]->root; |
624
|
|
|
|
|
|
|
$shortest_path_group[$k] = Gnome2::Canvas::Item->new($canvas_root[$k], "Gnome2::Canvas::Group"); |
625
|
|
|
|
|
|
|
$root_group[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
626
|
|
|
|
|
|
|
$shortest_path_group_wps1[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
627
|
|
|
|
|
|
|
$shortest_path_group_wps2[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
628
|
|
|
|
|
|
|
%text=(); |
629
|
|
|
|
|
|
|
%line=(); |
630
|
|
|
|
|
|
|
$diffy = 40; |
631
|
|
|
|
|
|
|
$diffx = 0; |
632
|
|
|
|
|
|
|
$x=0; |
633
|
|
|
|
|
|
|
$y=0; |
634
|
|
|
|
|
|
|
$maxx=0; |
635
|
|
|
|
|
|
|
$maxy=0; |
636
|
|
|
|
|
|
|
$minx=0; |
637
|
|
|
|
|
|
|
$miny=0; |
638
|
|
|
|
|
|
|
@roots = grep /Root\b/, @trace_strings; |
639
|
|
|
|
|
|
|
if(length($roots[0]) == length($trace_strings[1]) or length($roots[0]) == length($trace_strings[2])) |
640
|
|
|
|
|
|
|
{ |
641
|
|
|
|
|
|
|
@wps= split /\shypernym\s/, $roots[0]; |
642
|
|
|
|
|
|
|
$word = $wps[$#wps]; |
643
|
|
|
|
|
|
|
$y = $y-$diffy; |
644
|
|
|
|
|
|
|
if($miny>$y) |
645
|
|
|
|
|
|
|
{ |
646
|
|
|
|
|
|
|
$miny = $y; |
647
|
|
|
|
|
|
|
} |
648
|
|
|
|
|
|
|
if($maxy<$y) |
649
|
|
|
|
|
|
|
{ |
650
|
|
|
|
|
|
|
$maxy = $y; |
651
|
|
|
|
|
|
|
} |
652
|
|
|
|
|
|
|
if($minx>$x) |
653
|
|
|
|
|
|
|
{ |
654
|
|
|
|
|
|
|
$minx = $x; |
655
|
|
|
|
|
|
|
} |
656
|
|
|
|
|
|
|
if($maxx<$x) |
657
|
|
|
|
|
|
|
{ |
658
|
|
|
|
|
|
|
$maxx = $x; |
659
|
|
|
|
|
|
|
} |
660
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
661
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
662
|
|
|
|
|
|
|
$lcs_x=$x; |
663
|
|
|
|
|
|
|
$lcs_y=$y; |
664
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
665
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
666
|
|
|
|
|
|
|
{ |
667
|
|
|
|
|
|
|
$color = 'red'; |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
670
|
|
|
|
|
|
|
{ |
671
|
|
|
|
|
|
|
$color = 'dark green'; |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
else |
674
|
|
|
|
|
|
|
{ |
675
|
|
|
|
|
|
|
$color = 'purple'; |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Text", |
678
|
|
|
|
|
|
|
x => $x, |
679
|
|
|
|
|
|
|
y => $y, |
680
|
|
|
|
|
|
|
font => 'Sans 10', |
681
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
682
|
|
|
|
|
|
|
fill_color => $color, |
683
|
|
|
|
|
|
|
text => $word); |
684
|
|
|
|
|
|
|
if($word !~ /Root/) |
685
|
|
|
|
|
|
|
{ |
686
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
687
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
688
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
689
|
|
|
|
|
|
|
},$self); |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
} |
692
|
|
|
|
|
|
|
else |
693
|
|
|
|
|
|
|
{ |
694
|
|
|
|
|
|
|
$jflag=0; |
695
|
|
|
|
|
|
|
@wps= split /\shypernym\s/, $roots[0]; |
696
|
|
|
|
|
|
|
foreach $j (0...$#wps) |
697
|
|
|
|
|
|
|
{ |
698
|
|
|
|
|
|
|
$word = $wps[$j]; |
699
|
|
|
|
|
|
|
$y = $y-$diffy; |
700
|
|
|
|
|
|
|
if($miny>$y) |
701
|
|
|
|
|
|
|
{ |
702
|
|
|
|
|
|
|
$miny = $y; |
703
|
|
|
|
|
|
|
} |
704
|
|
|
|
|
|
|
if($maxy<$y) |
705
|
|
|
|
|
|
|
{ |
706
|
|
|
|
|
|
|
$maxy = $y; |
707
|
|
|
|
|
|
|
} |
708
|
|
|
|
|
|
|
if($minx>$x) |
709
|
|
|
|
|
|
|
{ |
710
|
|
|
|
|
|
|
$minx = $x; |
711
|
|
|
|
|
|
|
} |
712
|
|
|
|
|
|
|
if($maxx<$x) |
713
|
|
|
|
|
|
|
{ |
714
|
|
|
|
|
|
|
$maxx = $x; |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
if($j==0) |
717
|
|
|
|
|
|
|
{ |
718
|
|
|
|
|
|
|
$lcs_x=$x; |
719
|
|
|
|
|
|
|
$lcs_y=$y; |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
722
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
723
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
724
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
725
|
|
|
|
|
|
|
{ |
726
|
|
|
|
|
|
|
$color = 'red'; |
727
|
|
|
|
|
|
|
} |
728
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
729
|
|
|
|
|
|
|
{ |
730
|
|
|
|
|
|
|
$color = 'dark green'; |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
else |
733
|
|
|
|
|
|
|
{ |
734
|
|
|
|
|
|
|
$color = 'purple'; |
735
|
|
|
|
|
|
|
} |
736
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Text", |
737
|
|
|
|
|
|
|
x => $x, |
738
|
|
|
|
|
|
|
y => $y, |
739
|
|
|
|
|
|
|
font => 'Sans 10', |
740
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
741
|
|
|
|
|
|
|
fill_color => $color, |
742
|
|
|
|
|
|
|
text => $word); |
743
|
|
|
|
|
|
|
if($word !~ /Root/) |
744
|
|
|
|
|
|
|
{ |
745
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
746
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
747
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
748
|
|
|
|
|
|
|
},$self); |
749
|
|
|
|
|
|
|
} |
750
|
|
|
|
|
|
|
if($j>0) |
751
|
|
|
|
|
|
|
{ |
752
|
|
|
|
|
|
|
if($roots[0] =~ /$trace_strings[1]/ or $roots[0] =~ /$trace_strings[2]/) |
753
|
|
|
|
|
|
|
{ |
754
|
|
|
|
|
|
|
$line{$wps[$j-1]}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
755
|
|
|
|
|
|
|
points => [$prevx,$prevy-$diffy/5,$x,$y+$diffy/5], |
756
|
|
|
|
|
|
|
width_pixels => 1, |
757
|
|
|
|
|
|
|
last_arrowhead => 1, |
758
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
759
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
760
|
|
|
|
|
|
|
arrow_shape_c => 4, |
761
|
|
|
|
|
|
|
fill_color => 'blue', |
762
|
|
|
|
|
|
|
); |
763
|
|
|
|
|
|
|
} |
764
|
|
|
|
|
|
|
else |
765
|
|
|
|
|
|
|
{ |
766
|
|
|
|
|
|
|
$line{$wps[$j-1]}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
767
|
|
|
|
|
|
|
points => [$prevx,$prevy-$diffy/5,$x,$y+$diffy/5], |
768
|
|
|
|
|
|
|
width_pixels => 1, |
769
|
|
|
|
|
|
|
last_arrowhead => 1, |
770
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
771
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
772
|
|
|
|
|
|
|
arrow_shape_c => 4, |
773
|
|
|
|
|
|
|
fill_color => 'blue', |
774
|
|
|
|
|
|
|
line_style => 'on-off-dash' |
775
|
|
|
|
|
|
|
); |
776
|
|
|
|
|
|
|
} |
777
|
|
|
|
|
|
|
} |
778
|
|
|
|
|
|
|
$prevx = $x; |
779
|
|
|
|
|
|
|
$prevy = $y; |
780
|
|
|
|
|
|
|
} |
781
|
|
|
|
|
|
|
$diffx=0; |
782
|
|
|
|
|
|
|
} |
783
|
|
|
|
|
|
|
$x=$lcs_x; |
784
|
|
|
|
|
|
|
$y=$lcs_y; |
785
|
|
|
|
|
|
|
$prevx=$lcs_x; |
786
|
|
|
|
|
|
|
$prevy=$lcs_y; |
787
|
|
|
|
|
|
|
@wps= split /\shypernym\s/,$wps2_path; |
788
|
|
|
|
|
|
|
foreach $i (reverse 0...$#wps) |
789
|
|
|
|
|
|
|
{ |
790
|
|
|
|
|
|
|
$word = $wps[$i]; |
791
|
|
|
|
|
|
|
if(!exists $text{$word}) |
792
|
|
|
|
|
|
|
{ |
793
|
|
|
|
|
|
|
$x = $x+$diffx; |
794
|
|
|
|
|
|
|
$y = $y+$diffy; |
795
|
|
|
|
|
|
|
if($miny>$y) |
796
|
|
|
|
|
|
|
{ |
797
|
|
|
|
|
|
|
$miny = $y; |
798
|
|
|
|
|
|
|
} |
799
|
|
|
|
|
|
|
if($maxy<$y) |
800
|
|
|
|
|
|
|
{ |
801
|
|
|
|
|
|
|
$maxy = $y; |
802
|
|
|
|
|
|
|
} |
803
|
|
|
|
|
|
|
if($minx>$x) |
804
|
|
|
|
|
|
|
{ |
805
|
|
|
|
|
|
|
$minx = $x; |
806
|
|
|
|
|
|
|
} |
807
|
|
|
|
|
|
|
if($maxx<$x) |
808
|
|
|
|
|
|
|
{ |
809
|
|
|
|
|
|
|
$maxx = $x; |
810
|
|
|
|
|
|
|
} |
811
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
812
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
813
|
|
|
|
|
|
|
{ |
814
|
|
|
|
|
|
|
$color = 'red'; |
815
|
|
|
|
|
|
|
} |
816
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
817
|
|
|
|
|
|
|
{ |
818
|
|
|
|
|
|
|
$color = 'dark green'; |
819
|
|
|
|
|
|
|
} |
820
|
|
|
|
|
|
|
else |
821
|
|
|
|
|
|
|
{ |
822
|
|
|
|
|
|
|
$color = 'purple'; |
823
|
|
|
|
|
|
|
} |
824
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($shortest_path_group_wps2[$k], "Gnome2::Canvas::Text", |
825
|
|
|
|
|
|
|
x => $x, |
826
|
|
|
|
|
|
|
y => $y, |
827
|
|
|
|
|
|
|
fill_color => $color, |
828
|
|
|
|
|
|
|
font => 'Sans 10', |
829
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
830
|
|
|
|
|
|
|
text => $word); |
831
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
832
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
833
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
834
|
|
|
|
|
|
|
},$self); |
835
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
836
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
837
|
|
|
|
|
|
|
$line{$word}{$wps[$i+1]} = Gnome2::Canvas::Item->new($shortest_path_group_wps2[$k], "Gnome2::Canvas::Line", |
838
|
|
|
|
|
|
|
points => [$prevx,$prevy+$diffy/5,$x,$y-$diffy/5], |
839
|
|
|
|
|
|
|
width_pixels => 1, |
840
|
|
|
|
|
|
|
first_arrowhead => 1, |
841
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
842
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
843
|
|
|
|
|
|
|
arrow_shape_c => 4, |
844
|
|
|
|
|
|
|
fill_color => 'blue' |
845
|
|
|
|
|
|
|
); |
846
|
|
|
|
|
|
|
$prevx = $x; |
847
|
|
|
|
|
|
|
$prevy = $y; |
848
|
|
|
|
|
|
|
} |
849
|
|
|
|
|
|
|
else |
850
|
|
|
|
|
|
|
{ |
851
|
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2)=$text{$word}->get_bounds; |
852
|
|
|
|
|
|
|
$x = $x1 - 5; |
853
|
|
|
|
|
|
|
$y = $y2; |
854
|
|
|
|
|
|
|
$prevx = $x; |
855
|
|
|
|
|
|
|
$prevy = $y; |
856
|
|
|
|
|
|
|
$x = $x-60; |
857
|
|
|
|
|
|
|
$y = $y+10; |
858
|
|
|
|
|
|
|
next; |
859
|
|
|
|
|
|
|
} |
860
|
|
|
|
|
|
|
} |
861
|
|
|
|
|
|
|
$x=$lcs_x; |
862
|
|
|
|
|
|
|
$y=$lcs_y; |
863
|
|
|
|
|
|
|
$prevx=$lcs_x; |
864
|
|
|
|
|
|
|
$prevy=$lcs_y; |
865
|
|
|
|
|
|
|
$diffx=0; |
866
|
|
|
|
|
|
|
@wps= split /\shypernym\s/,$wps1_path; |
867
|
|
|
|
|
|
|
foreach $i (reverse 0...$#wps) |
868
|
|
|
|
|
|
|
{ |
869
|
|
|
|
|
|
|
$word = $wps[$i]; |
870
|
|
|
|
|
|
|
if(!exists $text{$word}) |
871
|
|
|
|
|
|
|
{ |
872
|
|
|
|
|
|
|
$x = $x+$diffx; |
873
|
|
|
|
|
|
|
$y = $y+$diffy; |
874
|
|
|
|
|
|
|
if($miny>$y) |
875
|
|
|
|
|
|
|
{ |
876
|
|
|
|
|
|
|
$miny = $y; |
877
|
|
|
|
|
|
|
} |
878
|
|
|
|
|
|
|
if($maxy<$y) |
879
|
|
|
|
|
|
|
{ |
880
|
|
|
|
|
|
|
$maxy = $y; |
881
|
|
|
|
|
|
|
} |
882
|
|
|
|
|
|
|
if($minx>$x) |
883
|
|
|
|
|
|
|
{ |
884
|
|
|
|
|
|
|
$minx = $x; |
885
|
|
|
|
|
|
|
} |
886
|
|
|
|
|
|
|
if($maxx<$x) |
887
|
|
|
|
|
|
|
{ |
888
|
|
|
|
|
|
|
$maxx = $x; |
889
|
|
|
|
|
|
|
} |
890
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
891
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
892
|
|
|
|
|
|
|
{ |
893
|
|
|
|
|
|
|
$color = 'red'; |
894
|
|
|
|
|
|
|
} |
895
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
896
|
|
|
|
|
|
|
{ |
897
|
|
|
|
|
|
|
$color = 'dark green'; |
898
|
|
|
|
|
|
|
} |
899
|
|
|
|
|
|
|
else |
900
|
|
|
|
|
|
|
{ |
901
|
|
|
|
|
|
|
$color = 'purple'; |
902
|
|
|
|
|
|
|
} |
903
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($shortest_path_group_wps1[$k], "Gnome2::Canvas::Text", |
904
|
|
|
|
|
|
|
x => $x, |
905
|
|
|
|
|
|
|
y => $y, |
906
|
|
|
|
|
|
|
fill_color => $color, |
907
|
|
|
|
|
|
|
font => 'Sans 10', |
908
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
909
|
|
|
|
|
|
|
text => $word); |
910
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
911
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
912
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
913
|
|
|
|
|
|
|
},$self); |
914
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
915
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
916
|
|
|
|
|
|
|
$line{$word}{$wps[$i+1]} = Gnome2::Canvas::Item->new($shortest_path_group_wps1[$k], "Gnome2::Canvas::Line", |
917
|
|
|
|
|
|
|
points => [$prevx,$prevy+$diffy/5,$x,$y-$diffy/5], |
918
|
|
|
|
|
|
|
width_pixels => 1, |
919
|
|
|
|
|
|
|
first_arrowhead => 1, |
920
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
921
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
922
|
|
|
|
|
|
|
arrow_shape_c => 4, |
923
|
|
|
|
|
|
|
fill_color => 'blue' |
924
|
|
|
|
|
|
|
); |
925
|
|
|
|
|
|
|
$prevx = $x; |
926
|
|
|
|
|
|
|
$prevy = $y; |
927
|
|
|
|
|
|
|
} |
928
|
|
|
|
|
|
|
else |
929
|
|
|
|
|
|
|
{ |
930
|
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2)=$text{$word}->get_bounds; |
931
|
|
|
|
|
|
|
$x = $x2 + 5; |
932
|
|
|
|
|
|
|
$y = $y2; |
933
|
|
|
|
|
|
|
$prevx = $x; |
934
|
|
|
|
|
|
|
$prevy = $y; |
935
|
|
|
|
|
|
|
$x = $x+60; |
936
|
|
|
|
|
|
|
$y = $y+10; |
937
|
|
|
|
|
|
|
next; |
938
|
|
|
|
|
|
|
} |
939
|
|
|
|
|
|
|
} |
940
|
|
|
|
|
|
|
$hx = abs($maxx-$minx)+100; |
941
|
|
|
|
|
|
|
$hy = abs($maxy-$miny)+80; |
942
|
|
|
|
|
|
|
$canvas[$k]->set_size_request($hx,$hy); |
943
|
|
|
|
|
|
|
$canvas[$k]->set_scroll_region (0, 0, $hx, $hy); |
944
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(x=>abs($minx)+60); |
945
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(y=>abs($miny)+10); |
946
|
|
|
|
|
|
|
$minx = $k+1; |
947
|
|
|
|
|
|
|
if($mpflag) |
948
|
|
|
|
|
|
|
{ |
949
|
|
|
|
|
|
|
$notebook->append_page($canvas[$k], "Path ".$minx); |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
else |
952
|
|
|
|
|
|
|
{ |
953
|
|
|
|
|
|
|
$notebook->add($canvas[0]); |
954
|
|
|
|
|
|
|
} |
955
|
|
|
|
|
|
|
$k++; |
956
|
|
|
|
|
|
|
} |
957
|
|
|
|
|
|
|
} |
958
|
|
|
|
|
|
|
$self->{ canvas } = $canvas[0]; |
959
|
|
|
|
|
|
|
} |
960
|
|
|
|
|
|
|
elsif($trace_strings[0]=~/wup/) |
961
|
|
|
|
|
|
|
{ |
962
|
|
|
|
|
|
|
my @temp = split /\s=\s/, $trace_strings[$#trace_strings-2]; |
963
|
|
|
|
|
|
|
my $word1 = $temp[0]; |
964
|
|
|
|
|
|
|
my $word_lcs_flag; |
965
|
|
|
|
|
|
|
@temp = split /\s=\s/, $trace_strings[$#trace_strings]; |
966
|
|
|
|
|
|
|
my $lcs = $temp[0]; |
967
|
|
|
|
|
|
|
@temp = split /\s=\s/, $trace_strings[$#trace_strings-1]; |
968
|
|
|
|
|
|
|
my $word2 = $temp[0]; |
969
|
|
|
|
|
|
|
my $sub; |
970
|
|
|
|
|
|
|
my @trees = grep /\shypernym\s/, @trace_strings; |
971
|
|
|
|
|
|
|
my @syns1; |
972
|
|
|
|
|
|
|
my @syns2; |
973
|
|
|
|
|
|
|
my $syn; |
974
|
|
|
|
|
|
|
my @mult_wps1_path; |
975
|
|
|
|
|
|
|
@syns1 = $self->{ querydata_interface }->find_allsyns($word1); |
976
|
|
|
|
|
|
|
my $syns_group = join " ",@syns1; |
977
|
|
|
|
|
|
|
foreach $syn (@syns1) |
978
|
|
|
|
|
|
|
{ |
979
|
|
|
|
|
|
|
push @mult_wps1_path, grep(/\b$syn\b/, @trees); |
980
|
|
|
|
|
|
|
} |
981
|
|
|
|
|
|
|
my @mult_wps2_path; |
982
|
|
|
|
|
|
|
@syns2 = $self->{ querydata_interface }->find_allsyns($word2); |
983
|
|
|
|
|
|
|
foreach $syn (@syns2) |
984
|
|
|
|
|
|
|
{ |
985
|
|
|
|
|
|
|
push @mult_wps2_path, grep(/\b$syn\b/, @trees); |
986
|
|
|
|
|
|
|
} |
987
|
|
|
|
|
|
|
if($#mult_wps1_path+$#mult_wps2_path+1>1) |
988
|
|
|
|
|
|
|
{ |
989
|
|
|
|
|
|
|
$notebook = Gtk2::Notebook->new; |
990
|
|
|
|
|
|
|
# $notebook->signal_connect(switch_page=>sub { |
991
|
|
|
|
|
|
|
# my ($self,$gui) = @_; |
992
|
|
|
|
|
|
|
# my $child=$self->get_current_page; |
993
|
|
|
|
|
|
|
# my @children = $self->get_children; |
994
|
|
|
|
|
|
|
# $gui->{ canvas }= $children[$child]; |
995
|
|
|
|
|
|
|
# },$self); |
996
|
|
|
|
|
|
|
$mpflag = 1; |
997
|
|
|
|
|
|
|
} |
998
|
|
|
|
|
|
|
else |
999
|
|
|
|
|
|
|
{ |
1000
|
|
|
|
|
|
|
$notebook = Gtk2::VBox->new; |
1001
|
|
|
|
|
|
|
} |
1002
|
|
|
|
|
|
|
my $lcsflag=0; |
1003
|
|
|
|
|
|
|
$syn = join " ",@syns1; |
1004
|
|
|
|
|
|
|
if($syn =~ /\b$word2\b/) |
1005
|
|
|
|
|
|
|
{ |
1006
|
|
|
|
|
|
|
foreach $wps1_path (@mult_wps1_path) |
1007
|
|
|
|
|
|
|
{ |
1008
|
|
|
|
|
|
|
$lcsflag=0; |
1009
|
|
|
|
|
|
|
$x=0; |
1010
|
|
|
|
|
|
|
$y=0; |
1011
|
|
|
|
|
|
|
$maxx=0; |
1012
|
|
|
|
|
|
|
$maxy=0; |
1013
|
|
|
|
|
|
|
$minx=0; |
1014
|
|
|
|
|
|
|
$miny=0; |
1015
|
|
|
|
|
|
|
$canvas[$k] = Gnome2::Canvas->new; |
1016
|
|
|
|
|
|
|
$canvas_root[$k] = $canvas[$k]->root; |
1017
|
|
|
|
|
|
|
$shortest_path_group[$k] = Gnome2::Canvas::Item->new($canvas_root[$k], "Gnome2::Canvas::Group"); |
1018
|
|
|
|
|
|
|
$root_group[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1019
|
|
|
|
|
|
|
$shortest_path_group_wps1[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1020
|
|
|
|
|
|
|
$shortest_path_group_wps2[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1021
|
|
|
|
|
|
|
%text=(); |
1022
|
|
|
|
|
|
|
%line=(); |
1023
|
|
|
|
|
|
|
$diffy = 40; |
1024
|
|
|
|
|
|
|
$diffx = 0; |
1025
|
|
|
|
|
|
|
$jflag=0; |
1026
|
|
|
|
|
|
|
@wps= split /\shypernym\s/, $wps1_path; |
1027
|
|
|
|
|
|
|
foreach $j (0...$#wps) |
1028
|
|
|
|
|
|
|
{ |
1029
|
|
|
|
|
|
|
$word = $wps[$j]; |
1030
|
|
|
|
|
|
|
$y = $y-$diffy; |
1031
|
|
|
|
|
|
|
if($miny>$y) |
1032
|
|
|
|
|
|
|
{ |
1033
|
|
|
|
|
|
|
$miny = $y; |
1034
|
|
|
|
|
|
|
} |
1035
|
|
|
|
|
|
|
if($maxy<$y) |
1036
|
|
|
|
|
|
|
{ |
1037
|
|
|
|
|
|
|
$maxy = $y; |
1038
|
|
|
|
|
|
|
} |
1039
|
|
|
|
|
|
|
if($minx>$x) |
1040
|
|
|
|
|
|
|
{ |
1041
|
|
|
|
|
|
|
$minx = $x; |
1042
|
|
|
|
|
|
|
} |
1043
|
|
|
|
|
|
|
if($maxx<$x) |
1044
|
|
|
|
|
|
|
{ |
1045
|
|
|
|
|
|
|
$maxx = $x; |
1046
|
|
|
|
|
|
|
} |
1047
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
1048
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
1049
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
1050
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
1051
|
|
|
|
|
|
|
{ |
1052
|
|
|
|
|
|
|
$color = 'red'; |
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
1055
|
|
|
|
|
|
|
{ |
1056
|
|
|
|
|
|
|
$color = 'dark green'; |
1057
|
|
|
|
|
|
|
} |
1058
|
|
|
|
|
|
|
else |
1059
|
|
|
|
|
|
|
{ |
1060
|
|
|
|
|
|
|
$color = 'purple'; |
1061
|
|
|
|
|
|
|
} |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Text", |
1064
|
|
|
|
|
|
|
x => $x, |
1065
|
|
|
|
|
|
|
y => $y, |
1066
|
|
|
|
|
|
|
fill_color => $color, |
1067
|
|
|
|
|
|
|
font => 'Sans 10', |
1068
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
1069
|
|
|
|
|
|
|
text => $word); |
1070
|
|
|
|
|
|
|
if($word !~ /Root/) |
1071
|
|
|
|
|
|
|
{ |
1072
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
1073
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
1074
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
1075
|
|
|
|
|
|
|
},$self); |
1076
|
|
|
|
|
|
|
} |
1077
|
|
|
|
|
|
|
if($j>0) |
1078
|
|
|
|
|
|
|
{ |
1079
|
|
|
|
|
|
|
$sub=0; |
1080
|
|
|
|
|
|
|
$line{$wps[$j-1]}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
1081
|
|
|
|
|
|
|
points => [$prevx,$prevy-$diffy/5,$x+$sub,$y+$diffy/5], |
1082
|
|
|
|
|
|
|
width_pixels => 1, |
1083
|
|
|
|
|
|
|
last_arrowhead => 1, |
1084
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1085
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1086
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1087
|
|
|
|
|
|
|
fill_color => 'blue' |
1088
|
|
|
|
|
|
|
); |
1089
|
|
|
|
|
|
|
} |
1090
|
|
|
|
|
|
|
$prevx = $x; |
1091
|
|
|
|
|
|
|
$prevy = $y; |
1092
|
|
|
|
|
|
|
} |
1093
|
|
|
|
|
|
|
$hx = abs($maxx-$minx)+100; |
1094
|
|
|
|
|
|
|
$hy = abs($maxy-$miny)+80; |
1095
|
|
|
|
|
|
|
$canvas[$k]->set_size_request($hx,$hy); |
1096
|
|
|
|
|
|
|
$canvas[$k]->set_scroll_region (0, 0, $hx, $hy); |
1097
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(x=>abs($minx)+60); |
1098
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(y=>abs($miny)+10); |
1099
|
|
|
|
|
|
|
$minx = $k+1; |
1100
|
|
|
|
|
|
|
if($mpflag) |
1101
|
|
|
|
|
|
|
{ |
1102
|
|
|
|
|
|
|
$notebook->append_page($canvas[$k], "Path ".$minx); |
1103
|
|
|
|
|
|
|
} |
1104
|
|
|
|
|
|
|
else |
1105
|
|
|
|
|
|
|
{ |
1106
|
|
|
|
|
|
|
$notebook->add($canvas[0]); |
1107
|
|
|
|
|
|
|
} |
1108
|
|
|
|
|
|
|
$k++; |
1109
|
|
|
|
|
|
|
} |
1110
|
|
|
|
|
|
|
} |
1111
|
|
|
|
|
|
|
else |
1112
|
|
|
|
|
|
|
{ |
1113
|
|
|
|
|
|
|
foreach $wps1_path (@mult_wps1_path) |
1114
|
|
|
|
|
|
|
{ |
1115
|
|
|
|
|
|
|
foreach $wps2_path (@mult_wps2_path) |
1116
|
|
|
|
|
|
|
{ |
1117
|
|
|
|
|
|
|
if($wps1_path !~ /wps2_path/ and length($wps1_path)>1 and length($wps2_path)>1) |
1118
|
|
|
|
|
|
|
{ |
1119
|
|
|
|
|
|
|
$lcsflag=0; |
1120
|
|
|
|
|
|
|
$x=0; |
1121
|
|
|
|
|
|
|
$y=0; |
1122
|
|
|
|
|
|
|
$maxx=0; |
1123
|
|
|
|
|
|
|
$maxy=0; |
1124
|
|
|
|
|
|
|
$minx=0; |
1125
|
|
|
|
|
|
|
$miny=0; |
1126
|
|
|
|
|
|
|
$canvas[$k] = Gnome2::Canvas->new; |
1127
|
|
|
|
|
|
|
$canvas_root[$k] = $canvas[$k]->root; |
1128
|
|
|
|
|
|
|
$shortest_path_group[$k] = Gnome2::Canvas::Item->new($canvas_root[$k], "Gnome2::Canvas::Group"); |
1129
|
|
|
|
|
|
|
$root_group[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1130
|
|
|
|
|
|
|
$shortest_path_group_wps1[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1131
|
|
|
|
|
|
|
$shortest_path_group_wps2[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1132
|
|
|
|
|
|
|
%text=(); |
1133
|
|
|
|
|
|
|
%line=(); |
1134
|
|
|
|
|
|
|
$diffy = 40; |
1135
|
|
|
|
|
|
|
$diffx = 0; |
1136
|
|
|
|
|
|
|
$jflag=0; |
1137
|
|
|
|
|
|
|
@wps= split /\shypernym\s/, $wps1_path; |
1138
|
|
|
|
|
|
|
foreach $j (0...$#wps) |
1139
|
|
|
|
|
|
|
{ |
1140
|
|
|
|
|
|
|
$word = $wps[$j]; |
1141
|
|
|
|
|
|
|
if($wps2_path=~/$word/) |
1142
|
|
|
|
|
|
|
{ |
1143
|
|
|
|
|
|
|
if($lcsflag==0) |
1144
|
|
|
|
|
|
|
{ |
1145
|
|
|
|
|
|
|
$lcs = $word; |
1146
|
|
|
|
|
|
|
$x=$x-length($word)*9; |
1147
|
|
|
|
|
|
|
$lcs_x=$x; |
1148
|
|
|
|
|
|
|
$lcs_y=$y-$diffy; |
1149
|
|
|
|
|
|
|
} |
1150
|
|
|
|
|
|
|
} |
1151
|
|
|
|
|
|
|
$y = $y-$diffy; |
1152
|
|
|
|
|
|
|
if($miny>$y) |
1153
|
|
|
|
|
|
|
{ |
1154
|
|
|
|
|
|
|
$miny = $y; |
1155
|
|
|
|
|
|
|
} |
1156
|
|
|
|
|
|
|
if($maxy<$y) |
1157
|
|
|
|
|
|
|
{ |
1158
|
|
|
|
|
|
|
$maxy = $y; |
1159
|
|
|
|
|
|
|
} |
1160
|
|
|
|
|
|
|
if($minx>$x) |
1161
|
|
|
|
|
|
|
{ |
1162
|
|
|
|
|
|
|
$minx = $x; |
1163
|
|
|
|
|
|
|
} |
1164
|
|
|
|
|
|
|
if($maxx<$x) |
1165
|
|
|
|
|
|
|
{ |
1166
|
|
|
|
|
|
|
$maxx = $x; |
1167
|
|
|
|
|
|
|
} |
1168
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
1169
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
1170
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
1171
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
1172
|
|
|
|
|
|
|
{ |
1173
|
|
|
|
|
|
|
$color = 'red'; |
1174
|
|
|
|
|
|
|
} |
1175
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
1176
|
|
|
|
|
|
|
{ |
1177
|
|
|
|
|
|
|
$color = 'dark green'; |
1178
|
|
|
|
|
|
|
} |
1179
|
|
|
|
|
|
|
else |
1180
|
|
|
|
|
|
|
{ |
1181
|
|
|
|
|
|
|
$color = 'purple'; |
1182
|
|
|
|
|
|
|
} |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Text", |
1185
|
|
|
|
|
|
|
x => $x, |
1186
|
|
|
|
|
|
|
y => $y, |
1187
|
|
|
|
|
|
|
fill_color => $color, |
1188
|
|
|
|
|
|
|
font => 'Sans 10', |
1189
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
1190
|
|
|
|
|
|
|
text => $word); |
1191
|
|
|
|
|
|
|
if($word !~ /Root/) |
1192
|
|
|
|
|
|
|
{ |
1193
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
1194
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
1195
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
1196
|
|
|
|
|
|
|
},$self); |
1197
|
|
|
|
|
|
|
} |
1198
|
|
|
|
|
|
|
if($j>0) |
1199
|
|
|
|
|
|
|
{ |
1200
|
|
|
|
|
|
|
$sub=0; |
1201
|
|
|
|
|
|
|
if($wps2_path=~/$word/) |
1202
|
|
|
|
|
|
|
{ |
1203
|
|
|
|
|
|
|
if($lcsflag==0) |
1204
|
|
|
|
|
|
|
{ |
1205
|
|
|
|
|
|
|
$sub=length($word)*3; |
1206
|
|
|
|
|
|
|
$lcsflag=1; |
1207
|
|
|
|
|
|
|
} |
1208
|
|
|
|
|
|
|
} |
1209
|
|
|
|
|
|
|
$line{$wps[$j-1]}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
1210
|
|
|
|
|
|
|
points => [$prevx,$prevy-$diffy/5,$x+$sub,$y+$diffy/5], |
1211
|
|
|
|
|
|
|
width_pixels => 1, |
1212
|
|
|
|
|
|
|
last_arrowhead => 1, |
1213
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1214
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1215
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1216
|
|
|
|
|
|
|
fill_color => 'blue' |
1217
|
|
|
|
|
|
|
); |
1218
|
|
|
|
|
|
|
} |
1219
|
|
|
|
|
|
|
$prevx = $x; |
1220
|
|
|
|
|
|
|
$prevy = $y; |
1221
|
|
|
|
|
|
|
} |
1222
|
|
|
|
|
|
|
$diffx=0; |
1223
|
|
|
|
|
|
|
@wps= split /\shypernym\s/,$wps2_path; |
1224
|
|
|
|
|
|
|
$word_lcs_flag=0; |
1225
|
|
|
|
|
|
|
$x=$lcs_x; |
1226
|
|
|
|
|
|
|
$y=$lcs_y; |
1227
|
|
|
|
|
|
|
$prevx = $x-length($lcs)*3; |
1228
|
|
|
|
|
|
|
$prevy = $y; |
1229
|
|
|
|
|
|
|
foreach $i (reverse 0...$#wps) |
1230
|
|
|
|
|
|
|
{ |
1231
|
|
|
|
|
|
|
$word = $wps[$i]; |
1232
|
|
|
|
|
|
|
if($word_lcs_flag==1) |
1233
|
|
|
|
|
|
|
{ |
1234
|
|
|
|
|
|
|
if(!exists $text{$word}) |
1235
|
|
|
|
|
|
|
{ |
1236
|
|
|
|
|
|
|
$x = $x+$diffx; |
1237
|
|
|
|
|
|
|
$y = $y+$diffy; |
1238
|
|
|
|
|
|
|
if($miny>$y) |
1239
|
|
|
|
|
|
|
{ |
1240
|
|
|
|
|
|
|
$miny = $y; |
1241
|
|
|
|
|
|
|
} |
1242
|
|
|
|
|
|
|
if($maxy<$y) |
1243
|
|
|
|
|
|
|
{ |
1244
|
|
|
|
|
|
|
$maxy = $y; |
1245
|
|
|
|
|
|
|
} |
1246
|
|
|
|
|
|
|
if($minx>$x) |
1247
|
|
|
|
|
|
|
{ |
1248
|
|
|
|
|
|
|
$minx = $x; |
1249
|
|
|
|
|
|
|
} |
1250
|
|
|
|
|
|
|
if($maxx<$x) |
1251
|
|
|
|
|
|
|
{ |
1252
|
|
|
|
|
|
|
$maxx = $x; |
1253
|
|
|
|
|
|
|
} |
1254
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
1255
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
1256
|
|
|
|
|
|
|
{ |
1257
|
|
|
|
|
|
|
$color = 'red'; |
1258
|
|
|
|
|
|
|
} |
1259
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
1260
|
|
|
|
|
|
|
{ |
1261
|
|
|
|
|
|
|
$color = 'dark green'; |
1262
|
|
|
|
|
|
|
} |
1263
|
|
|
|
|
|
|
else |
1264
|
|
|
|
|
|
|
{ |
1265
|
|
|
|
|
|
|
$color = 'purple'; |
1266
|
|
|
|
|
|
|
} |
1267
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($shortest_path_group_wps2[$k], "Gnome2::Canvas::Text", |
1268
|
|
|
|
|
|
|
x => $x, |
1269
|
|
|
|
|
|
|
y => $y, |
1270
|
|
|
|
|
|
|
fill_color => $color, |
1271
|
|
|
|
|
|
|
font => 'Sans 10', |
1272
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
1273
|
|
|
|
|
|
|
text => $word); |
1274
|
|
|
|
|
|
|
if($word !~ /Root/) |
1275
|
|
|
|
|
|
|
{ |
1276
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
1277
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
1278
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
1279
|
|
|
|
|
|
|
},$self); } |
1280
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
1281
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
1282
|
|
|
|
|
|
|
$line{$word}{$wps[$i+1]} = Gnome2::Canvas::Item->new($shortest_path_group_wps2[$k], "Gnome2::Canvas::Line", |
1283
|
|
|
|
|
|
|
points => [$prevx,$prevy+$diffy/5,$x,$y-$diffy/5], |
1284
|
|
|
|
|
|
|
width_pixels => 1, |
1285
|
|
|
|
|
|
|
first_arrowhead => 1, |
1286
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1287
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1288
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1289
|
|
|
|
|
|
|
fill_color => 'blue' |
1290
|
|
|
|
|
|
|
); |
1291
|
|
|
|
|
|
|
$prevx = $x; |
1292
|
|
|
|
|
|
|
$prevy = $y; |
1293
|
|
|
|
|
|
|
} |
1294
|
|
|
|
|
|
|
else |
1295
|
|
|
|
|
|
|
{ |
1296
|
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2)=$text{$word}->get_bounds; |
1297
|
|
|
|
|
|
|
$x = $x1 - 5; |
1298
|
|
|
|
|
|
|
$y = $y2; |
1299
|
|
|
|
|
|
|
$prevx = $x; |
1300
|
|
|
|
|
|
|
$prevy = $y; |
1301
|
|
|
|
|
|
|
$x = $x-60; |
1302
|
|
|
|
|
|
|
$y = $y+10; |
1303
|
|
|
|
|
|
|
next; |
1304
|
|
|
|
|
|
|
} |
1305
|
|
|
|
|
|
|
} |
1306
|
|
|
|
|
|
|
elsif($lcs =~ /$word/) |
1307
|
|
|
|
|
|
|
{ |
1308
|
|
|
|
|
|
|
$x = $x-length($lcs)*6; |
1309
|
|
|
|
|
|
|
$word_lcs_flag=1; |
1310
|
|
|
|
|
|
|
} |
1311
|
|
|
|
|
|
|
} |
1312
|
|
|
|
|
|
|
$hx = abs($maxx-$minx)+100; |
1313
|
|
|
|
|
|
|
$hy = abs($maxy-$miny)+80; |
1314
|
|
|
|
|
|
|
$canvas[$k]->set_size_request($hx,$hy); |
1315
|
|
|
|
|
|
|
$canvas[$k]->set_scroll_region (0, 0, $hx, $hy); |
1316
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(x=>abs($minx)+60); |
1317
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(y=>abs($miny)+10); |
1318
|
|
|
|
|
|
|
$minx = $k+1; |
1319
|
|
|
|
|
|
|
if($mpflag) |
1320
|
|
|
|
|
|
|
{ |
1321
|
|
|
|
|
|
|
$notebook->append_page($canvas[$k], "Path ".$minx); |
1322
|
|
|
|
|
|
|
} |
1323
|
|
|
|
|
|
|
else |
1324
|
|
|
|
|
|
|
{ |
1325
|
|
|
|
|
|
|
$notebook->add($canvas[0]); |
1326
|
|
|
|
|
|
|
} |
1327
|
|
|
|
|
|
|
$k++; |
1328
|
|
|
|
|
|
|
} |
1329
|
|
|
|
|
|
|
} |
1330
|
|
|
|
|
|
|
} |
1331
|
|
|
|
|
|
|
} |
1332
|
|
|
|
|
|
|
$self->{ canvas } = $canvas[0]; |
1333
|
|
|
|
|
|
|
} |
1334
|
|
|
|
|
|
|
elsif($trace_strings[0]=~/lch/) |
1335
|
|
|
|
|
|
|
{ |
1336
|
|
|
|
|
|
|
$k=-1; |
1337
|
|
|
|
|
|
|
if($#trace_strings>3) |
1338
|
|
|
|
|
|
|
{ |
1339
|
|
|
|
|
|
|
$notebook = Gtk2::Notebook->new; |
1340
|
|
|
|
|
|
|
# $notebook->signal_connect(switch_page=>sub { |
1341
|
|
|
|
|
|
|
# my ($self,$gui) = @_; |
1342
|
|
|
|
|
|
|
# my $child=$self->get_current_page; |
1343
|
|
|
|
|
|
|
# my @children = $self->get_children; |
1344
|
|
|
|
|
|
|
# $gui->{ canvas }= $children[$child]; |
1345
|
|
|
|
|
|
|
# },$self); |
1346
|
|
|
|
|
|
|
$mpflag = 1; |
1347
|
|
|
|
|
|
|
} |
1348
|
|
|
|
|
|
|
else |
1349
|
|
|
|
|
|
|
{ |
1350
|
|
|
|
|
|
|
$notebook = Gtk2::VBox->new; |
1351
|
|
|
|
|
|
|
} |
1352
|
|
|
|
|
|
|
$i=0; |
1353
|
|
|
|
|
|
|
my $sub=0; |
1354
|
|
|
|
|
|
|
my $lcsflag=0; |
1355
|
|
|
|
|
|
|
foreach $i (1...$#trace_strings-1) |
1356
|
|
|
|
|
|
|
{ |
1357
|
|
|
|
|
|
|
if($i%2==1) |
1358
|
|
|
|
|
|
|
{ |
1359
|
|
|
|
|
|
|
$k++; |
1360
|
|
|
|
|
|
|
$x=0; |
1361
|
|
|
|
|
|
|
$y=0; |
1362
|
|
|
|
|
|
|
$maxx=0; |
1363
|
|
|
|
|
|
|
$maxy=0; |
1364
|
|
|
|
|
|
|
$minx=0; |
1365
|
|
|
|
|
|
|
$miny=0; |
1366
|
|
|
|
|
|
|
$canvas[$k] = Gnome2::Canvas->new; |
1367
|
|
|
|
|
|
|
$canvas_root[$k] = $canvas[$k]->root; |
1368
|
|
|
|
|
|
|
$shortest_path_group[$k] = Gnome2::Canvas::Item->new($canvas_root[$k], "Gnome2::Canvas::Group"); |
1369
|
|
|
|
|
|
|
$root_group[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1370
|
|
|
|
|
|
|
$shortest_path_group_wps1[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1371
|
|
|
|
|
|
|
$shortest_path_group_wps2[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1372
|
|
|
|
|
|
|
%text=(); |
1373
|
|
|
|
|
|
|
%line=(); |
1374
|
|
|
|
|
|
|
$diffy = 40; |
1375
|
|
|
|
|
|
|
$diffx = 0; |
1376
|
|
|
|
|
|
|
$lcsflag=0; |
1377
|
|
|
|
|
|
|
$jflag=0; |
1378
|
|
|
|
|
|
|
@wps= split /\shypernym\s/, $trace_strings[$i]; |
1379
|
|
|
|
|
|
|
$diffx=0; |
1380
|
|
|
|
|
|
|
foreach $j (0...$#wps) |
1381
|
|
|
|
|
|
|
{ |
1382
|
|
|
|
|
|
|
$word = $wps[$j]; |
1383
|
|
|
|
|
|
|
$y = $y-$diffy; |
1384
|
|
|
|
|
|
|
if($j==$#wps) |
1385
|
|
|
|
|
|
|
{ |
1386
|
|
|
|
|
|
|
if($lcsflag==0) |
1387
|
|
|
|
|
|
|
{ |
1388
|
|
|
|
|
|
|
$x=$x-length($word)*9; |
1389
|
|
|
|
|
|
|
} |
1390
|
|
|
|
|
|
|
} |
1391
|
|
|
|
|
|
|
if($miny>$y) |
1392
|
|
|
|
|
|
|
{ |
1393
|
|
|
|
|
|
|
$miny = $y; |
1394
|
|
|
|
|
|
|
} |
1395
|
|
|
|
|
|
|
if($maxy<$y) |
1396
|
|
|
|
|
|
|
{ |
1397
|
|
|
|
|
|
|
$maxy = $y; |
1398
|
|
|
|
|
|
|
} |
1399
|
|
|
|
|
|
|
if($minx>$x) |
1400
|
|
|
|
|
|
|
{ |
1401
|
|
|
|
|
|
|
$minx = $x; |
1402
|
|
|
|
|
|
|
} |
1403
|
|
|
|
|
|
|
if($maxx<$x) |
1404
|
|
|
|
|
|
|
{ |
1405
|
|
|
|
|
|
|
$maxx = $x; |
1406
|
|
|
|
|
|
|
} |
1407
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
1408
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
1409
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
1410
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
1411
|
|
|
|
|
|
|
{ |
1412
|
|
|
|
|
|
|
$color = 'red'; |
1413
|
|
|
|
|
|
|
} |
1414
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
1415
|
|
|
|
|
|
|
{ |
1416
|
|
|
|
|
|
|
$color = 'dark green'; |
1417
|
|
|
|
|
|
|
} |
1418
|
|
|
|
|
|
|
else |
1419
|
|
|
|
|
|
|
{ |
1420
|
|
|
|
|
|
|
$color = 'purple'; |
1421
|
|
|
|
|
|
|
} |
1422
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Text", |
1423
|
|
|
|
|
|
|
x => $x, |
1424
|
|
|
|
|
|
|
y => $y, |
1425
|
|
|
|
|
|
|
fill_color => $color, |
1426
|
|
|
|
|
|
|
font => 'Sans 10', |
1427
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
1428
|
|
|
|
|
|
|
text => $word); |
1429
|
|
|
|
|
|
|
if($word !~ /Root/) |
1430
|
|
|
|
|
|
|
{ |
1431
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
1432
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
1433
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
1434
|
|
|
|
|
|
|
},$self); |
1435
|
|
|
|
|
|
|
} |
1436
|
|
|
|
|
|
|
if($j>0) |
1437
|
|
|
|
|
|
|
{ |
1438
|
|
|
|
|
|
|
$sub=0; |
1439
|
|
|
|
|
|
|
if($j==$#wps) |
1440
|
|
|
|
|
|
|
{ |
1441
|
|
|
|
|
|
|
if($lcsflag==0) |
1442
|
|
|
|
|
|
|
{ |
1443
|
|
|
|
|
|
|
$sub=length($word)*3; |
1444
|
|
|
|
|
|
|
$lcsflag=1; |
1445
|
|
|
|
|
|
|
} |
1446
|
|
|
|
|
|
|
} |
1447
|
|
|
|
|
|
|
$line{$wps[$j-1]}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
1448
|
|
|
|
|
|
|
points => [$prevx,$prevy-$diffy/5,$x+$sub,$y+$diffy/5], |
1449
|
|
|
|
|
|
|
width_pixels => 1, |
1450
|
|
|
|
|
|
|
last_arrowhead => 1, |
1451
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1452
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1453
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1454
|
|
|
|
|
|
|
fill_color => 'blue' |
1455
|
|
|
|
|
|
|
); |
1456
|
|
|
|
|
|
|
} |
1457
|
|
|
|
|
|
|
$prevx = $x; |
1458
|
|
|
|
|
|
|
$prevy = $y; |
1459
|
|
|
|
|
|
|
} |
1460
|
|
|
|
|
|
|
} |
1461
|
|
|
|
|
|
|
else |
1462
|
|
|
|
|
|
|
{ |
1463
|
|
|
|
|
|
|
$diffx=0; |
1464
|
|
|
|
|
|
|
@wps= split /\shypernym\s/,$trace_strings[$i]; |
1465
|
|
|
|
|
|
|
foreach $i (reverse 0...$#wps) |
1466
|
|
|
|
|
|
|
{ |
1467
|
|
|
|
|
|
|
$word = $wps[$i]; |
1468
|
|
|
|
|
|
|
if(!exists $text{$word}) |
1469
|
|
|
|
|
|
|
{ |
1470
|
|
|
|
|
|
|
$x = $x+$diffx; |
1471
|
|
|
|
|
|
|
$y = $y+$diffy; |
1472
|
|
|
|
|
|
|
if($miny>$y) |
1473
|
|
|
|
|
|
|
{ |
1474
|
|
|
|
|
|
|
$miny = $y; |
1475
|
|
|
|
|
|
|
} |
1476
|
|
|
|
|
|
|
if($maxy<$y) |
1477
|
|
|
|
|
|
|
{ |
1478
|
|
|
|
|
|
|
$maxy = $y; |
1479
|
|
|
|
|
|
|
} |
1480
|
|
|
|
|
|
|
if($minx>$x) |
1481
|
|
|
|
|
|
|
{ |
1482
|
|
|
|
|
|
|
$minx = $x; |
1483
|
|
|
|
|
|
|
} |
1484
|
|
|
|
|
|
|
if($maxx<$x) |
1485
|
|
|
|
|
|
|
{ |
1486
|
|
|
|
|
|
|
$maxx = $x; |
1487
|
|
|
|
|
|
|
} |
1488
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
1489
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
1490
|
|
|
|
|
|
|
{ |
1491
|
|
|
|
|
|
|
$color = 'red'; |
1492
|
|
|
|
|
|
|
} |
1493
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
1494
|
|
|
|
|
|
|
{ |
1495
|
|
|
|
|
|
|
$color = 'dark green'; |
1496
|
|
|
|
|
|
|
} |
1497
|
|
|
|
|
|
|
else |
1498
|
|
|
|
|
|
|
{ |
1499
|
|
|
|
|
|
|
$color = 'purple'; |
1500
|
|
|
|
|
|
|
} |
1501
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($shortest_path_group_wps2[$k], "Gnome2::Canvas::Text", |
1502
|
|
|
|
|
|
|
x => $x, |
1503
|
|
|
|
|
|
|
y => $y, |
1504
|
|
|
|
|
|
|
fill_color => $color, |
1505
|
|
|
|
|
|
|
font => 'Sans 10', |
1506
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
1507
|
|
|
|
|
|
|
text => $word); |
1508
|
|
|
|
|
|
|
if($word !~ /Root/) |
1509
|
|
|
|
|
|
|
{ |
1510
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
1511
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
1512
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
1513
|
|
|
|
|
|
|
},$self); |
1514
|
|
|
|
|
|
|
} |
1515
|
|
|
|
|
|
|
$wpspos{$word}{"x"}=$x; |
1516
|
|
|
|
|
|
|
$wpspos{$word}{"y"}=$y; |
1517
|
|
|
|
|
|
|
$line{$word}{$wps[$i+1]} = Gnome2::Canvas::Item->new($shortest_path_group_wps2[$k], "Gnome2::Canvas::Line", |
1518
|
|
|
|
|
|
|
points => [$prevx,$prevy+$diffy/5,$x,$y-$diffy/5], |
1519
|
|
|
|
|
|
|
width_pixels => 1, |
1520
|
|
|
|
|
|
|
first_arrowhead => 1, |
1521
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1522
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1523
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1524
|
|
|
|
|
|
|
fill_color => 'blue' |
1525
|
|
|
|
|
|
|
); |
1526
|
|
|
|
|
|
|
$prevx = $x; |
1527
|
|
|
|
|
|
|
$prevy = $y; |
1528
|
|
|
|
|
|
|
} |
1529
|
|
|
|
|
|
|
else |
1530
|
|
|
|
|
|
|
{ |
1531
|
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2)=$text{$word}->get_bounds; |
1532
|
|
|
|
|
|
|
$x = $x1 - 5; |
1533
|
|
|
|
|
|
|
$y = $y2; |
1534
|
|
|
|
|
|
|
$prevx = $x; |
1535
|
|
|
|
|
|
|
$prevy = $y; |
1536
|
|
|
|
|
|
|
$x = $x-60; |
1537
|
|
|
|
|
|
|
$y = $y+10; |
1538
|
|
|
|
|
|
|
next; |
1539
|
|
|
|
|
|
|
} |
1540
|
|
|
|
|
|
|
} |
1541
|
|
|
|
|
|
|
$hx = abs($maxx-$minx)+100; |
1542
|
|
|
|
|
|
|
$hy = abs($maxy-$miny)+80; |
1543
|
|
|
|
|
|
|
$canvas[$k]->set_size_request($hx,$hy); |
1544
|
|
|
|
|
|
|
$canvas[$k]->set_scroll_region (0, 0, $hx, $hy); |
1545
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(x=>abs($minx)+60); |
1546
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(y=>abs($miny)+10); |
1547
|
|
|
|
|
|
|
$minx = $k+1; |
1548
|
|
|
|
|
|
|
if($mpflag) |
1549
|
|
|
|
|
|
|
{ |
1550
|
|
|
|
|
|
|
$notebook->append_page($canvas[$k], "Path ".$minx); |
1551
|
|
|
|
|
|
|
} |
1552
|
|
|
|
|
|
|
else |
1553
|
|
|
|
|
|
|
{ |
1554
|
|
|
|
|
|
|
$notebook->add($canvas[0]); |
1555
|
|
|
|
|
|
|
} |
1556
|
|
|
|
|
|
|
} |
1557
|
|
|
|
|
|
|
} |
1558
|
|
|
|
|
|
|
$self->{ canvas } = $canvas[0]; |
1559
|
|
|
|
|
|
|
} |
1560
|
|
|
|
|
|
|
elsif($trace_strings[0]=~/hso/) |
1561
|
|
|
|
|
|
|
{ |
1562
|
|
|
|
|
|
|
$k=-1; |
1563
|
|
|
|
|
|
|
if($#trace_strings>1) |
1564
|
|
|
|
|
|
|
{ |
1565
|
|
|
|
|
|
|
$notebook = Gtk2::Notebook->new; |
1566
|
|
|
|
|
|
|
# $notebook->signal_connect(switch_page=>sub { |
1567
|
|
|
|
|
|
|
# my ($self,$gui) = @_; |
1568
|
|
|
|
|
|
|
# my $child=$self->get_current_page; |
1569
|
|
|
|
|
|
|
# my @children = $self->get_children; |
1570
|
|
|
|
|
|
|
# $gui->{ canvas }= $children[$child]; |
1571
|
|
|
|
|
|
|
# },$self); |
1572
|
|
|
|
|
|
|
$mpflag = 1; |
1573
|
|
|
|
|
|
|
} |
1574
|
|
|
|
|
|
|
else |
1575
|
|
|
|
|
|
|
{ |
1576
|
|
|
|
|
|
|
$notebook = Gtk2::VBox->new; |
1577
|
|
|
|
|
|
|
} |
1578
|
|
|
|
|
|
|
$i=0; |
1579
|
|
|
|
|
|
|
my $sub=0; |
1580
|
|
|
|
|
|
|
my $lcsflag=0; |
1581
|
|
|
|
|
|
|
my $prevword; |
1582
|
|
|
|
|
|
|
foreach $i (1...$#trace_strings) |
1583
|
|
|
|
|
|
|
{ |
1584
|
|
|
|
|
|
|
$k++; |
1585
|
|
|
|
|
|
|
$x=0; |
1586
|
|
|
|
|
|
|
$y=0; |
1587
|
|
|
|
|
|
|
$maxx=0; |
1588
|
|
|
|
|
|
|
$maxy=0; |
1589
|
|
|
|
|
|
|
$minx=0; |
1590
|
|
|
|
|
|
|
$miny=0; |
1591
|
|
|
|
|
|
|
$canvas[$k] = Gnome2::Canvas->new; |
1592
|
|
|
|
|
|
|
$canvas_root[$k] = $canvas[$k]->root; |
1593
|
|
|
|
|
|
|
$shortest_path_group[$k] = Gnome2::Canvas::Item->new($canvas_root[$k], "Gnome2::Canvas::Group"); |
1594
|
|
|
|
|
|
|
$root_group[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1595
|
|
|
|
|
|
|
$shortest_path_group_wps1[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1596
|
|
|
|
|
|
|
$shortest_path_group_wps2[$k] = Gnome2::Canvas::Item->new($shortest_path_group[$k], "Gnome2::Canvas::Group"); |
1597
|
|
|
|
|
|
|
%text=(); |
1598
|
|
|
|
|
|
|
%line=(); |
1599
|
|
|
|
|
|
|
$diffy = 60; |
1600
|
|
|
|
|
|
|
$diffx = 0; |
1601
|
|
|
|
|
|
|
$lcsflag=0; |
1602
|
|
|
|
|
|
|
$jflag=0; |
1603
|
|
|
|
|
|
|
@wps= split /\s/, $trace_strings[$i]; |
1604
|
|
|
|
|
|
|
$diffx=60; |
1605
|
|
|
|
|
|
|
$prevword=""; |
1606
|
|
|
|
|
|
|
foreach $word (@wps) |
1607
|
|
|
|
|
|
|
{ |
1608
|
|
|
|
|
|
|
if(length($word)>=1) |
1609
|
|
|
|
|
|
|
{ |
1610
|
|
|
|
|
|
|
if($miny>$y) |
1611
|
|
|
|
|
|
|
{ |
1612
|
|
|
|
|
|
|
$miny = $y; |
1613
|
|
|
|
|
|
|
} |
1614
|
|
|
|
|
|
|
if($maxy<$y) |
1615
|
|
|
|
|
|
|
{ |
1616
|
|
|
|
|
|
|
$maxy = $y; |
1617
|
|
|
|
|
|
|
} |
1618
|
|
|
|
|
|
|
if($minx>$x) |
1619
|
|
|
|
|
|
|
{ |
1620
|
|
|
|
|
|
|
$minx = $x; |
1621
|
|
|
|
|
|
|
} |
1622
|
|
|
|
|
|
|
if($maxx<$x) |
1623
|
|
|
|
|
|
|
{ |
1624
|
|
|
|
|
|
|
$maxx = $x; |
1625
|
|
|
|
|
|
|
} |
1626
|
|
|
|
|
|
|
if($word=~/hypernym/) |
1627
|
|
|
|
|
|
|
{ |
1628
|
|
|
|
|
|
|
$y=$y+$diffy; |
1629
|
|
|
|
|
|
|
$x=$x+$diffx+5; |
1630
|
|
|
|
|
|
|
if($prevx!=0) |
1631
|
|
|
|
|
|
|
{ |
1632
|
|
|
|
|
|
|
$prevx+=5; |
1633
|
|
|
|
|
|
|
} |
1634
|
|
|
|
|
|
|
$prevy=$prevy+15; |
1635
|
|
|
|
|
|
|
$line{$prevword}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
1636
|
|
|
|
|
|
|
points => [$prevx,$prevy-$diffy/7,$x+$sub,$y-$diffy/7], |
1637
|
|
|
|
|
|
|
width_pixels => 1, |
1638
|
|
|
|
|
|
|
last_arrowhead => 1, |
1639
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1640
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1641
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1642
|
|
|
|
|
|
|
fill_color => 'blue' |
1643
|
|
|
|
|
|
|
); |
1644
|
|
|
|
|
|
|
} |
1645
|
|
|
|
|
|
|
elsif($word=~/hyponym/) |
1646
|
|
|
|
|
|
|
{ |
1647
|
|
|
|
|
|
|
$x=$x+$diffx; |
1648
|
|
|
|
|
|
|
$y=$y-$diffy; |
1649
|
|
|
|
|
|
|
if($prevx!=0) |
1650
|
|
|
|
|
|
|
{ |
1651
|
|
|
|
|
|
|
$prevx+=5; |
1652
|
|
|
|
|
|
|
} |
1653
|
|
|
|
|
|
|
$line{$prevword}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
1654
|
|
|
|
|
|
|
points => [$prevx,$prevy-$diffy/7,$x+$sub,$y+$diffy/7], |
1655
|
|
|
|
|
|
|
width_pixels => 1, |
1656
|
|
|
|
|
|
|
last_arrowhead => 1, |
1657
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1658
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1659
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1660
|
|
|
|
|
|
|
fill_color => 'green' |
1661
|
|
|
|
|
|
|
); |
1662
|
|
|
|
|
|
|
} |
1663
|
|
|
|
|
|
|
elsif($word=~/merynym/) |
1664
|
|
|
|
|
|
|
{ |
1665
|
|
|
|
|
|
|
$prevx = $prevx + length($prevword)*3.5; |
1666
|
|
|
|
|
|
|
$x = $x+2*$diffx; |
1667
|
|
|
|
|
|
|
$line{$prevword}{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Line", |
1668
|
|
|
|
|
|
|
points => [$prevx+5,$prevy,$x-5,$y], |
1669
|
|
|
|
|
|
|
width_pixels => 1, |
1670
|
|
|
|
|
|
|
last_arrowhead => 1, |
1671
|
|
|
|
|
|
|
arrow_shape_a => 3.57, |
1672
|
|
|
|
|
|
|
arrow_shape_b => 6.93, |
1673
|
|
|
|
|
|
|
arrow_shape_c => 4, |
1674
|
|
|
|
|
|
|
fill_color => 'black' |
1675
|
|
|
|
|
|
|
); |
1676
|
|
|
|
|
|
|
} |
1677
|
|
|
|
|
|
|
else |
1678
|
|
|
|
|
|
|
{ |
1679
|
|
|
|
|
|
|
if($prevword=~/merynym/) |
1680
|
|
|
|
|
|
|
{ |
1681
|
|
|
|
|
|
|
$x=$x+length($word)*3.5; |
1682
|
|
|
|
|
|
|
} |
1683
|
|
|
|
|
|
|
@colorpos = split '#', $word; |
1684
|
|
|
|
|
|
|
if($colorpos[1]=~ 'v') |
1685
|
|
|
|
|
|
|
{ |
1686
|
|
|
|
|
|
|
$color = 'red'; |
1687
|
|
|
|
|
|
|
} |
1688
|
|
|
|
|
|
|
elsif($colorpos[1]=~ 'n') |
1689
|
|
|
|
|
|
|
{ |
1690
|
|
|
|
|
|
|
$color = 'dark green'; |
1691
|
|
|
|
|
|
|
} |
1692
|
|
|
|
|
|
|
else |
1693
|
|
|
|
|
|
|
{ |
1694
|
|
|
|
|
|
|
$color = 'purple'; |
1695
|
|
|
|
|
|
|
} |
1696
|
|
|
|
|
|
|
$text{$word} = Gnome2::Canvas::Item->new($root_group[$k], "Gnome2::Canvas::Text", |
1697
|
|
|
|
|
|
|
x => $x, |
1698
|
|
|
|
|
|
|
y => $y, |
1699
|
|
|
|
|
|
|
fill_color => $color, |
1700
|
|
|
|
|
|
|
font => 'Sans 10', |
1701
|
|
|
|
|
|
|
anchor => 'GTK_ANCHOR_CENTER', |
1702
|
|
|
|
|
|
|
text => $word); |
1703
|
|
|
|
|
|
|
if($word !~ /Root/) |
1704
|
|
|
|
|
|
|
{ |
1705
|
|
|
|
|
|
|
$text{$word}->signal_connect (event => sub { |
1706
|
|
|
|
|
|
|
my ($self,$event,$gui) = @_; |
1707
|
|
|
|
|
|
|
$gui->display_tooltip($self,$event); |
1708
|
|
|
|
|
|
|
},$self); |
1709
|
|
|
|
|
|
|
} |
1710
|
|
|
|
|
|
|
$prevx = $x; |
1711
|
|
|
|
|
|
|
$prevy = $y; |
1712
|
|
|
|
|
|
|
} |
1713
|
|
|
|
|
|
|
$prevword = $word; |
1714
|
|
|
|
|
|
|
} |
1715
|
|
|
|
|
|
|
} |
1716
|
|
|
|
|
|
|
$hx = abs($maxx-$minx)+100; |
1717
|
|
|
|
|
|
|
$hy = abs($maxy-$miny)+80; |
1718
|
|
|
|
|
|
|
$canvas[$k]->set_size_request($hx,$hy); |
1719
|
|
|
|
|
|
|
$canvas[$k]->set_scroll_region (0, 0, $hx, $hy); |
1720
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(x=>abs($minx)+60); |
1721
|
|
|
|
|
|
|
$shortest_path_group[$k]->set(y=>abs($miny)+10); |
1722
|
|
|
|
|
|
|
$minx = $k+1; |
1723
|
|
|
|
|
|
|
if($mpflag) |
1724
|
|
|
|
|
|
|
{ |
1725
|
|
|
|
|
|
|
$notebook->append_page($canvas[$k], "Path ".$minx); |
1726
|
|
|
|
|
|
|
} |
1727
|
|
|
|
|
|
|
else |
1728
|
|
|
|
|
|
|
{ |
1729
|
|
|
|
|
|
|
$notebook->add($canvas[0]); |
1730
|
|
|
|
|
|
|
} |
1731
|
|
|
|
|
|
|
} |
1732
|
|
|
|
|
|
|
$self->{ canvas } = $canvas[0]; |
1733
|
|
|
|
|
|
|
} |
1734
|
|
|
|
|
|
|
return $notebook; |
1735
|
|
|
|
|
|
|
} |
1736
|
|
|
|
|
|
|
|
1737
|
|
|
|
|
|
|
sub display_tooltip |
1738
|
|
|
|
|
|
|
{ |
1739
|
|
|
|
|
|
|
my ($gui,$self,$event)=@_; |
1740
|
|
|
|
|
|
|
my $px=$self->parent->parent->get("x"); |
1741
|
|
|
|
|
|
|
my $py=$self->parent->parent->get("y"); |
1742
|
|
|
|
|
|
|
my @glos = $gui->{ querydata_interface }->{ wn }->querySense($self->get("text"),"glos"); |
1743
|
|
|
|
|
|
|
my @text = split ";",$glos[0]; |
1744
|
|
|
|
|
|
|
my $length = length($text[0]); |
1745
|
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2)=$self->get_bounds; |
1746
|
|
|
|
|
|
|
if($gui->{ toolflag } == 0) |
1747
|
|
|
|
|
|
|
{ |
1748
|
|
|
|
|
|
|
if($event->type =~ /enter/) |
1749
|
|
|
|
|
|
|
{ |
1750
|
|
|
|
|
|
|
my $width = $length*6.7; |
1751
|
|
|
|
|
|
|
my $height = $y2-$y1+1; |
1752
|
|
|
|
|
|
|
$gui->{ tooltip_label }->set_text($text[0]); |
1753
|
|
|
|
|
|
|
$gui->{ tooltip_label }->set_size_request($width,$height); |
1754
|
|
|
|
|
|
|
$gui->{ tooltip }->resize($width,$height); |
1755
|
|
|
|
|
|
|
$gui->{ tooltip }->show_all; |
1756
|
|
|
|
|
|
|
my ($posx, $posy) = $gui->{ tooltip }->get_position; |
1757
|
|
|
|
|
|
|
$gui->{ tooltip }->move($posx+$width/2+7,$posy+$height); |
1758
|
|
|
|
|
|
|
$gui->{ toolflag }=1; |
1759
|
|
|
|
|
|
|
} |
1760
|
|
|
|
|
|
|
elsif($event->type=~/leave/) |
1761
|
|
|
|
|
|
|
{ |
1762
|
|
|
|
|
|
|
if($event->x-$px<$x1 or $event->y-$py<$y1 or $event->x-$px>$x2 or $event->y-$py>$y2) |
1763
|
|
|
|
|
|
|
{ |
1764
|
|
|
|
|
|
|
$gui->{ tooltip }->hide; |
1765
|
|
|
|
|
|
|
$gui->{ toolflag }=0; |
1766
|
|
|
|
|
|
|
} |
1767
|
|
|
|
|
|
|
} |
1768
|
|
|
|
|
|
|
} |
1769
|
|
|
|
|
|
|
else |
1770
|
|
|
|
|
|
|
{ |
1771
|
|
|
|
|
|
|
if($event->type=~/leave/) |
1772
|
|
|
|
|
|
|
{ |
1773
|
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2)=$self->get_bounds; |
1774
|
|
|
|
|
|
|
if($event->x-$px<$x1 or $event->y-$py<$y1 or $event->x-$px>$x2 or $event->y-$py>$y2) |
1775
|
|
|
|
|
|
|
{ |
1776
|
|
|
|
|
|
|
$gui->{ tooltip }->hide; |
1777
|
|
|
|
|
|
|
$gui->{ toolflag }=0; |
1778
|
|
|
|
|
|
|
$gui->{ tooltip_label }->set_size_request(1,1); |
1779
|
|
|
|
|
|
|
$gui->{ tooltip }->set_size_request(1,1); |
1780
|
|
|
|
|
|
|
} |
1781
|
|
|
|
|
|
|
} |
1782
|
|
|
|
|
|
|
} |
1783
|
|
|
|
|
|
|
if($event->type=~/button.press/) |
1784
|
|
|
|
|
|
|
{ |
1785
|
|
|
|
|
|
|
my @syns = $gui->{ querydata_interface }->{ wn }->querySense($self->get("text"),"syns"); |
1786
|
|
|
|
|
|
|
my $string = "Glos: ".$glos[0]."\n\nSynonyms: "; |
1787
|
|
|
|
|
|
|
my $syn; |
1788
|
|
|
|
|
|
|
foreach $syn (@syns) |
1789
|
|
|
|
|
|
|
{ |
1790
|
|
|
|
|
|
|
$string = $string.", ".$syn; |
1791
|
|
|
|
|
|
|
} |
1792
|
|
|
|
|
|
|
my $children; |
1793
|
|
|
|
|
|
|
if(defined $gui->{ vpaned }->child2) |
1794
|
|
|
|
|
|
|
{ |
1795
|
|
|
|
|
|
|
my @prev_results = $gui->{ vpaned }->child2->get_children(); |
1796
|
|
|
|
|
|
|
foreach $children (@prev_results) |
1797
|
|
|
|
|
|
|
{ |
1798
|
|
|
|
|
|
|
$gui->{ vpaned }->child2->remove($children); |
1799
|
|
|
|
|
|
|
} |
1800
|
|
|
|
|
|
|
$gui->{ vpaned }->remove($gui->{ vpaned }->child2); |
1801
|
|
|
|
|
|
|
} |
1802
|
|
|
|
|
|
|
my $txtbuffer = Gtk2::TextBuffer->new(); |
1803
|
|
|
|
|
|
|
$txtbuffer->set_text($string); |
1804
|
|
|
|
|
|
|
my $txtview = Gtk2::TextView->new; |
1805
|
|
|
|
|
|
|
$txtview->set_editable(FALSE); |
1806
|
|
|
|
|
|
|
$txtview->set_cursor_visible(FALSE); |
1807
|
|
|
|
|
|
|
$txtview->set_wrap_mode("word"); |
1808
|
|
|
|
|
|
|
$txtview->set_buffer($txtbuffer); |
1809
|
|
|
|
|
|
|
$gui->{ vpaned }->add2($txtview); |
1810
|
|
|
|
|
|
|
($x1,$y1,$x2,$y2)=$self->parent->parent->parent->get_bounds; |
1811
|
|
|
|
|
|
|
$gui->{ vpaned }->set_position($y2+40-$y1); |
1812
|
|
|
|
|
|
|
$gui->{ vpaned }->show_all; |
1813
|
|
|
|
|
|
|
} |
1814
|
|
|
|
|
|
|
} |
1815
|
|
|
|
|
|
|
|
1816
|
|
|
|
|
|
|
# sub save_file |
1817
|
|
|
|
|
|
|
# { |
1818
|
|
|
|
|
|
|
# my ($self,$filename)=@_; |
1819
|
|
|
|
|
|
|
# # my $window = Gtk2::Gdk::Drawable->new; |
1820
|
|
|
|
|
|
|
# # $window = $self->{ canvas }->get_window(); |
1821
|
|
|
|
|
|
|
# my $pixbuf = Gtk2::Gdk::Pixbuf->new('rgb',0,8,1000,1000); |
1822
|
|
|
|
|
|
|
# $pixbuf->get_from_drawable(undef,$self->{ canvas }->get_colormap(),0,0,0,0,1000,1000); |
1823
|
|
|
|
|
|
|
# # my $pixbuf = Gtk2::Gdk::pixbuf->new_from_data($window,$window->get_colormap(),0,0,0,0,1000,1000); |
1824
|
|
|
|
|
|
|
# pixbuf->save($filename,"png"); |
1825
|
|
|
|
|
|
|
# } |
1826
|
|
|
|
|
|
|
|
1827
|
|
|
|
|
|
|
|
1828
|
|
|
|
|
|
|
1; |
1829
|
|
|
|
|
|
|
__END__ |