Deprecated 'collection' parameter in favor of 'cq' - fixes #92
Change-Id: I51f0197da3a182fc4d4cd35f12ccb88cce3f8833
diff --git a/Changes b/Changes
index b33b2e3..a1d46e1 100755
--- a/Changes
+++ b/Changes
@@ -1,7 +1,9 @@
-0.35 2019-07-05
+0.35 2019-07-12
- Added EXPERIMENTAL proxy to API route.
- Remove deprecated api configuration
(requires api_path instead now).
+ - Deprecated 'collection' parameter in
+ favor of 'cq' (#92).
0.34 2019-06-26
- Introduced guided tour (hebasta, #19).
diff --git a/dev/demo/all.html b/dev/demo/all.html
index 8417903..bd7461c 100644
--- a/dev/demo/all.html
+++ b/dev/demo/all.html
@@ -37,12 +37,12 @@
<!-- <i class="fa fa-arrow-circle-down show-hint" onclick="hint.popUp()"></i> -->
</div>
- <!-- Search in the following virtual collection -->
+ <!-- Search in the following virtual corpus -->
<div id="vc-view"></div>
in
<input id="show" name="show" type="hidden" />
<!--<input id="collection-name" name="collection-name" type="hidden"> -->
- <input id="collection" name="collection" type="text" value="">
+ <input id="cq" name="cq" type="text" value="">
with <span class="menu select">
<select name="ql" id="ql-field">
<option value="poliqarp">Poliqarp</option>
@@ -111,7 +111,7 @@
KorAP.koralQuery = {
"matches":["..."],
- "collection":{
+ "corpus":{
"@type": "koral:docGroup",
"operation": "operation:or", "operands": [{
"@type": "koral:docGroup",
diff --git a/dev/demo/alldemo.js b/dev/demo/alldemo.js
index 6f9f60b..108bfe6 100644
--- a/dev/demo/alldemo.js
+++ b/dev/demo/alldemo.js
@@ -774,7 +774,7 @@
require(['app/en', 'init', 'hint/foundries/cnx'], function (lang) {
KorAP.hintArray = hintArray;
- // Set current virtual collection
+ // Set current virtual corpus
// KorAP.currentVC = vcExample;
// Parse and show the table
diff --git a/dev/demo/sidebar-login.html b/dev/demo/sidebar-login.html
index eb2f429..2b127f1 100644
--- a/dev/demo/sidebar-login.html
+++ b/dev/demo/sidebar-login.html
@@ -54,12 +54,12 @@
<!-- <i class="fa fa-arrow-circle-down show-hint" onclick="hint.popUp()"></i> -->
</div>
- <!-- Search in the following virtual collection -->
+ <!-- Search in the following virtual corpus -->
<div id="vc-view"></div>
in
<input id="show" name="show" type="hidden" />
- <input id="collection-name" name="collection-name" type="hidden">
- <input id="collection" name="collection" type="text" value="">
+ <!--<input id="collection-name" name="collection-name" type="hidden"> -->
+ <input id="cq" name="cq" type="text" value="">
with <span class="menu select">
<select name="ql" id="ql-field">
<option value="poliqarp">Poliqarp</option>
diff --git a/dev/demo/vcdemo.js b/dev/demo/vcdemo.js
index e0b9f16..75c7cf1 100644
--- a/dev/demo/vcdemo.js
+++ b/dev/demo/vcdemo.js
@@ -67,7 +67,7 @@
]
};
-var collections = [
+var corpora = [
{
"statistics":{
"paragraphs":2034752,
@@ -120,7 +120,7 @@
domReady(function() {
- // Create a new virtual collection by passing a based json object and
+ // Create a new virtual corpus by passing a based json object and
// field menu information
KorAP.vc = vcClass.create([
['title', 'string'],
diff --git a/dev/js/spec/tourSpec.js b/dev/js/spec/tourSpec.js
index 18d3b4e..55307b4 100644
--- a/dev/js/spec/tourSpec.js
+++ b/dev/js/spec/tourSpec.js
@@ -14,11 +14,11 @@
"<input autocapitalize='off' autocomplete='off' autocorrect='off' autofocus='autofocus' id='q-field' name='q' placeholder='Finde ...' spellcheck='false' type='search'>" +
"<button type='submit' id='qsubmit' title='Los!'><span>Los!</span></button>" +
"</div>" +
- "<!-- Search in the following virtual collection -->"+
+ "<!-- Search in the following virtual corpus -->"+
"<div id='vc-view'></div>" +
"in" +
"<span id='vc-choose' class='select'><span>allen Korpora</span></span>" +
- "<input id='collection' name='collection' type='text' style='display: none;'>" +
+ "<input id='cq' name='cq' type='text' style='display: none;'>" +
"mit" +
"<span class='select'>" +
"<select id='ql-field' name='ql' style='display: none;'>" +
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index 564b8d6..388a26d 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -1561,7 +1561,7 @@
);
});
- it('should be deserializable from collection 1', function () {
+ it('should be deserializable from collection/corpus 1', function () {
var kq = {
"matches":["..."],
"collection":{
@@ -1624,6 +1624,13 @@
var vc = vcClass.create().fromJson(kq["collection"]);
expect(vc.toQuery()).toEqual('(title = "Der Birnbaum" & pubPlace = "Mannheim" & (subTitle = "Aufzucht und Pflege" | subTitle = "Gedichte")) | pubDate since 2015-03-05');
+
+ kq["corpus"] = kq["collection"]
+ delete kq["collection"]
+
+ vc = vcClass.create().fromJson(kq["corpus"]);
+ expect(vc.toQuery()).toEqual('(title = "Der Birnbaum" & pubPlace = "Mannheim" & (subTitle = "Aufzucht und Pflege" | subTitle = "Gedichte")) | pubDate since 2015-03-05');
+
});
it('should be deserializable from collection 2', function () {
@@ -1692,6 +1699,7 @@
expect(vc.toQuery()).toEqual('availability = /CC-BY.*/ & author = "Goethe"');
});
+
it('shouldn\'t be deserializable from collection with unknown type', function () {
var kq = {
"@type" : "koral:doc",
diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index e536ea2..eae75a8 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -85,7 +85,7 @@
/**
- * Retrieve information about collections
+ * Retrieve information about virtual corpora
*/
KorAP.API.getCollections = function (cb) {
KorAP.API.getJSON(KorAP.URL + '/collection', cb, "CorpusInfo");
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index ec11cf5..6de66d8 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -95,10 +95,10 @@
};
/**
- * Replace Virtual Collection field
+ * Replace Virtual Corpus field
*/
var vcname, vcchoose;
- var input = d.getElementById('collection');
+ var input = d.getElementById('cq');
var vc = KorAP.vc;
@@ -110,9 +110,10 @@
vcname.classList.add('select');
// Load virtual corpus object
- if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
+ // Supports "collection" for legacy reasons
+ if (KorAP.koralQuery !== undefined && (KorAP.koralQuery["collection"] || KorAP.koralQuery["corpus"])) {
try {
- vc.fromJson(KorAP.koralQuery["collection"]);
+ vc.fromJson(KorAP.koralQuery["collection"] || KorAP.koralQuery["corpus"]);
}
catch (e) {
KorAP.log(0,e);
@@ -264,12 +265,12 @@
/*
- * Toggle the Virtual Collection builder
+ * Toggle the Virtual Corpus builder
*/
if (vcname) {
vc.onMinimize = function () {
vcname.classList.remove('active');
- delete show['collection'];
+ delete show['vc'];
};
vc.onOpen = function () {
@@ -279,7 +280,7 @@
if (!view.firstChild)
view.appendChild(this.element());
- show['collection'] = true;
+ show['vc'] = true;
};
var vcclick = function () {
@@ -294,7 +295,7 @@
vcname.onclick = vcclick;
// Click, if the VC should be shown
- if (show['collection']) {
+ if (show['vc']) {
vcclick.apply();
};
};
diff --git a/dev/js/src/loc/de.js b/dev/js/src/loc/de.js
index de0ab80..99d3fa3 100644
--- a/dev/js/src/loc/de.js
+++ b/dev/js/src/loc/de.js
@@ -4,14 +4,7 @@
loc.AND = 'und';
// EMPTY, DELETE
- // Virtual collection:
- /*
- loc.VC_subTitle = 'Untertitel';
- loc.VC_title = 'Titel';
- loc.VC_pubDate = 'Veröffentlichungsdatum';
- loc.VC_pubPlace = 'Veröffentlichungsort';
- */
-
+ // Virtual corpus:
loc.VC_allCorpora = 'allen Korpora';
loc.VC_oneCollection = 'einem virtuellen Korpus';
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index fd67863..5d1ccf0 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -1,6 +1,6 @@
/**
- * Create virtual collections with a visual user interface. This resembles the
- * collection type objects of a KoralQuery "collection" object.
+ * Create virtual corpora with a visual user interface. This resembles the
+ * corpus/collection type objects of a KoralQuery "collection"/"corpus" object.
*
* KoralQuery v0.3 is expected.
*
@@ -115,18 +115,18 @@
};
/**
- * Virtual Collection
+ * Virtual corpus
*/
return {
/**
- * The JSON-LD type of the virtual collection
+ * The JSON-LD type of the virtual corpus
*/
ldType : function() {
return null;
},
- // Initialize virtual collection
+ // Initialize virtual corpus
_init : function(keyList) {
// Inject localized css styles
@@ -164,7 +164,7 @@
},
/**
- * Create a new virtual collection.
+ * Create a new virtual corpus
*/
create : function(keyList) {
var obj = Object.create(this)._init(keyList);
@@ -174,8 +174,8 @@
/**
- * Create and render a new virtual collection based on a KoralQuery
- * collection document
+ * Create and render a new virtual corpus based on a KoralQuery
+ * corpus document
*/
fromJson : function(json) {
if (json !== undefined) {
@@ -255,7 +255,7 @@
},
/**
- * Get or set the root object of the virtual collection.
+ * Get or set the root object of the virtual corpus
*/
root : function(obj) {
if (arguments.length === 1) {
diff --git a/dev/js/src/vc/choosemenu.js b/dev/js/src/vc/choosemenu.js
index 84f6ae9..90660b7 100644
--- a/dev/js/src/vc/choosemenu.js
+++ b/dev/js/src/vc/choosemenu.js
@@ -1,5 +1,5 @@
/**
- * Menu showing all predefined virtual collections.
+ * Menu showing all predefined virtual corpora.
* THIS IS EXPERIMENTAL AND MAY BE REMOVED!
*/
define(['vc/menu', 'api'], function (menuClass, itemClass) {
diff --git a/dev/js/src/vc/stringval.js b/dev/js/src/vc/stringval.js
index 77c6d90..8b05787 100644
--- a/dev/js/src/vc/stringval.js
+++ b/dev/js/src/vc/stringval.js
@@ -1,5 +1,5 @@
/**
- * Add string values to the virtual collection
+ * Add string values to the virtual corpus
*/
define(['util'], {
diff --git a/dev/js/src/vc/unspecified.js b/dev/js/src/vc/unspecified.js
index 416ad85..4ffe507 100644
--- a/dev/js/src/vc/unspecified.js
+++ b/dev/js/src/vc/unspecified.js
@@ -1,5 +1,5 @@
/**
- * An unspecified criterion in a virtual collection.
+ * An unspecified criterion in a virtual corpus.
* Inherits everything from jsonld
*/
define([
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index 04f9b0d..1472cd8 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -43,6 +43,11 @@
$cutoff = 1;
};
+ # Deal with legacy collection
+ if ($v->param('collection')) {
+ $c->param(cq => $v->param('collection'));
+ };
+
# No query (Check ignoring validation)
unless ($c->param('q')) {
return $c->render($c->loc('Template_intro', 'intro'));
@@ -70,7 +75,8 @@
$query{count} = $v->param('count') // $c->items_per_page;
- $query{cq} = $v->param('cq') // $v->param('collection');
+ $query{cq} = $v->param('cq');
+
$query{cutoff} = $v->param('cutoff');
# Before: 'base/s:p'/'paragraph'
$query{context} = $v->param('context') // '40-t,40-t';
diff --git a/t/fixtures/response_query_baum_o0_c25_cq.json b/t/fixtures/response_query_baum_o0_c25_cq.json
new file mode 100644
index 0000000..47ba228
--- /dev/null
+++ b/t/fixtures/response_query_baum_o0_c25_cq.json
@@ -0,0 +1,83 @@
+{
+ "status" : 200,
+ "json" : {
+ "@context" : "http://korap.ids-mannheim.de/ns/KoralQuery/v0.3/context.jsonld",
+ "meta" : {
+ "count" : 25,
+ "startIndex" : 0,
+ "authorized" : null,
+ "timeout" : 120000,
+ "context" : {
+ "left" : ["token",40],
+ "right" : ["token",40]
+ },
+ "fields" : ["pubDate","subTitle","author","pubPlace","title","textSigle","UID","ID","layerInfos","corpusSigle","docSigle","corpusID","textClass"],
+ "version" : "0.55.7",
+ "benchmark" : "0.120577834 s",
+ "totalResults" : 51,
+ "serialQuery" : "tokens:s:Baum",
+ "itemsPerPage" : 25
+ },
+ "query" : {
+ "@type" : "koral:token",
+ "wrap" : {
+ "@type" : "koral:term",
+ "layer" : "orth",
+ "key" : "Baum",
+ "match" : "match:eq",
+ "foundry" : "opennlp",
+ "rewrites" : [
+ {
+ "@type" : "koral:rewrite",
+ "src" : "Kustvakt",
+ "operation" : "operation:injection",
+ "scope" : "foundry"
+ }
+ ]
+ }
+ },
+ "collection":{
+ "@type":"koral:doc",
+ "match":"match:eq",
+ "type":"type:regex",
+ "value":"CC-BY.*",
+ "key":"availability"
+ },
+ "matches" : [
+ {
+ "field" : "tokens",
+ "pubPlace" : "München",
+ "textSigle" : "GOE/AGI/00000",
+ "docSigle" : "GOE/AGI",
+ "corpusSigle" : "GOE",
+ "title" : "Italienische Reise",
+ "subTitle" : "Auch ich in Arkadien!",
+ "author" : "Goethe, Johann Wolfgang von",
+ "layerInfos" : "base/s=spans corenlp/c=spans corenlp/p=tokens corenlp/s=spans dereko/s=spans malt/d=rels mdp/d=rels opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans",
+ "startMore" : true,
+ "endMore" : true,
+ "snippet" : "<span class=\"context-left\"><span class=\"more\"></span>sie etwas bedeuten zu wollen und machte mit der Oberlippe eine fatale Miene. ich sprach sehr viel mit ihr durch, sie war überall zu Hause und merkte gut auf die Gegenstände. so fragte sie mich einmal, was das für ein </span><span class=\"match\"><mark>Baum</mark></span><span class=\"context-right\"> sei. es war ein schöner großer Ahorn, der erste, der mir auf der ganzen Reise zu Gesichte kam. den hatte sie doch gleich bemerkt und freute sich, da mehrere nach und nach erschienen, daß sie auch diesen Baum unterscheiden könne<span class=\"more\"></span></span>",
+ "matchID" : "match-GOE/AGI/00000-p2030-2031",
+ "UID" : 0,
+ "pubDate" : "1982"
+ },
+ {
+ "field" : "tokens",
+ "pubPlace" : "München",
+ "textSigle" : "GOE/AGI/00001",
+ "docSigle" : "GOE/AGI",
+ "corpusSigle" : "GOE",
+ "title" : "Italienische Reise",
+ "subTitle" : "Auch ich in Arkadien!",
+ "author" : "Goethe, Johann Wolfgang von",
+ "layerInfos" : "base/s=spans corenlp/c=spans corenlp/p=tokens corenlp/s=spans dereko/s=spans malt/d=rels mdp/d=rels opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans",
+ "startMore" : true,
+ "endMore" : true,
+ "snippet" : "<span class=\"context-left\"><span class=\"more\"></span>für ein Baum sei. es war ein schöner großer Ahorn, der erste, der mir auf der ganzen Reise zu Gesichte kam. den hatte sie doch gleich bemerkt und freute sich, da mehrere nach und nach erschienen, daß sie auch diesen </span><span class=\"match\"><mark>Baum</mark></span><span class=\"context-right\"> unterscheiden könne. sie gehe, sagte sie, nach Bozen auf die Messe, wo ich doch wahrscheinlich auch hinzöge. wenn sie mich dort anträfe, müsse ich ihr einen Jahrmarkt kaufen, welches ich ihr denn auch versprach. dort wollte sie auch ihre neue<span class=\"more\"></span></span>",
+ "matchID" : "match-GOE/AGI/00000-p2068-2069",
+ "UID" : 0,
+ "pubDate" : "1982"
+ }
+ ]
+ }
+}
diff --git a/t/query.t b/t/query.t
index 81c4ac8..4532167 100644
--- a/t/query.t
+++ b/t/query.t
@@ -220,9 +220,24 @@
$t->get_ok('/?q=timeout')
->status_is(200)
# ->text_like('noscript div.notify-warning', qr!Response time exceeded!)
+ ->element_exists("input#cq")
+ ->element_exists_not("input#cq[value]")
->text_is('#total-results', '> 4,274,841');
;
+# Query with collection
+$t->get_ok('/?q=baum&collection=availability+%3D+%2FCC-BY.*%2F')
+ ->status_is(200)
+ ->element_exists("input#cq[value='availability = /CC-BY.*/']")
+ ->text_is('#error','')
+ ;
+
+# Query with corpus query
+$t->get_ok('/?q=baum&cq=availability+%3D+%2FCC-BY.*%2F')
+ ->status_is(200)
+ ->element_exists("input#cq[value='availability = /CC-BY.*/']")
+ ->text_is('#error','')
+ ;
done_testing;
__END__
diff --git a/t/server/mock.pl b/t/server/mock.pl
index 2c7f43b..2b998ab 100644
--- a/t/server/mock.pl
+++ b/t/server/mock.pl
@@ -77,6 +77,7 @@
$v->optional('q');
$v->optional('page');
$v->optional('ql');
+ $v->optional('cq');
$v->optional('count');
$v->optional('context');
$v->optional('offset');
@@ -102,6 +103,7 @@
push @slug_base, 'o' . $v->param('offset') if defined $v->param('offset');
push @slug_base, 'c' . $v->param('count') if defined $v->param('count');
push @slug_base, 'co' . $v->param('cutoff') if defined $v->param('cutoff');
+ push @slug_base, 'cq' if defined $v->param('cq');
# Get response based on query parameter
my $response = $c->load_response('query_' . slugify(join('_', @slug_base)));
diff --git a/templates/doc/api.html.ep b/templates/doc/api.html.ep
index 3b8842b..7fa7a11 100644
--- a/templates/doc/api.html.ep
+++ b/templates/doc/api.html.ep
@@ -6,7 +6,7 @@
<dl>
<dt><%= doc_link_to('Search API', 'api', 'search') %></dt>
- <dd>Initiate queries, create virtual collections.</dd>
+ <dd>Initiate queries, create virtual corpora.</dd>
<dt><%= doc_link_to('Match API', 'api', 'match') %></dt>
<dd>Retrieve further information like annotations for a certain match.</dd>
diff --git a/templates/partial/header.html.ep b/templates/partial/header.html.ep
index 8992b0f..8638d7b 100644
--- a/templates/partial/header.html.ep
+++ b/templates/partial/header.html.ep
@@ -9,11 +9,11 @@
<button type="submit" id="qsubmit" title="<%= loc 'go' %>"><span><%= loc 'go' %></span></button>
</div>
- <!-- Search in the following virtual collection -->
+ <!-- Search in the following virtual corpus -->
<div id="vc-view"></div>
<%= loc 'in' %>
%# TODO: Create 'align' parameter
- %= text_field 'collection', id => 'collection'
+ %= text_field 'cq', id => 'cq'
<%= loc 'with' %>
<span class="select">