Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame] | 1 | var treeSnippet = |
| 2 | "<span class=\"context-left\"></span>" + |
| 3 | "<span class=\"match\">" + |
| 4 | " <span title=\"xip/c:MC\">" + |
| 5 | " <span title=\"xip/c:TOP\">" + |
| 6 | " <span title=\"xip/c:PP\">" + |
| 7 | " <span title=\"xip/c:PREP\">Mit</span>" + |
| 8 | " <span title=\"xip/c:NP\">" + |
| 9 | " <span title=\"xip/c:DET\">dieser</span>" + |
| 10 | " <span title=\"xip/c:NPA\">" + |
| 11 | " <span title=\"xip/c:NOUN\">Methode</span>" + |
| 12 | " </span>" + |
| 13 | " </span>" + |
| 14 | " </span>" + |
| 15 | " <span title=\"xip/c:VERB\">ist</span>" + |
| 16 | " <span title=\"xip/c:NP\">" + |
| 17 | " <span title=\"xip/c:PRON\">es</span>" + |
| 18 | " </span>" + |
| 19 | " <span title=\"xip/c:AP\">" + |
| 20 | " <span title=\"xip/c:ADV\">nun</span>" + |
| 21 | " <span title=\"xip/c:ADJ\">möglich</span>" + |
| 22 | " </span>" + |
| 23 | " <span title=\"xip/c:ADV\">z. B.</span>" + |
| 24 | " <span title=\"xip/c:NPA\">" + |
| 25 | " <span title=\"xip/c:NP\">" + |
| 26 | " <span title=\"xip/c:NOUN\">Voice</span>" + |
| 27 | " </span>" + |
| 28 | " </span>" + "(" + |
| 29 | " <span title=\"xip/c:INS\">" + |
| 30 | " <span title=\"xip/c:NPA\">" + |
| 31 | " <span title=\"xip/c:NP\">" + |
| 32 | " <span title=\"xip/c:NOUN\">Sprache</span>" + |
| 33 | " </span>" + |
| 34 | " </span>" + |
| 35 | " </span>" + ")" + |
| 36 | " <span title=\"xip/c:VERB\">bevorzugt</span>" + |
| 37 | " <span title=\"xip/c:PP\">" + |
| 38 | " <span title=\"xip/c:PREP\">in</span>" + |
| 39 | " <span title=\"xip/c:NP\">" + |
| 40 | " <span title=\"xip/c:PRON\">der</span>" + |
| 41 | " </span>" + |
| 42 | " <span title=\"xip/c:NPA\">" + |
| 43 | " <span title=\"xip/c:NP\">" + |
| 44 | " <span title=\"xip/c:NOUN\">Bridge</span>" + |
| 45 | " </span>" + |
| 46 | " </span>" + |
| 47 | " </span>" + |
| 48 | " <span title=\"xip/c:INFC\">" + |
| 49 | " <span title=\"xip/c:INS\">" + |
| 50 | " <span title=\"xip/c:VERB\">weiterzugeben</span>" + |
| 51 | " </span>" + |
| 52 | " </span>" + |
| 53 | " </span>" + |
| 54 | " </span>" + |
| 55 | "</span>" + |
| 56 | "<span class=\"context-right\"></span>"; |
| 57 | |
Akron | f5dc510 | 2017-05-16 20:32:57 +0200 | [diff] [blame] | 58 | requirejs.config({ |
Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame] | 59 | baseUrl: '../js/src', |
| 60 | paths : { |
| 61 | 'lib': '../lib' |
| 62 | } |
Akron | f5dc510 | 2017-05-16 20:32:57 +0200 | [diff] [blame] | 63 | }); |
| 64 | |
Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame] | 65 | require(['match/relations', 'match/tree'], function (relClass, treeClass) { |
Akron | f5dc510 | 2017-05-16 20:32:57 +0200 | [diff] [blame] | 66 | var rel = relClass.create(); |
Akron | 3a4a08e | 2017-05-23 22:34:18 +0200 | [diff] [blame] | 67 | |
| 68 | /* |
| 69 | * Start and end may be spans, i.e. arrays |
| 70 | */ |
| 71 | |
| 72 | rel |
| 73 | .addToken("Der") |
| 74 | .addToken("alte") |
| 75 | .addToken("Mann") |
| 76 | .addToken("ging") |
| 77 | .addToken("über") |
| 78 | .addToken("die") |
| 79 | .addToken("breite") |
| 80 | .addToken("nasse") |
| 81 | .addToken("Straße") |
| 82 | ; |
| 83 | |
| 84 | rel |
Akron | 65d3108 | 2017-09-08 16:23:40 +0200 | [diff] [blame] | 85 | .addRel({ start: 0, end: 1, label: "a", direction: "uni"}) |
| 86 | .addRel({ start: 0, end: 1, label: "b", direction: "uni" }) |
Akron | 3a4a08e | 2017-05-23 22:34:18 +0200 | [diff] [blame] | 87 | .addRel({ start: 1, end: 2, label: "c", direction: "bi" }) |
Akron | 65d3108 | 2017-09-08 16:23:40 +0200 | [diff] [blame] | 88 | .addRel({ start: 0, end: 2, label: "dreizehn", direction: "uni" }) |
| 89 | .addRel({ start: [2,4], end: 5, label: "e", direction: "uni" }) |
| 90 | .addRel({ start: [5,6], end: 7, label: "g", direction: "uni" }) |
Akron | 3a4a08e | 2017-05-23 22:34:18 +0200 | [diff] [blame] | 91 | .addRel({ start: 4, end: [6,8], label: "f", direction: "bi" }) |
| 92 | ; |
Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame] | 93 | |
| 94 | document.getElementById("treeRel").appendChild(rel.element()); |
| 95 | |
| 96 | // Todo: Probably rename to rel.draw() |
Akron | f5dc510 | 2017-05-16 20:32:57 +0200 | [diff] [blame] | 97 | rel.show(); |
Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame] | 98 | |
| 99 | var tree = treeClass.create(treeSnippet); |
| 100 | document.getElementById("treeHier").appendChild(tree.element()); |
Akron | f5dc510 | 2017-05-16 20:32:57 +0200 | [diff] [blame] | 101 | }); |
Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame] | 102 | |