blob: 0c66dd3e8ca8d87155c598855719e63ba0e4b3ea [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001requirejs.config({
2 baseUrl: '../js/src',
3 paths : {
4 'lib': '../lib'
5 }
6});
7
8var 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 Diewald4c221252015-04-21 20:19:25 +000018 "key":"title",
Nils Diewald0e6992a2015-04-14 20:13:52 +000019 "value":"Der Birnbaum",
20 "match":"match:eq"
21 },
22 {
23 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000024 "key":"pubPlace",
Nils Diewald0e6992a2015-04-14 20:13:52 +000025 "value":"Mannheim",
Akronea4e9052017-07-06 16:12:05 +020026 "type" : "type:regex",
27 "match":"match:contains"
Nils Diewald0e6992a2015-04-14 20:13:52 +000028 },
29 {
30 "@type":"koral:docGroup",
31 "operation":"operation:or",
32 "operands":[
33 {
34 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000035 "key":"subTitle",
Nils Diewald0e6992a2015-04-14 20:13:52 +000036 "value":"Aufzucht und Pflege",
37 "match":"match:eq"
38 },
39 {
40 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000041 "key":"subTitle",
Nils Diewald0e6992a2015-04-14 20:13:52 +000042 "value":"Gedichte",
43 "match":"match:eq",
44 "rewrites" : [
45 {
46 "@type": "koral:rewrite",
47 "src" : "policy",
48 "operation" : "operation:injection",
49 }
50 ]
Akronb19803c2018-08-16 16:39:42 +020051 },
52 {
53 "@type":"koral:docGroupRef",
54 "ref":"@kalamar/myCorpus"
Nils Diewald0e6992a2015-04-14 20:13:52 +000055 }
56 ]
57 }
58 ]
59 },
60 {
61 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000062 "key":"pubDate",
Nils Diewald0e6992a2015-04-14 20:13:52 +000063 "type":"type:date",
64 "value":"2015-03-05",
65 "match":"match:geq"
66 }
67 ]
68};
69
Akron48b1e4d2015-06-17 18:47:01 +020070var 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
hebasta3e90a5d2018-06-05 15:05:15 +020099
Akron49f88cc2018-09-11 11:06:19 +0200100require(['vc','vc/fragment','lib/domReady', 'lib/highlight/highlight.pack'], function (vcClass, fragmentClass, domReady) {
Nils Diewald4c221252015-04-21 20:19:25 +0000101
102 var loc = KorAP.Locale;
hebasta3e90a5d2018-06-05 15:05:15 +0200103
104 //corpus statistic
105 var statistic = {
106 "documents":1,
107 "tokens":222222,
108 "sentences":33333,
109 "paragraphs":444
110 };
Nils Diewald4c221252015-04-21 20:19:25 +0000111
Nils Diewald652e5f42015-05-10 18:11:45 +0000112/*
Nils Diewald4c221252015-04-21 20:19:25 +0000113 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 Diewald652e5f42015-05-10 18:11:45 +0000119*/
Nils Diewald0e6992a2015-04-14 20:13:52 +0000120
121 domReady(function() {
Nils Diewald4c221252015-04-21 20:19:25 +0000122
123 // Create a new virtual collection by passing a based json object and
124 // field menu information
Nils Diewald6283d692015-04-23 20:32:53 +0000125 var vc = vcClass.create([
Nils Diewald4c221252015-04-21 20:19:25 +0000126 ['title', 'string'],
127 ['subTitle', 'string'],
128 ['pubDate', 'date'],
Akron3ad46942018-08-22 16:47:14 +0200129 ['author', 'text']
Nils Diewald6283d692015-04-23 20:32:53 +0000130 ]).fromJson(json);
Nils Diewald87507832015-05-01 23:36:41 +0000131
Akron2f979122018-07-25 17:00:23 +0200132 document.getElementById('vc-view').appendChild(vc.element());
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000133
Akron5d286b22018-08-29 17:03:28 +0200134 vc.open();
135
Nils Diewald4c221252015-04-21 20:19:25 +0000136 // show the current JSON serialization
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000137 KorAP.showJSON = function () {
Nils Diewald652e5f42015-05-10 18:11:45 +0000138 var json = document.getElementById("json");
139 json.innerHTML = JSON.stringify(vc.root().toJson(), null, ' ');
140 hljs.highlightBlock(json);
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000141 };
142
Nils Diewald4c221252015-04-21 20:19:25 +0000143 // show the current query serialization
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000144 KorAP.showQuery = function () {
145 document.getElementById("query").innerHTML = vc.root().toQuery();
146 };
Nils Diewald845282c2015-05-14 07:53:03 +0000147
148 // make the current vc persistant
149 KorAP.makeVCPersistant = function () {
150 vc.makePersistant();
151 };
hebasta3e90a5d2018-06-05 15:05:15 +0200152
153 //get the corpus statistic (demo function)
154 KorAP.API.getCorpStat = function(collQu, cb){
155 return cb(statistic);
Akron49f88cc2018-09-11 11:06:19 +0200156 };
157
158
159 var f = fragmentClass.create();
160 f.add("author", "Peter");
161 f.add("title", "Sonstiges");
162 f.add("subTitle", "Anderes");
163
164 document.getElementById('fragment').appendChild(
165 f.element()
166 );
167
168 });
hebasta3e90a5d2018-06-05 15:05:15 +0200169});
170