Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 1 | requirejs.config({ |
| 2 | baseUrl: '../js/src', |
| 3 | paths : { |
| 4 | 'lib': '../lib' |
| 5 | } |
| 6 | }); |
| 7 | |
| 8 | var json = { |
| 9 | "@type":"koral:docGroup", |
| 10 | "operation":"operation:or", |
| 11 | "operands":[ |
| 12 | { |
| 13 | "@type":"koral:docGroup", |
| 14 | "operation":"operation:and", |
| 15 | "operands":[ |
| 16 | { |
| 17 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 18 | "key":"title", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 19 | "value":"Der Birnbaum", |
| 20 | "match":"match:eq" |
| 21 | }, |
| 22 | { |
| 23 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 24 | "key":"pubPlace", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 25 | "value":"Mannheim", |
Akron | ea4e905 | 2017-07-06 16:12:05 +0200 | [diff] [blame] | 26 | "type" : "type:regex", |
| 27 | "match":"match:contains" |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 28 | }, |
| 29 | { |
| 30 | "@type":"koral:docGroup", |
| 31 | "operation":"operation:or", |
| 32 | "operands":[ |
| 33 | { |
| 34 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 35 | "key":"subTitle", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 36 | "value":"Aufzucht und Pflege", |
| 37 | "match":"match:eq" |
| 38 | }, |
| 39 | { |
| 40 | "@type":"koral:doc", |
Akron | 5d4f2e4 | 2024-12-16 09:10:27 +0100 | [diff] [blame^] | 41 | "key":"nTok", |
| 42 | "type":"type:integer", |
| 43 | "value":200, |
| 44 | "match":"match:eq" |
| 45 | }, |
| 46 | { |
| 47 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 48 | "key":"subTitle", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 49 | "value":"Gedichte", |
| 50 | "match":"match:eq", |
| 51 | "rewrites" : [ |
| 52 | { |
| 53 | "@type": "koral:rewrite", |
| 54 | "src" : "policy", |
| 55 | "operation" : "operation:injection", |
| 56 | } |
| 57 | ] |
Akron | b19803c | 2018-08-16 16:39:42 +0200 | [diff] [blame] | 58 | }, |
| 59 | { |
| 60 | "@type":"koral:docGroupRef", |
| 61 | "ref":"@kalamar/myCorpus" |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 62 | } |
| 63 | ] |
| 64 | } |
| 65 | ] |
| 66 | }, |
| 67 | { |
| 68 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 69 | "key":"pubDate", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 70 | "type":"type:date", |
| 71 | "value":"2015-03-05", |
| 72 | "match":"match:geq" |
| 73 | } |
| 74 | ] |
| 75 | }; |
| 76 | |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 77 | var corpora = [ |
Akron | 48b1e4d | 2015-06-17 18:47:01 +0200 | [diff] [blame] | 78 | { |
| 79 | "statistics":{ |
| 80 | "paragraphs":2034752, |
| 81 | "documents":196510, |
| 82 | "tokens":51545081, |
| 83 | "sentences":4116282 |
| 84 | }, |
| 85 | "query":[ |
| 86 | { |
| 87 | "@value":{ |
| 88 | "@field":"korap:field#corpusID", |
| 89 | "@value":"WPD", |
| 90 | "@type":"korap:term" |
| 91 | }, |
| 92 | "@type":"korap:meta-filter" |
| 93 | } |
| 94 | ], |
| 95 | "name":"Wikipedia", |
| 96 | "path":"Wikipedia", |
| 97 | "description":"Die freie Enzyklopädie", |
| 98 | "shared":false, |
| 99 | "managed":true, |
| 100 | "created":"2015-04-01T23:04:32.000+02:00", |
| 101 | "foundries":"", |
| 102 | "id":"ZGU0ZTllNTFkYzc3M2VhZmViYzdkYWE2ODI5NDc3NTk4NGQ1YThhOTMwOTNhOWYxNWMwN2M3Y2YyZmE3N2RlNQ==" |
| 103 | } |
| 104 | ]; |
| 105 | |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 106 | |
Akron | 49f88cc | 2018-09-11 11:06:19 +0200 | [diff] [blame] | 107 | require(['vc','vc/fragment','lib/domReady', 'lib/highlight/highlight.pack'], function (vcClass, fragmentClass, domReady) { |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 108 | |
| 109 | var loc = KorAP.Locale; |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 110 | |
| 111 | //corpus statistic |
| 112 | var statistic = { |
| 113 | "documents":1, |
| 114 | "tokens":222222, |
| 115 | "sentences":33333, |
| 116 | "paragraphs":444 |
| 117 | }; |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 118 | |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 119 | /* |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 120 | loc.AND = 'und'; |
| 121 | loc.OR = 'oder'; |
| 122 | loc.VC_subTitle = 'Untertitel'; |
| 123 | loc.VC_title = 'Titel'; |
| 124 | loc.VC_pubDate = 'Veröffentlichungsdatum'; |
| 125 | loc.VC_pubPlace = 'Veröffentlichungsort'; |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 126 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 127 | |
| 128 | domReady(function() { |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 129 | |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 130 | // Create a new virtual corpus by passing a based json object and |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 131 | // field menu information |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 132 | KorAP.vc = vcClass.create([ |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 133 | ['title', 'string'], |
| 134 | ['subTitle', 'string'], |
| 135 | ['pubDate', 'date'], |
Akron | 3ad4694 | 2018-08-22 16:47:14 +0200 | [diff] [blame] | 136 | ['author', 'text'] |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 137 | ]).fromJson(json); |
Nils Diewald | 8750783 | 2015-05-01 23:36:41 +0000 | [diff] [blame] | 138 | |
hebasta | de595b4 | 2019-02-05 13:53:10 +0100 | [diff] [blame] | 139 | |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 140 | document.getElementById('vc-view').appendChild(KorAP.vc.element()); |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 141 | |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 142 | KorAP.vc.open(); |
Akron | 5d286b2 | 2018-08-29 17:03:28 +0200 | [diff] [blame] | 143 | |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 144 | // show the current JSON serialization |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 145 | KorAP.showJSON = function () { |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 146 | var json = document.getElementById("json"); |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 147 | json.innerHTML = JSON.stringify(KorAP.vc.root().toJson(), null, ' '); |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 148 | hljs.highlightBlock(json); |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 149 | }; |
| 150 | |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 151 | // show the current query serialization |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 152 | KorAP.showQuery = function () { |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 153 | document.getElementById("query").innerHTML = KorAP.vc.root().toQuery(); |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 154 | }; |
Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 155 | |
| 156 | // make the current vc persistant |
| 157 | KorAP.makeVCPersistant = function () { |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 158 | KorAP.vc.makePersistant(); |
Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 159 | }; |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 160 | |
| 161 | //get the corpus statistic (demo function) |
| 162 | KorAP.API.getCorpStat = function(collQu, cb){ |
| 163 | return cb(statistic); |
Akron | 49f88cc | 2018-09-11 11:06:19 +0200 | [diff] [blame] | 164 | }; |
| 165 | |
| 166 | |
| 167 | var f = fragmentClass.create(); |
| 168 | f.add("author", "Peter"); |
| 169 | f.add("title", "Sonstiges"); |
| 170 | f.add("subTitle", "Anderes"); |
| 171 | |
| 172 | document.getElementById('fragment').appendChild( |
| 173 | f.element() |
| 174 | ); |
| 175 | |
| 176 | }); |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 177 | }); |
| 178 | |