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", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 41 | "key":"subTitle", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 42 | "value":"Gedichte", |
| 43 | "match":"match:eq", |
| 44 | "rewrites" : [ |
| 45 | { |
| 46 | "@type": "koral:rewrite", |
| 47 | "src" : "policy", |
| 48 | "operation" : "operation:injection", |
| 49 | } |
| 50 | ] |
Akron | b19803c | 2018-08-16 16:39:42 +0200 | [diff] [blame] | 51 | }, |
| 52 | { |
| 53 | "@type":"koral:docGroupRef", |
| 54 | "ref":"@kalamar/myCorpus" |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 55 | } |
| 56 | ] |
| 57 | } |
| 58 | ] |
| 59 | }, |
| 60 | { |
| 61 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 62 | "key":"pubDate", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 63 | "type":"type:date", |
| 64 | "value":"2015-03-05", |
| 65 | "match":"match:geq" |
| 66 | } |
| 67 | ] |
| 68 | }; |
| 69 | |
Akron | 48b1e4d | 2015-06-17 18:47:01 +0200 | [diff] [blame] | 70 | var collections = [ |
| 71 | { |
| 72 | "statistics":{ |
| 73 | "paragraphs":2034752, |
| 74 | "documents":196510, |
| 75 | "tokens":51545081, |
| 76 | "sentences":4116282 |
| 77 | }, |
| 78 | "query":[ |
| 79 | { |
| 80 | "@value":{ |
| 81 | "@field":"korap:field#corpusID", |
| 82 | "@value":"WPD", |
| 83 | "@type":"korap:term" |
| 84 | }, |
| 85 | "@type":"korap:meta-filter" |
| 86 | } |
| 87 | ], |
| 88 | "name":"Wikipedia", |
| 89 | "path":"Wikipedia", |
| 90 | "description":"Die freie Enzyklopädie", |
| 91 | "shared":false, |
| 92 | "managed":true, |
| 93 | "created":"2015-04-01T23:04:32.000+02:00", |
| 94 | "foundries":"", |
| 95 | "id":"ZGU0ZTllNTFkYzc3M2VhZmViYzdkYWE2ODI5NDc3NTk4NGQ1YThhOTMwOTNhOWYxNWMwN2M3Y2YyZmE3N2RlNQ==" |
| 96 | } |
| 97 | ]; |
| 98 | |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 99 | |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 100 | require(['vc','lib/domReady', 'lib/highlight/highlight.pack'], function (vcClass, domReady) { |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 101 | |
| 102 | var loc = KorAP.Locale; |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 103 | |
| 104 | //corpus statistic |
| 105 | var statistic = { |
| 106 | "documents":1, |
| 107 | "tokens":222222, |
| 108 | "sentences":33333, |
| 109 | "paragraphs":444 |
| 110 | }; |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 111 | |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 112 | /* |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 113 | loc.AND = 'und'; |
| 114 | loc.OR = 'oder'; |
| 115 | loc.VC_subTitle = 'Untertitel'; |
| 116 | loc.VC_title = 'Titel'; |
| 117 | loc.VC_pubDate = 'Veröffentlichungsdatum'; |
| 118 | loc.VC_pubPlace = 'Veröffentlichungsort'; |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 119 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 120 | |
| 121 | domReady(function() { |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 122 | |
| 123 | // Create a new virtual collection by passing a based json object and |
| 124 | // field menu information |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 125 | var vc = vcClass.create([ |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 126 | ['title', 'string'], |
| 127 | ['subTitle', 'string'], |
| 128 | ['pubDate', 'date'], |
Akron | b19803c | 2018-08-16 16:39:42 +0200 | [diff] [blame] | 129 | ['author', 'text'], |
| 130 | ['@referTo', 'ref'] |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 131 | ]).fromJson(json); |
Nils Diewald | 8750783 | 2015-05-01 23:36:41 +0000 | [diff] [blame] | 132 | |
Akron | 2f97912 | 2018-07-25 17:00:23 +0200 | [diff] [blame] | 133 | document.getElementById('vc-view').appendChild(vc.element()); |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 134 | |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 135 | // show the current JSON serialization |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 136 | KorAP.showJSON = function () { |
Nils Diewald | 652e5f4 | 2015-05-10 18:11:45 +0000 | [diff] [blame] | 137 | var json = document.getElementById("json"); |
| 138 | json.innerHTML = JSON.stringify(vc.root().toJson(), null, ' '); |
| 139 | hljs.highlightBlock(json); |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 142 | // show the current query serialization |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 143 | KorAP.showQuery = function () { |
| 144 | document.getElementById("query").innerHTML = vc.root().toQuery(); |
| 145 | }; |
Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 146 | |
| 147 | // make the current vc persistant |
| 148 | KorAP.makeVCPersistant = function () { |
| 149 | vc.makePersistant(); |
| 150 | }; |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 151 | |
| 152 | //get the corpus statistic (demo function) |
| 153 | KorAP.API.getCorpStat = function(collQu, cb){ |
| 154 | return cb(statistic); |
| 155 | }; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 156 | }); |
hebasta | 3e90a5d | 2018-06-05 15:05:15 +0200 | [diff] [blame] | 157 | }); |
| 158 | |