Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 1 | var snippet = "<span title=\"cnx/l:meist\">" + |
| 2 | " <span title=\"cnx/p:ADV\">" + |
| 3 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 4 | " <span title=\"mate/l:meist\">" + |
| 5 | " <span title=\"mate/p:ADV\">" + |
| 6 | " <span title=\"opennlp/p:ADV\">meist</span>" + |
| 7 | " </span>" + |
| 8 | " </span>" + |
| 9 | " </span>" + |
| 10 | " </span>" + |
| 11 | "</span>" + |
| 12 | "<span title=\"cnx/l:deutlich\">" + |
| 13 | " <span title=\"cnx/p:A\">" + |
| 14 | " <span title=\"cnx/syn:@PREMOD\">" + |
| 15 | " <span title=\"mate/l:deutlich\">" + |
| 16 | " <span title=\"mate/m:degree:pos\">" + |
| 17 | " <span title=\"mate/p:ADJD\">" + |
| 18 | " <span title=\"opennlp/p:ADJD\">deutlich</span>" + |
| 19 | " </span>" + |
| 20 | " </span>" + |
| 21 | " </span>" + |
| 22 | " </span>" + |
| 23 | " </span>" + |
| 24 | "</span>" + |
| 25 | "<span title=\"cnx/l:fähig\">" + |
| 26 | " <span title=\"cnx/l:leistung\">" + |
| 27 | " <span title=\"cnx/p:A\">" + |
| 28 | " <span title=\"cnx/syn:@NH\">" + |
| 29 | " <span title=\"mate/l:leistungsfähig\">" + |
| 30 | " <span title=\"mate/m:degree:comp\">" + |
| 31 | " <span title=\"mate/p:ADJD\">" + |
| 32 | " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" + |
| 33 | " </span>" + |
| 34 | " </span>" + |
| 35 | " </span>" + |
| 36 | " </span>" + |
| 37 | " </span>" + |
| 38 | " </span>" + |
| 39 | "</span>"; |
| 40 | |
| 41 | var treeSnippet = |
| 42 | "<span class=\"context-left\"></span>" + |
| 43 | "<span class=\"match\">" + |
| 44 | " <span title=\"xip/c:MC\">" + |
| 45 | " <span title=\"xip/c:TOP\">" + |
| 46 | " <span title=\"xip/c:PP\">" + |
| 47 | " <span title=\"xip/c:PREP\">Mit</span>" + |
| 48 | " <span title=\"xip/c:NP\">" + |
| 49 | " <span title=\"xip/c:DET\">dieser</span>" + |
| 50 | " <span title=\"xip/c:NPA\">" + |
| 51 | " <span title=\"xip/c:NOUN\">Methode</span>" + |
| 52 | " </span>" + |
| 53 | " </span>" + |
| 54 | " </span>" + |
| 55 | " <span title=\"xip/c:VERB\">ist</span>" + |
| 56 | " <span title=\"xip/c:NP\">" + |
| 57 | " <span title=\"xip/c:PRON\">es</span>" + |
| 58 | " </span>" + |
| 59 | " <span title=\"xip/c:AP\">" + |
| 60 | " <span title=\"xip/c:ADV\">nun</span>" + |
| 61 | " <span title=\"xip/c:ADJ\">möglich</span>" + |
| 62 | " </span>" + |
| 63 | " <span title=\"xip/c:ADV\">z. B.</span>" + |
| 64 | " <span title=\"xip/c:NPA\">" + |
| 65 | " <span title=\"xip/c:NP\">" + |
| 66 | " <span title=\"xip/c:NOUN\">Voice</span>" + |
| 67 | " </span>" + |
| 68 | " </span>" + "(" + |
| 69 | " <span title=\"xip/c:INS\">" + |
| 70 | " <span title=\"xip/c:NPA\">" + |
| 71 | " <span title=\"xip/c:NP\">" + |
| 72 | " <span title=\"xip/c:NOUN\">Sprache</span>" + |
| 73 | " </span>" + |
| 74 | " </span>" + |
| 75 | " </span>" + ")" + |
| 76 | " <span title=\"xip/c:VERB\">bevorzugt</span>" + |
| 77 | " <span title=\"xip/c:PP\">" + |
| 78 | " <span title=\"xip/c:PREP\">in</span>" + |
| 79 | " <span title=\"xip/c:NP\">" + |
| 80 | " <span title=\"xip/c:PRON\">der</span>" + |
| 81 | " </span>" + |
| 82 | " <span title=\"xip/c:NPA\">" + |
| 83 | " <span title=\"xip/c:NP\">" + |
| 84 | " <span title=\"xip/c:NOUN\">Bridge</span>" + |
| 85 | " </span>" + |
| 86 | " </span>" + |
| 87 | " </span>" + |
| 88 | " <span title=\"xip/c:INFC\">" + |
| 89 | " <span title=\"xip/c:INS\">" + |
| 90 | " <span title=\"xip/c:VERB\">weiterzugeben</span>" + |
| 91 | " </span>" + |
| 92 | " </span>" + |
| 93 | " </span>" + |
| 94 | " </span>" + |
| 95 | "</span>" + |
| 96 | "<span class=\"context-right\"></span>"; |
| 97 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 98 | var menuContent = [ |
| 99 | ['cnx/c', 'cnx', 'c'], |
| 100 | ['mate/c', 'mate', 'c'], |
| 101 | ['base/c', 'base', 'c'], |
| 102 | ['xip/c', 'xip', 'c'], |
| 103 | ['tt/c', 'tt', 'c'] |
| 104 | ]; |
| 105 | |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame^] | 106 | var namedEntities = [ |
| 107 | ["I-LOC", "I-LOC ", "Location"], |
| 108 | ["I-MISC", "I-MISC ", "Miscellaneous"], |
| 109 | ["I-ORG", "I-ORG ", "Organization"], |
| 110 | ["I-PER", "I-PER ", "Person"] |
| 111 | ]; |
| 112 | |
| 113 | // http://www.ids-mannheim.de/cosmas2/projekt/referenz/stts/morph.html |
| 114 | // http://nachhalt.sfb632.uni-potsdam.de/owl-docu/stts.html |
| 115 | var sttsArray = [ |
| 116 | // "$.", "$(", "$," |
| 117 | ["ADJA","ADJA ", "Attributive Adjective"], |
| 118 | ["ADJD","ADJD ", "Predicative Adjective"], |
| 119 | ["ADV","ADV ", "Adverb"], |
| 120 | ["APPO","APPO ", "Postposition"], |
| 121 | ["APPR","APPR ", "Preposition"], |
| 122 | ["APPRART","APPRART ", "Preposition with Determiner"], |
| 123 | ["APZR","APZR ","Right Circumposition"], |
| 124 | ["ART","ART ", "Determiner"], |
| 125 | ["CARD","CARD ", "Cardinal Number"], |
| 126 | ["FM","FM ", "Foreign Material"], |
| 127 | ["ITJ","ITJ ", "Interjection"], |
| 128 | ["KOKOM","KOKOM ", "Comparison Particle"], |
| 129 | ["KON","KON ", "Coordinating Conjuncion"], |
| 130 | ["KOUI","KOUI ", "Subordinating Conjunction with 'zu'"], |
| 131 | ["KOUS","KOUS ", "Subordinating Conjunction with Sentence"], |
| 132 | ["NE","NE ", "Named Entity"], |
| 133 | ["NN","NN ", "Normal Nomina"], |
| 134 | ["PAV", "PAV ", "Pronominal Adverb"], |
| 135 | ["PDAT","PDAT ","Attributive Demonstrative Pronoun"], |
| 136 | ["PDS","PDS ", "Substitutive Demonstrative Pronoun"], |
| 137 | ["PIAT","PIAT ", "Attributive Indefinite Pronoun without Determiner"], |
| 138 | ["PIDAT","PIDAT ", "Attributive Indefinite Pronoun with Determiner"], |
| 139 | ["PIS","PIS ", "Substitutive Indefinite Pronoun"], |
| 140 | ["PPER","PPER ", "Personal Pronoun"], |
| 141 | ["PPOSAT","PPOSAT ", "Attributive Possessive Pronoun"], |
| 142 | ["PPOSS","PPOSS ", "Substitutive Possessive Pronoun"], |
| 143 | ["PRELAT","PRELAT ", "Attributive Relative Pronoun"], |
| 144 | ["PRELS","PRELS ", "Substitutive Relative Pronoun"], |
| 145 | ["PRF","PRF ", "Reflexive Pronoun"], |
| 146 | ["PROAV","PROAV ", "Pronominal Adverb"], |
| 147 | ["PTKA","PTKA ","Particle with Adjective"], |
| 148 | ["PTKANT","PTKANT ", "Answering Particle"], |
| 149 | ["PTKNEG","PTKNEG ", "Negation Particle"], |
| 150 | ["PTKVZ","PTKVZ ", "Separated Verbal Particle"], |
| 151 | ["PTKZU","PTKZU ", "'zu' Particle"], |
| 152 | ["PWAT","PWAT ", "Attributive Interrogative Pronoun"], |
| 153 | ["PWAV","PWAV ", "Adverbial Interrogative Pronoun"], |
| 154 | ["PWS","PWS ", "Substitutive Interrogative Pronoun"], |
| 155 | ["TRUNC","TRUNC ","Truncated"], |
| 156 | ["VAFIN","VAFIN ", "Auxiliary Finite Verb"], |
| 157 | ["VAINF","VAINF ", "Auxiliary Infinite Verb"], |
| 158 | ["VAIMP","VAIMP ", "Auxiliary Finite Imperative Verb"], |
| 159 | ["VAPP","VAPP ", "Auxiliary Perfect Participle"], |
| 160 | ["VMFIN","VMFIN ", "Modal Finite Verb"], |
| 161 | ["VMINF","VMINF ", "Modal Infinite Verb"], |
| 162 | ["VMPP","VMPP ", "Modal Perfect Participle"], |
| 163 | ["VVFIN","VVFIN ","Finite Verb"], |
| 164 | ["VVIMP","VVIMP ", "Finite Imperative Verb"], |
| 165 | ["VVINF","VVINF ", "Infinite Verb"], |
| 166 | ["VVIZU","VVIZU ", "Infinite Verb with 'zu'"], |
| 167 | ["VVPP","VVPP ", "Perfect Participle"], |
| 168 | ["XY", "XY ", "Non-Word"] |
| 169 | ]; |
| 170 | |
| 171 | var mateSttsArray = sttsArray.slice(0); |
| 172 | mateSttsArray.push( |
| 173 | ["<root-POS>","<root-POS>","Root Part of Speech"] |
| 174 | ); |
| 175 | |
| 176 | |
| 177 | var vcExample = { |
| 178 | "@type":"koral:docGroup", |
| 179 | "operation":"operation:or", |
| 180 | "operands":[ |
| 181 | { |
| 182 | "@type":"koral:docGroup", |
| 183 | "operation":"operation:and", |
| 184 | "operands":[ |
| 185 | { |
| 186 | "@type":"koral:doc", |
| 187 | "key":"Titel", |
| 188 | "value":"Der Birnbaum", |
| 189 | "match":"match:eq" |
| 190 | }, |
| 191 | { |
| 192 | "@type":"koral:doc", |
| 193 | "key":"Veröffentlichungsort", |
| 194 | "value":"Mannheim", |
| 195 | "match":"match:eq" |
| 196 | }, |
| 197 | { |
| 198 | "@type":"koral:docGroup", |
| 199 | "operation":"operation:or", |
| 200 | "operands":[ |
| 201 | { |
| 202 | "@type":"koral:doc", |
| 203 | "key":"Untertitel", |
| 204 | "value":"Aufzucht und Pflege", |
| 205 | "match":"match:eq" |
| 206 | }, |
| 207 | { |
| 208 | "@type":"koral:doc", |
| 209 | "key":"Untertitel", |
| 210 | "value":"Gedichte", |
| 211 | "match":"match:eq", |
| 212 | "rewrites" : [ |
| 213 | { |
| 214 | "@type": "koral:rewrite", |
| 215 | "src" : "policy", |
| 216 | "operation" : "operation:injection", |
| 217 | } |
| 218 | ] |
| 219 | } |
| 220 | ] |
| 221 | } |
| 222 | ] |
| 223 | }, |
| 224 | { |
| 225 | "@type":"koral:doc", |
| 226 | "key":"Veröffentlichungsdatum", |
| 227 | "type":"type:date", |
| 228 | "value":"2015-03-05", |
| 229 | "match":"match:geq" |
| 230 | } |
| 231 | ] |
| 232 | }; |
| 233 | |
| 234 | |
| 235 | KorAP.hintArray = { |
| 236 | "-" : [ |
| 237 | ["Connexor", "cnx/", "Constituency, Lemma, Morphology, Part-of-Speech, Syntax"], |
| 238 | ["CoreNLP", "corenlp/", "Named Entities"], |
| 239 | ["Mate", "mate/", "Lemma, Morphology, Part-of-Speech"], |
| 240 | ["OpenNLP", "opennlp/", "Part-of-Speech"], |
| 241 | ["TreeTagger", "tt/", "Lemma, Part-of-Speech"], |
| 242 | ["Xerox Parser", "xip/", "Constituency, Lemma, Part-of-Speech"] |
| 243 | ], |
| 244 | "corenlp/" : [ |
| 245 | ["Named Entity", "ne=" , "Combined"], |
| 246 | ["Named Entity", "ne_dewac_175m_600=" , "ne_dewac_175m_600"], |
| 247 | ["Named Entity", "ne_hgc_175m_600=", "ne_hgc_175m_600"] |
| 248 | ], |
| 249 | "corenlp/ne=" : namedEntities, |
| 250 | "corenlp/ne_dewac_175m_600=" : namedEntities, |
| 251 | "corenlp/ne_hgc_175m_600=" : namedEntities, |
| 252 | "cnx/" : [ |
| 253 | ["Constituency", "c="], |
| 254 | ["Lemma", "l="], |
| 255 | ["Morphology", "m="], |
| 256 | ["Part-of-Speech", "p="], |
| 257 | ["Syntax", "syn="] |
| 258 | ], |
| 259 | "cnx/c=" : [ |
| 260 | ["np", "np ", "Nominal Phrase"] |
| 261 | ], |
| 262 | // http://www.ids-mannheim.de/cosmas2/projekt/referenz/connexor/morph.html |
| 263 | "cnx/m=" : [ |
| 264 | ["Abbr","Abbr ", "Nouns: Abbreviation"], |
| 265 | ["CMP","CMP ", "Adjective: Comparative"], |
| 266 | ["IMP", "IMP ", "Mood: Imperative"], |
| 267 | ["IND", "IND ", "Mood: Indicative"], |
| 268 | ["INF", "INF ", "Infinitive"], |
| 269 | ["ORD","ORD ", "Numeral: Ordinal"], |
| 270 | ["PAST", "PAST ", "Tense: past"], |
| 271 | ["PCP", "PCP ", "Participle"], |
| 272 | ["PERF", "PERF ", "Perfective Participle"], |
| 273 | ["PL","PL ", "Nouns: Plural"], |
| 274 | ["PRES", "PRES ", "Tense: present"], |
| 275 | ["PROG", "PROG ", "Progressive Participle"], |
| 276 | ["Prop","Prop ", "Nouns: Proper Noun"], |
| 277 | ["SUB", "SUB ", "Mood: Subjunctive"], |
| 278 | ["SUP","SUP ", "Adjective: Superlative"] |
| 279 | ], |
| 280 | // http://www.ids-mannheim.de/cosmas2/projekt/referenz/connexor/morph.html |
| 281 | "cnx/p=" : [ |
| 282 | ["A", "A ", "Adjective"], |
| 283 | ["ADV", "ADV ", "Adverb"], |
| 284 | ["CC", "CC ", "Coordination Marker"], |
| 285 | ["CS", "CS ", "Clause Marker"], |
| 286 | ["DET", "DET ", "Determiner"], |
| 287 | ["INTERJ", "INTERJ ", "Interjection"], |
| 288 | ["N", "N ", "Noun"], |
| 289 | ["NUM", "NUM ", "Numeral"], |
| 290 | ["PREP", "PREP ", "Preposition"], |
| 291 | ["PRON", "PRON ", "Pro-Nominal"], |
| 292 | ["V", "V ", "Verb"] |
| 293 | ], |
| 294 | // http://www.ids-mannheim.de/cosmas2/projekt/referenz/connexor/syntax.html |
| 295 | "cnx/syn=" : [ |
| 296 | ["@ADVL", "@ADVL ", "Adverbial Head"], |
| 297 | ["@AUX", "@AUX ", "Auxiliary Verb"], |
| 298 | ["@CC", "@CC ", "Coordination"] |
| 299 | ["@MAIN", "@MAIN ", "Main Verb"], |
| 300 | ["@NH", "@NH ", "Nominal Head"], |
| 301 | ["@POSTMOD", "@POSTMOD ", "Postmodifier"], |
| 302 | ["@PREMARK", "@PREMARK ", "Preposed Marker"], |
| 303 | ["@PREMOD", "@POSTMOD ", "Premodifier"] |
| 304 | ], |
| 305 | "opennlp/" : [ |
| 306 | ["Part-of-Speech", "p="] |
| 307 | ], |
| 308 | "opennlp/p=" : sttsArray, |
| 309 | "xip/" : [ |
| 310 | ["Constituency", "c="], |
| 311 | // Inactive: ["Dependency", "d="], |
| 312 | ["Lemma", "l="], |
| 313 | ["Part-of-Speech", "p="], |
| 314 | ], |
| 315 | // "xip/c=" : [], |
| 316 | // Inactive: "xip/d=" : [], |
| 317 | // "xip/p=" : [], |
| 318 | "tt/" : [ |
| 319 | ["Lemma", "l="], |
| 320 | ["Part-of-Speech", "p="] |
| 321 | ], |
| 322 | "tt/p=" : sttsArray, |
| 323 | "mate/" : [ |
| 324 | // Inactive: "d" : ["d=", "Dependency"], |
| 325 | ["Lemma", "l="], |
| 326 | ["Morphology", "m="], |
| 327 | ["Part-of-Speech", "p="] |
| 328 | ], |
| 329 | // Inactive: mate/d= |
| 330 | "mate/p=" : mateSttsArray, |
| 331 | "mate/m=" : [ |
| 332 | ["Case", "case:"], |
| 333 | ["Degree", "degree:"], |
| 334 | ["Gender", "gender:"], |
| 335 | ["Mood", "mood:"], |
| 336 | ["Number", "number:"], |
| 337 | ["Person", "person:"], |
| 338 | ["Tense","tense:"], |
| 339 | ["No type", "<no-type> "] |
| 340 | ], |
| 341 | "mate/m=case:" : [ |
| 342 | ["acc", "acc ", "Accusative"], |
| 343 | ["dat","dat ", "Dative"], |
| 344 | ["gen", "gen ","Genitive"], |
| 345 | ["nom","nom ", "Nominative"], |
| 346 | ["*","* ", "Undefined"] |
| 347 | ], |
| 348 | "mate/m=degree:" : [ |
| 349 | ["comp","comp ", "Comparative"], |
| 350 | ["pos","pos ", "Positive"], |
| 351 | ["sup","sup ", "Superative"] |
| 352 | ], |
| 353 | "mate/m=gender:" : [ |
| 354 | ["fem", "fem ", "Feminium"], |
| 355 | ["masc", "masc ", "Masculinum"], |
| 356 | ["neut","neut ", "Neuter"], |
| 357 | ["*","* ","Undefined"] |
| 358 | ], |
| 359 | "mate/m=mood:" : [ |
| 360 | ["imp","imp ", "Imperative"], |
| 361 | ["ind","ind ", "Indicative"], |
| 362 | ["subj","subj ", "Subjunctive"] |
| 363 | ], |
| 364 | "mate/m=number:" : [ |
| 365 | ["pl","pl ","Plural"], |
| 366 | ["sg","sg ","Singular"], |
| 367 | ["*","* ","Undefined"] |
| 368 | ], |
| 369 | "mate/m=person:" : [ |
| 370 | ["1","1 ", "First Person"], |
| 371 | ["2","2 ", "Second Person"], |
| 372 | ["3","3 ", "Third Person"] |
| 373 | ], |
| 374 | "mate/m=tense:" : [ |
| 375 | ["past","past ", "Past"], |
| 376 | ["pres","pres ", "Present"] |
| 377 | ] |
| 378 | }; |
| 379 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 380 | // Parse and show the table |
| 381 | // Override getMatchInfo API call |
| 382 | KorAP.API.getMatchInfo = function(match, callObj) { |
| 383 | if (callObj["spans"] !== undefined && callObj["spans"] === true) { |
| 384 | return { "snippet": treeSnippet }; |
| 385 | } |
| 386 | else { |
| 387 | return { "snippet": snippet }; |
| 388 | } |
| 389 | }; |
| 390 | |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame^] | 391 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 392 | /** |
| 393 | * Do some things at the beginning. |
| 394 | */ |
| 395 | window.onload = function () { |
| 396 | |
| 397 | // Decorate actions |
| 398 | KorAP.init(); |
| 399 | |
| 400 | var menu = KorAP.MatchTreeMenu.create( |
| 401 | undefined, |
| 402 | menuContent |
| 403 | ); |
| 404 | |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame^] | 405 | var vc = KorAP.VirtualCollection.render(vcExample); |
| 406 | document.getElementById('vc').appendChild(vc.element()); |
| 407 | |
| 408 | |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 409 | // Don't hide!!! |
| 410 | menu.hide = function () {}; |
| 411 | document.getElementById('menu').appendChild(menu.element()); |
| 412 | menu.limit(3); |
| 413 | menu.show(); |
| 414 | menu.focus(); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 415 | }; |