Introduce corpusByMatch assistant object
Change-Id: Ia23b644e545f9e720de89704be1dc83a79957193
diff --git a/dev/js/src/match/corpusByMatch.js b/dev/js/src/match/corpusByMatch.js
new file mode 100644
index 0000000..1c0bead
--- /dev/null
+++ b/dev/js/src/match/corpusByMatch.js
@@ -0,0 +1,37 @@
+define(['vc/fragment', 'util'], function (vcFragmentClass) {
+ "use strict";
+
+ return {
+ /**
+ * Constructor
+ */
+ create : function (meta) {
+ return Object.create(this)._init(meta);
+ },
+
+ // Initialize corpusByMatch
+ _init : function (meta) {
+ if (meta === undefined) {
+ throw new Error('Missing parameters');
+ }
+ else if (!(meta instanceof Node)) {
+ throw new Error("Requires element");
+ };
+
+ // Collect the meta constraints
+ this._vc = {};
+
+ // Remember the meta table
+ this._meta = meta;
+
+ this._fragment = vcFragmentClass.create();
+
+ return this;
+ },
+
+ // Stringify annotation
+ toString : function () {
+ return '';
+ }
+ };
+});
diff --git a/dev/js/src/match/meta.js b/dev/js/src/match/meta.js
index 8667953..d4b2d7f 100644
--- a/dev/js/src/match/meta.js
+++ b/dev/js/src/match/meta.js
@@ -1,4 +1,4 @@
-define(['util'], function () {
+define(['match/corpusByMatch','util'], function (cbmClass) {
// Localization values
const loc = KorAP.Locale;
@@ -55,7 +55,7 @@
var value = fields[i].value;
metaInfo[fields[i].key] = value;
};
-
+
// console.log(fields);
// TODO: Meta fields should be separated
@@ -63,13 +63,15 @@
for (var i in keys.sort()) {
var k = keys[i];
+
+ // Ignore internal IDs
if (k !== "UID" &&
k !== "corpusID" &&
k !== "docID" &&
k !== "textID" &&
/*
- k !== "corpusSigle" &&
- k !== "docSigle" &&
+ k !== "corpusSigle" &&
+ k !== "docSigle" &&
*/
k !== "layerInfos") {
@@ -83,18 +85,20 @@
metaDD = metaL.addE('dd');
if(metaDescr instanceof Array){
- metaDD.classList.add("metakeyvalues");
- for(i = 0; i < metaDescr.length; i++){
- metaDD.addE('div').addT(metaDescr[i]);
- }
+ metaDD.classList.add("metakeyvalues");
+ for(i = 0; i < metaDescr.length; i++){
+ metaDD.addE('div').addT(metaDescr[i]);
+ }
}
else{
- metaDD.addT(metaInfo[k]);
+ metaDD.addT(metaInfo[k]);
}
-
+
metaDL.appendChild(metaL);
};
};
+
+ this._corpusByMatch = cbmClass.create(this._element);
return this._element;
}
};