| 1 |
<% String pageTitle = "Parser Testing"; %> |
|---|
| 2 |
<%@ include file="header2.jsp" %> |
|---|
| 3 |
|
|---|
| 4 |
<%@ page import="java.util.*" %> |
|---|
| 5 |
<%@ page import="com.qwirx.lex.ontology.*" %> |
|---|
| 6 |
<%@ page import="com.qwirx.lex.wordnet.*" %> |
|---|
| 7 |
<%@ page import="com.qwirx.lex.parser.*" %> |
|---|
| 8 |
<%@ page import="com.qwirx.lex.morph.*" %> |
|---|
| 9 |
|
|---|
| 10 |
<script language="javascript"> |
|---|
| 11 |
<!-- |
|---|
| 12 |
|
|---|
| 13 |
var old_hilites = null; |
|---|
| 14 |
var selected_state = new Array(); |
|---|
| 15 |
|
|---|
| 16 |
function selected_class(state) |
|---|
| 17 |
{ |
|---|
| 18 |
return state ? "selected" : ""; |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
function object_default_class(object) |
|---|
| 22 |
{ |
|---|
| 23 |
var state = selected_state[object.id]; |
|---|
| 24 |
|
|---|
| 25 |
if (state == null) |
|---|
| 26 |
{ |
|---|
| 27 |
state = false; |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
return selected_class(state); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
function highlight_recursive(object) |
|---|
| 34 |
{ |
|---|
| 35 |
old_hilites[old_hilites.length] = object; |
|---|
| 36 |
object.className = "hilite"; |
|---|
| 37 |
|
|---|
| 38 |
var children = children_by_id[object.id]; |
|---|
| 39 |
|
|---|
| 40 |
if (children == null) |
|---|
| 41 |
{ |
|---|
| 42 |
alert("object has no id: " + object); |
|---|
| 43 |
return; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
for (var i = 0; i < children.length; i++) |
|---|
| 47 |
{ |
|---|
| 48 |
var child = document.getElementById(children[i]); |
|---|
| 49 |
if (child == null) |
|---|
| 50 |
{ |
|---|
| 51 |
alert("no such child: " + children[i]); |
|---|
| 52 |
} |
|---|
| 53 |
else |
|---|
| 54 |
{ |
|---|
| 55 |
highlight_recursive(child); |
|---|
| 56 |
} |
|---|
| 57 |
} |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
function highlight(object) |
|---|
| 61 |
{ |
|---|
| 62 |
unhighlight_all(); |
|---|
| 63 |
|
|---|
| 64 |
highlight_recursive(object); |
|---|
| 65 |
|
|---|
| 66 |
return true; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
function unhighlight_all() |
|---|
| 70 |
{ |
|---|
| 71 |
if (old_hilites != null) |
|---|
| 72 |
{ |
|---|
| 73 |
for (var i = 0; i < old_hilites.length; i++) |
|---|
| 74 |
{ |
|---|
| 75 |
old_hilites[i].className = object_default_class(old_hilites[i]); |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
old_hilites = new Array(); |
|---|
| 80 |
|
|---|
| 81 |
return true; |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
function select_children_recursive(object, state) |
|---|
| 85 |
{ |
|---|
| 86 |
selected_state[object.id] = state; |
|---|
| 87 |
object.className = selected_class(state); |
|---|
| 88 |
|
|---|
| 89 |
var children = children_by_id[object.id]; |
|---|
| 90 |
|
|---|
| 91 |
if (children == null) |
|---|
| 92 |
{ |
|---|
| 93 |
alert("object has no id: " + object); |
|---|
| 94 |
return; |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
for (var i = 0; i < children.length; i++) |
|---|
| 98 |
{ |
|---|
| 99 |
var child = document.getElementById(children[i]); |
|---|
| 100 |
if (child == null) |
|---|
| 101 |
{ |
|---|
| 102 |
alert("no such child: " + children[i]); |
|---|
| 103 |
} |
|---|
| 104 |
else |
|---|
| 105 |
{ |
|---|
| 106 |
select_children_recursive(child, state); |
|---|
| 107 |
} |
|---|
| 108 |
} |
|---|
| 109 |
} |
|---|
| 110 |
|
|---|
| 111 |
function on_checkbox_click(target_checkbox) |
|---|
| 112 |
{ |
|---|
| 113 |
var table_cell = document.getElementById(target_checkbox.name); |
|---|
| 114 |
select_children_recursive(table_cell, target_checkbox.checked); |
|---|
| 115 |
|
|---|
| 116 |
var sel_left = -1; |
|---|
| 117 |
var sel_right = -1; |
|---|
| 118 |
var any_checked = false; |
|---|
| 119 |
var checked_list = new Array(); |
|---|
| 120 |
|
|---|
| 121 |
for (var i = 0; i < edges.length; i++) |
|---|
| 122 |
{ |
|---|
| 123 |
var edge = edges[i]; |
|---|
| 124 |
var checkbox = document.forms.rulecmd[edge.id]; |
|---|
| 125 |
|
|---|
| 126 |
if (checkbox != null && checkbox.checked) |
|---|
| 127 |
{ |
|---|
| 128 |
checked_list[checked_list.length] = edge; |
|---|
| 129 |
|
|---|
| 130 |
if (sel_left == -1 || sel_left > edge.left) |
|---|
| 131 |
{ |
|---|
| 132 |
sel_left = edge.left; |
|---|
| 133 |
} |
|---|
| 134 |
if (sel_right == -1 || sel_right < edge.right) |
|---|
| 135 |
{ |
|---|
| 136 |
sel_right = edge.right; |
|---|
| 137 |
} |
|---|
| 138 |
} |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
for (var i = 0; i < edges.length; i++) |
|---|
| 142 |
{ |
|---|
| 143 |
var edge = edges[i]; |
|---|
| 144 |
var enabled = false; |
|---|
| 145 |
var checkbox = document.forms.rulecmd[edge.id]; |
|---|
| 146 |
|
|---|
| 147 |
if (checkbox == null) |
|---|
| 148 |
{ |
|---|
| 149 |
// fake edges don't have checkboxes |
|---|
| 150 |
continue; |
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
if (checked_list.length == 0) |
|---|
| 154 |
{ |
|---|
| 155 |
// if none are checked yet, allow any to be checked |
|---|
| 156 |
enabled = true; |
|---|
| 157 |
} |
|---|
| 158 |
else if (edge.left == sel_right + 1 || edge.right == sel_left - 1) |
|---|
| 159 |
{ |
|---|
| 160 |
// allow expansion at the edges |
|---|
| 161 |
enabled = true; |
|---|
| 162 |
} |
|---|
| 163 |
else if (!checkbox.checked) |
|---|
| 164 |
{ |
|---|
| 165 |
enabled = false; |
|---|
| 166 |
} |
|---|
| 167 |
else if (edge.left == sel_left || edge.right == sel_right) |
|---|
| 168 |
{ |
|---|
| 169 |
// allow deselection at the left and right edges only |
|---|
| 170 |
enabled = true; |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
checkbox.disabled = !enabled; |
|---|
| 174 |
} |
|---|
| 175 |
|
|---|
| 176 |
var parts = document.forms.rulecmd.new_rule_parts; |
|---|
| 177 |
parts.value = ""; |
|---|
| 178 |
|
|---|
| 179 |
for (var i = 0; i < checked_list.length; i++) |
|---|
| 180 |
{ |
|---|
| 181 |
var edge = checked_list[i]; |
|---|
| 182 |
|
|---|
| 183 |
if (edge.terminal) |
|---|
| 184 |
{ |
|---|
| 185 |
parts.value += "\"" + edge.symbol + "\""; |
|---|
| 186 |
} |
|---|
| 187 |
else |
|---|
| 188 |
{ |
|---|
| 189 |
parts.value += "{" + edge.symbol + "}"; |
|---|
| 190 |
} |
|---|
| 191 |
|
|---|
| 192 |
if (i < checked_list.length - 1) |
|---|
| 193 |
{ |
|---|
| 194 |
parts.value += " "; |
|---|
| 195 |
} |
|---|
| 196 |
} |
|---|
| 197 |
|
|---|
| 198 |
return true; |
|---|
| 199 |
} |
|---|
| 200 |
|
|---|
| 201 |
function edge (id, left, right, symbol, terminal, fake) |
|---|
| 202 |
{ |
|---|
| 203 |
this.id = id; |
|---|
| 204 |
this.left = left; |
|---|
| 205 |
this.right = right; |
|---|
| 206 |
this.symbol = symbol; |
|---|
| 207 |
this.terminal = terminal; |
|---|
| 208 |
this.fake = fake; |
|---|
| 209 |
} |
|---|
| 210 |
|
|---|
| 211 |
function on_rule_add_click() |
|---|
| 212 |
{ |
|---|
| 213 |
var form = document.forms.rulecmd; |
|---|
| 214 |
|
|---|
| 215 |
if (form.new_rule_sym.value == "") |
|---|
| 216 |
{ |
|---|
| 217 |
alert("You must enter a top symbol for the new rule!"); |
|---|
| 218 |
return false; |
|---|
| 219 |
} |
|---|
| 220 |
|
|---|
| 221 |
if (form.new_rule_parts.value == "") |
|---|
| 222 |
{ |
|---|
| 223 |
alert("You must select some edges for the new rule!"); |
|---|
| 224 |
return false; |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
return true; |
|---|
| 228 |
} |
|---|
| 229 |
|
|---|
| 230 |
//--> |
|---|
| 231 |
</script> |
|---|
| 232 |
|
|---|
| 233 |
<%@ include file="auth.jsp" %> |
|---|
| 234 |
|
|---|
| 235 |
<%@ include file="navclause.jsp" %> |
|---|
| 236 |
|
|---|
| 237 |
<% |
|---|
| 238 |
|
|---|
| 239 |
Map phrase_types = emdros.getEnumerationConstants |
|---|
| 240 |
("phrase_type_e",false); |
|---|
| 241 |
|
|---|
| 242 |
OntologyDb ontology = Lex.getOntologyDb(); |
|---|
| 243 |
|
|---|
| 244 |
Wordnet wordnet = Wordnet.getInstance(); |
|---|
| 245 |
|
|---|
| 246 |
class BorderTableRenderer extends TableRenderer |
|---|
| 247 |
{ |
|---|
| 248 |
public String getTable(String contents) |
|---|
| 249 |
{ |
|---|
| 250 |
return "<table class=\"tree\" border>" + contents + "</table>\n"; |
|---|
| 251 |
} |
|---|
| 252 |
} |
|---|
| 253 |
|
|---|
| 254 |
BorderTableRenderer rend = new BorderTableRenderer(); |
|---|
| 255 |
|
|---|
| 256 |
Sheaf sheaf = emdros.getSheaf |
|---|
| 257 |
( |
|---|
| 258 |
"SELECT ALL OBJECTS IN " + |
|---|
| 259 |
emdros.intersect(userTextAccessSet, min_m, max_m) + |
|---|
| 260 |
" WHERE [clause self = "+selClauseId+ |
|---|
| 261 |
" GET logical_struct_id, logical_structure "+ |
|---|
| 262 |
" [phrase GET phrase_type, argument_name, "+ |
|---|
| 263 |
" type_id, macrorole_number "+ |
|---|
| 264 |
" [word GET lexeme, phrase_dependent_part_of_speech, "+ |
|---|
| 265 |
" tense, stem, wordnet_gloss, wordnet_synset, " + |
|---|
| 266 |
" graphical_preformative, " + |
|---|
| 267 |
" graphical_locative, " + |
|---|
| 268 |
" graphical_lexeme, " + |
|---|
| 269 |
" graphical_pron_suffix, " + |
|---|
| 270 |
" graphical_verbal_ending, " + |
|---|
| 271 |
" graphical_root_formation, " + |
|---|
| 272 |
" graphical_nominal_ending, " + |
|---|
| 273 |
" person, number, gender, state, " + |
|---|
| 274 |
" suffix_person, suffix_number, suffix_gender " + |
|---|
| 275 |
" ]"+ |
|---|
| 276 |
" ]"+ |
|---|
| 277 |
" ]" |
|---|
| 278 |
); |
|---|
| 279 |
|
|---|
| 280 |
MatchedObject clause = null; |
|---|
| 281 |
|
|---|
| 282 |
{ |
|---|
| 283 |
SheafConstIterator sci = sheaf.const_iterator(); |
|---|
| 284 |
if (sci.hasNext()) |
|---|
| 285 |
{ |
|---|
| 286 |
Straw straw = sci.next(); |
|---|
| 287 |
StrawConstIterator swci = straw.const_iterator(); |
|---|
| 288 |
if (swci.hasNext()) |
|---|
| 289 |
{ |
|---|
| 290 |
clause = swci.next(); |
|---|
| 291 |
} |
|---|
| 292 |
} |
|---|
| 293 |
} |
|---|
| 294 |
|
|---|
| 295 |
if (clause == null) |
|---|
| 296 |
{ |
|---|
| 297 |
%><p>Selected clause not found or access denied.</p><% |
|---|
| 298 |
} |
|---|
| 299 |
else |
|---|
| 300 |
{ |
|---|
| 301 |
StringBuffer hebrewText = new StringBuffer(); |
|---|
| 302 |
List morphEdges = new ArrayList(); |
|---|
| 303 |
|
|---|
| 304 |
/* Prescan to list morpheme edges */ |
|---|
| 305 |
|
|---|
| 306 |
{ |
|---|
| 307 |
TreeNode root = new TreeNode("root"); |
|---|
| 308 |
HebrewMorphemeGenerator gen = new HebrewMorphemeGenerator(); |
|---|
| 309 |
|
|---|
| 310 |
{ |
|---|
| 311 |
SheafConstIterator phrases = clause.getSheaf().const_iterator(); |
|---|
| 312 |
|
|---|
| 313 |
while (phrases.hasNext()) |
|---|
| 314 |
{ |
|---|
| 315 |
MatchedObject phrase = |
|---|
| 316 |
phrases.next().const_iterator().next(); |
|---|
| 317 |
|
|---|
| 318 |
SheafConstIterator words = phrase.getSheaf().const_iterator(); |
|---|
| 319 |
while (words.hasNext()) |
|---|
| 320 |
{ |
|---|
| 321 |
MatchedObject word = words.next().const_iterator().next(); |
|---|
| 322 |
|
|---|
| 323 |
class HebrewFeatureConverter implements MorphemeHandler |
|---|
| 324 |
{ |
|---|
| 325 |
private TreeNode m_root; |
|---|
| 326 |
private MatchedObject m_word; |
|---|
| 327 |
private StringBuffer m_hebrew; |
|---|
| 328 |
private List m_morphs; |
|---|
| 329 |
|
|---|
| 330 |
public HebrewFeatureConverter(TreeNode root, |
|---|
| 331 |
MatchedObject word, StringBuffer hebrew, |
|---|
| 332 |
List morphs) |
|---|
| 333 |
{ |
|---|
| 334 |
m_root = root; |
|---|
| 335 |
m_word = word; |
|---|
| 336 |
m_hebrew = hebrew; |
|---|
| 337 |
m_morphs = morphs; |
|---|
| 338 |
} |
|---|
| 339 |
|
|---|
| 340 |
public void convert(String surface, |
|---|
| 341 |
boolean lastMorpheme, String desc, |
|---|
| 342 |
String morphNode) |
|---|
| 343 |
{ |
|---|
| 344 |
String raw = m_word.getEMdFValue(surface).getString(); |
|---|
| 345 |
|
|---|
| 346 |
String hebrew = HebrewConverter.toHebrew(raw); |
|---|
| 347 |
m_hebrew.append(hebrew); |
|---|
| 348 |
|
|---|
| 349 |
String translit = HebrewConverter.toTranslit(raw); |
|---|
| 350 |
translit = HebrewConverter.toHtml(translit); |
|---|
| 351 |
if (translit.equals("")) translit = "Ø"; |
|---|
| 352 |
if (!lastMorpheme) translit += "-"; |
|---|
| 353 |
TreeNode node = m_root.createChild(translit); |
|---|
| 354 |
|
|---|
| 355 |
node = node.createChild(raw); |
|---|
| 356 |
node.createChild(desc); |
|---|
| 357 |
|
|---|
| 358 |
m_morphs.add(new MorphEdge(morphNode, |
|---|
| 359 |
translit, m_morphs.size())); |
|---|
| 360 |
} |
|---|
| 361 |
} |
|---|
| 362 |
|
|---|
| 363 |
HebrewFeatureConverter hfc = |
|---|
| 364 |
new HebrewFeatureConverter(root, word, hebrewText, |
|---|
| 365 |
morphEdges); |
|---|
| 366 |
|
|---|
| 367 |
gen.parse(word, hfc, true, sql); |
|---|
| 368 |
|
|---|
| 369 |
hebrewText.append(" "); |
|---|
| 370 |
} |
|---|
| 371 |
} |
|---|
| 372 |
} |
|---|
| 373 |
|
|---|
| 374 |
%><p>Hebrew text: <span class="hebrew"><%= |
|---|
| 375 |
HebrewConverter.toHtml(hebrewText.toString()) |
|---|
| 376 |
%></span></p><% |
|---|
| 377 |
} |
|---|
| 378 |
|
|---|
| 379 |
if (request.getParameter("rule_add") != null) |
|---|
| 380 |
{ |
|---|
| 381 |
String symbol = request.getParameter("new_rule_sym"); |
|---|
| 382 |
String parts = request.getParameter("new_rule_parts"); |
|---|
| 383 |
|
|---|
| 384 |
if (symbol == null || symbol.equals("") || |
|---|
| 385 |
parts == null || parts.equals("")) |
|---|
| 386 |
{ |
|---|
| 387 |
%> |
|---|
| 388 |
<h2>Error: some required parameters were missing or empty</h2> |
|---|
| 389 |
<% |
|---|
| 390 |
} |
|---|
| 391 |
else |
|---|
| 392 |
{ |
|---|
| 393 |
Change ch = sql.createChange(SqlChange.INSERT, |
|---|
| 394 |
"lexicon_entries", null); |
|---|
| 395 |
ch.setString("Symbol", symbol); |
|---|
| 396 |
ch.setString("Lexeme", parts); |
|---|
| 397 |
ch.execute(); |
|---|
| 398 |
} |
|---|
| 399 |
} |
|---|
| 400 |
|
|---|
| 401 |
{ |
|---|
| 402 |
Parser p = new Parser(sql); |
|---|
| 403 |
p.setVerbose(true); |
|---|
| 404 |
Chart chart = p.parse(morphEdges); |
|---|
| 405 |
List sentences = chart.filter("SENTENCE", morphEdges, false); |
|---|
| 406 |
|
|---|
| 407 |
if (sentences.size() == 0) |
|---|
| 408 |
{ |
|---|
| 409 |
%> |
|---|
| 410 |
<h3>Parse failed</h3> |
|---|
| 411 |
<% |
|---|
| 412 |
} |
|---|
| 413 |
else |
|---|
| 414 |
{ |
|---|
| 415 |
%> |
|---|
| 416 |
<h3>Parse succeeded</h3> |
|---|
| 417 |
<% |
|---|
| 418 |
} |
|---|
| 419 |
|
|---|
| 420 |
%> |
|---|
| 421 |
<p>Complete sentences found: <%= sentences.size() %></p> |
|---|
| 422 |
<p>The edges found were:</p> |
|---|
| 423 |
<form name="rulecmd" method="post"> |
|---|
| 424 |
<% |
|---|
| 425 |
|
|---|
| 426 |
Map edgeIds = new Hashtable(); |
|---|
| 427 |
Map idEdges = new Hashtable(); |
|---|
| 428 |
Map fakeChild = new Hashtable(); |
|---|
| 429 |
List fakeEdges = new ArrayList(); |
|---|
| 430 |
List depths = new ArrayList(); |
|---|
| 431 |
List edges = chart.getEdges(); |
|---|
| 432 |
int maxDepth = 0; |
|---|
| 433 |
|
|---|
| 434 |
for (ListIterator i = edges.listIterator(); i.hasNext(); ) |
|---|
| 435 |
{ |
|---|
| 436 |
Edge e = (Edge)( i.next() ); |
|---|
| 437 |
|
|---|
| 438 |
int depth = e.getDepth(); |
|---|
| 439 |
|
|---|
| 440 |
if (maxDepth < depth) |
|---|
| 441 |
{ |
|---|
| 442 |
maxDepth = depth; |
|---|
| 443 |
} |
|---|
| 444 |
|
|---|
| 445 |
if (e instanceof MorphEdge) |
|---|
| 446 |
{ |
|---|
| 447 |
MorphEdge me = (MorphEdge)e; |
|---|
| 448 |
WordEdge we = new WordEdge(me.getHtmlSurface(), |
|---|
| 449 |
me.getLeftPosition()); |
|---|
| 450 |
i.add(we); |
|---|
| 451 |
fakeChild.put(me, we); |
|---|
| 452 |
fakeEdges.add(we); |
|---|
| 453 |
} |
|---|
| 454 |
} |
|---|
| 455 |
|
|---|
| 456 |
for (ListIterator i = edges.listIterator(); i.hasNext(); ) |
|---|
| 457 |
{ |
|---|
| 458 |
Edge e = (Edge)( i.next() ); |
|---|
| 459 |
|
|---|
| 460 |
int uniqueNum = 1; |
|---|
| 461 |
String base = e.symbol().replaceAll("[^A-Za-z0-9]","_"); |
|---|
| 462 |
String id = base + "_" + uniqueNum; |
|---|
| 463 |
|
|---|
| 464 |
while (idEdges.get(id) != null) |
|---|
| 465 |
{ |
|---|
| 466 |
uniqueNum++; |
|---|
| 467 |
id = base + "_" + uniqueNum; |
|---|
| 468 |
} |
|---|
| 469 |
|
|---|
| 470 |
edgeIds.put(e, id); |
|---|
| 471 |
idEdges.put(id, e); |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
/* |
|---|
| 475 |
%> |
|---|
| 476 |
<ul> |
|---|
| 477 |
<% |
|---|
| 478 |
|
|---|
| 479 |
for (Iterator i = edges.iterator(); i.hasNext(); ) |
|---|
| 480 |
{ |
|---|
| 481 |
Edge e = (Edge)( i.next() ); |
|---|
| 482 |
%> |
|---|
| 483 |
<ul> |
|---|
| 484 |
[<%= e.getDepth() %>] <%= edgeIds.get(e) %> |
|---|
| 485 |
<%= e.toString() %> |
|---|
| 486 |
</ul> |
|---|
| 487 |
<% |
|---|
| 488 |
} |
|---|
| 489 |
|
|---|
| 490 |
%> |
|---|
| 491 |
</ul> |
|---|
| 492 |
<% |
|---|
| 493 |
*/ |
|---|
| 494 |
|
|---|
| 495 |
for (int i = 0; i <= maxDepth; i++) |
|---|
| 496 |
{ |
|---|
| 497 |
depths.add(new ArrayList()); |
|---|
| 498 |
} |
|---|
| 499 |
|
|---|
| 500 |
for (Iterator i = edges.iterator(); i.hasNext(); ) |
|---|
| 501 |
{ |
|---|
| 502 |
Edge e = (Edge)( i.next() ); |
|---|
| 503 |
int depth = e.getDepth(); |
|---|
| 504 |
List edgesAtDepth = (List)( depths.get(depth) ); |
|---|
| 505 |
edgesAtDepth.add(e); |
|---|
| 506 |
} |
|---|
| 507 |
|
|---|
| 508 |
%> |
|---|
| 509 |
<table border> |
|---|
| 510 |
<% |
|---|
| 511 |
|
|---|
| 512 |
class EdgeComparator implements Comparator |
|---|
| 513 |
{ |
|---|
| 514 |
public int compare(Object o1, Object o2) |
|---|
| 515 |
{ |
|---|
| 516 |
Edge e1 = (Edge)o1; |
|---|
| 517 |
Edge e2 = (Edge)o2; |
|---|
| 518 |
int diff = e1.getLeftPosition() - e2.getLeftPosition(); |
|---|
| 519 |
if (diff != 0) return diff; |
|---|
| 520 |
return e2.getRightPosition() - e1.getRightPosition(); |
|---|
| 521 |
} |
|---|
| 522 |
} |
|---|
| 523 |
|
|---|
| 524 |
Comparator comp = new EdgeComparator(); |
|---|
| 525 |
|
|---|
| 526 |
for (int i = maxDepth; i >= 0; i--) |
|---|
| 527 |
{ |
|---|
| 528 |
List edgesAtDepth = (List)( depths.get(i) ); |
|---|
| 529 |
List remaining = new ArrayList(); |
|---|
| 530 |
remaining.addAll(edgesAtDepth); |
|---|
| 531 |
Collections.sort(remaining, comp); |
|---|
| 532 |
|
|---|
| 533 |
if (remaining.size() != edgesAtDepth.size()) |
|---|
| 534 |
{ |
|---|
| 535 |
throw new AssertionError("lost elements"); |
|---|
| 536 |
} |
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
while (remaining.size() > 0) |
|---|
| 541 |
{ |
|---|
| 542 |
List added = new ArrayList(); |
|---|
| 543 |
List leftOver = new ArrayList(); |
|---|
| 544 |
|
|---|
| 545 |
%> |
|---|
| 546 |
<tr> |
|---|
| 547 |
<% |
|---|
| 548 |
|
|---|
| 549 |
int pos = 0; |
|---|
| 550 |
|
|---|
| 551 |
for (Iterator n = remaining.iterator(); n.hasNext(); ) |
|---|
| 552 |
{ |
|---|
| 553 |
Edge next = (Edge)( n.next() ); |
|---|
| 554 |
boolean overlaps = false; |
|---|
| 555 |
|
|---|
| 556 |
for (Iterator a = added.iterator(); a.hasNext(); ) |
|---|
| 557 |
{ |
|---|
| 558 |
Edge addedEdge = (Edge)( a.next() ); |
|---|
| 559 |
if (next.overlaps(addedEdge)) |
|---|
| 560 |
{ |
|---|
| 561 |
overlaps = true; |
|---|
| 562 |
break; |
|---|
| 563 |
} |
|---|
| 564 |
} |
|---|
| 565 |
|
|---|
| 566 |
if (overlaps) |
|---|
| 567 |
{ |
|---|
| 568 |
leftOver.add(next); |
|---|
| 569 |
continue; |
|---|
| 570 |
} |
|---|
| 571 |
|
|---|
| 572 |
int left = next.getLeftPosition(); |
|---|
| 573 |
if (pos < left) |
|---|
| 574 |
{ |
|---|
| 575 |
%> |
|---|
| 576 |
<td colspan="<%= left - pos %>" /> |
|---|
| 577 |
<% |
|---|
| 578 |
pos = left; |
|---|
| 579 |
} |
|---|
| 580 |
|
|---|
| 581 |
int right = next.getRightPosition(); |
|---|
| 582 |
int colspan = right - left + 1; |
|---|
| 583 |
|
|---|
| 584 |
%> |
|---|
| 585 |
<td <%= colspan>1 ? "colspan="+colspan : "" %> |
|---|
| 586 |
id="<%= edgeIds.get(next) %>" |
|---|
| 587 |
onMouseOver="return highlight (this);" |
|---|
| 588 |
onMouseOut=" return unhighlight_all();" |
|---|
| 589 |
> |
|---|
| 590 |
|
|---|
| 591 |
<% /* %> |
|---|
| 592 |
[<%= edgeIds.get(next) %>] |
|---|
| 593 |
<% */ |
|---|
| 594 |
|
|---|
| 595 |
if (!fakeEdges.contains(next)) |
|---|
| 596 |
{ |
|---|
| 597 |
%> |
|---|
| 598 |
<span class="cb"> |
|---|
| 599 |
<input name="<%= edgeIds.get(next) %>" |
|---|
| 600 |
type="checkbox" |
|---|
| 601 |
onClick="return on_checkbox_click(this);" /> |
|---|
| 602 |
</span> |
|---|
| 603 |
<% |
|---|
| 604 |
} |
|---|
| 605 |
|
|---|
| 606 |
if (next instanceof RuleEdge) |
|---|
| 607 |
{ |
|---|
| 608 |
RuleEdge re = (RuleEdge)next; |
|---|
| 609 |
%><a href="rules.jsp?erid=<%= |
|---|
| 610 |
re.rule().id() |
|---|
| 611 |
%>#rule_<%= |
|---|
| 612 |
re.rule().id() |
|---|
| 613 |
%>"><%= |
|---|
| 614 |
next.getHtmlLabel() |
|---|
| 615 |
%></a><% |
|---|
| 616 |
} |
|---|
| 617 |
else |
|---|
| 618 |
{ |
|---|
| 619 |
%><%= next.getHtmlLabel() %><% |
|---|
| 620 |
} |
|---|
| 621 |
|
|---|
| 622 |
%> |
|---|
| 623 |
</td> |
|---|
| 624 |
<% |
|---|
| 625 |
|
|---|
| 626 |
added.add(next); |
|---|
| 627 |
pos += colspan; |
|---|
| 628 |
} |
|---|
| 629 |
|
|---|
| 630 |
remaining = leftOver; |
|---|
| 631 |
} |
|---|
| 632 |
|
|---|
| 633 |
%> |
|---|
| 634 |
</tr> |
|---|
| 635 |
<% |
|---|
| 636 |
} |
|---|
| 637 |
|
|---|
| 638 |
Map parentEdges = new Hashtable(); |
|---|
| 639 |
|
|---|
| 640 |
%> |
|---|
| 641 |
</table> |
|---|
| 642 |
<script><!-- |
|---|
| 643 |
var children_by_id = Array(); |
|---|
| 644 |
<% |
|---|
| 645 |
|
|---|
| 646 |
for (Iterator i = edges.iterator(); i.hasNext(); ) |
|---|
| 647 |
{ |
|---|
| 648 |
Edge e = (Edge)( i.next() ); |
|---|
| 649 |
%>children_by_id["<%= edgeIds.get(e) %>"] = new Array(<% |
|---|
| 650 |
Edge [] children = e.parts(); |
|---|
| 651 |
List childList = new ArrayList(); |
|---|
| 652 |
for (int j = 0; j < children.length; j++) |
|---|
| 653 |
{ |
|---|
| 654 |
childList.add(children[j].getUnboundOriginal()); |
|---|
| 655 |
} |
|---|
| 656 |
if (fakeChild.get(e) != null) |
|---|
| 657 |
{ |
|---|
| 658 |
childList.add(fakeChild.get(e)); |
|---|
| 659 |
} |
|---|
| 660 |
for (Iterator j = childList.iterator(); j.hasNext(); ) |
|---|
| 661 |
{ |
|---|
| 662 |
Edge child = (Edge)( j.next() ); |
|---|
| 663 |
String id = (String)( edgeIds.get(child) ); |
|---|
| 664 |
%>"<%= id %>"<% |
|---|
| 665 |
if (j.hasNext()) |
|---|
| 666 |
{ |
|---|
| 667 |
%>, <% |
|---|
| 668 |
} |
|---|
| 669 |
|
|---|
| 670 |
List parentEdgeList = (List)( parentEdges.get(id) ); |
|---|
| 671 |
if (parentEdgeList == null) |
|---|
| 672 |
{ |
|---|
| 673 |
parentEdgeList = new ArrayList(); |
|---|
| 674 |
} |
|---|
| 675 |
&nb |
|---|