Release preparation, documentation, fixing vc bugs
diff --git a/dev/js/src/match/info.js b/dev/js/src/match/info.js
index c47f5ae..b75e713 100644
--- a/dev/js/src/match/info.js
+++ b/dev/js/src/match/info.js
@@ -12,7 +12,7 @@
matchTreeClass,
matchTreeMenuClass) {
- // TODO: Make this async
+ // Override
KorAP.API.getMatchInfo = KorAP.API.getMatchInfo || function () {
KorAP.log(0, 'KorAP.API.getMatchInfo() not implemented')
return {};
@@ -20,10 +20,11 @@
var loc = KorAP.Locale;
- /**
- * Create new object
- */
return {
+
+ /**
+ * Create new match object
+ */
create : function (match) {
return Object.create(this)._init(match);
},
@@ -44,6 +45,11 @@
return this._match;
},
+
+ /**
+ * Open the information view,
+ * if closed, otherwise close.
+ */
toggle : function () {
if (this.opened == true) {
this._match.element().children[0].removeChild(
@@ -64,7 +70,8 @@
/**
- * Retrieve and parse snippet for table representation
+ * Retrieve and parse snippet for table
+ * representation
*/
getTable : function (tokens, cb) {
var focus = [];
diff --git a/dev/js/src/match/infolayer.js b/dev/js/src/match/infolayer.js
index dbd93f9..0812f71 100644
--- a/dev/js/src/match/infolayer.js
+++ b/dev/js/src/match/infolayer.js
@@ -1,16 +1,26 @@
/**
- *
- * Alternatively pass a string as <tt>base/s=span</tt>
- *
- * @param foundry
+ * Object representing information
+ * about a match's layer annotation.
*/
define(function () {
- var _AvailableRE = new RegExp("^([^\/]+?)\/([^=]+?)(?:=(spans|rels|tokens))?$");
+ var _AvailableRE =
+ new RegExp("^([^\/]+?)\/([^=]+?)(?:=(spans|rels|tokens))?$");
return {
+ /**
+ * Create new match information
+ * object for one layer.
+ *
+ * Alternatively pass a string as
+ * <tt>base/s=span</tt>
+ *
+ * @param foundry
+ */
create : function (foundry, layer, type) {
return Object.create(this)._init(foundry, layer, type);
},
+
+ // Initialize Layer
_init : function (foundry, layer, type) {
if (foundry === undefined)
throw new Error("Missing parameters");
diff --git a/dev/js/src/match/table.js b/dev/js/src/match/table.js
index 7eba8a0..1a167d2 100644
--- a/dev/js/src/match/table.js
+++ b/dev/js/src/match/table.js
@@ -1,10 +1,21 @@
+/**
+ * Table representation of morphological
+ * annotations of a match.
+ */
define(function () {
var _TermRE = new RegExp("^(?:([^\/]+?)\/)?([^:]+?):(.+?)$");
return {
+
+ /**
+ * Create new table view for a match
+ * based on a snippet string.
+ */
create : function (snippet) {
return Object.create(this)._init(snippet);
},
+
+ // Initialize table based on snippet
_init : function (snippet) {
// Create html for traversal
var html = document.createElement("div");
@@ -23,27 +34,49 @@
return this;
},
+
+ /**
+ * Length of the table (columns),
+ * aka the number of tokens
+ * in the snippet.
+ */
length : function () {
return this._pos;
},
+ /**
+ * Get the token in the snippet
+ * At a given position.
+ *
+ * @param pos
+ */
getToken : function (pos) {
if (pos === undefined)
return this._token;
return this._token[pos];
},
-
+
+ /**
+ * Get the annotation of a token
+ * in the snippet based on the position,
+ * the foundry, and the layer.
+ *
+ * @param pos
+ * @param foundry
+ * @param layer
+ */
getValue : function (pos, foundry, layer) {
return this._info[pos][foundry + '/' + layer]
},
- getLayerPerFoundry : function (foundry) {
- return this._foundry[foundry]
- },
-
- getFoundryPerLayer : function (layer) {
- return this._layer[layer];
- },
+ /*
+ getLayerPerFoundry : function (foundry) {
+ return this._foundry[foundry]
+ },
+ getFoundryPerLayer : function (layer) {
+ return this._layer[layer];
+ },
+ */
// Parse the snippet
_parse : function (children) {
diff --git a/dev/js/src/match/tree.js b/dev/js/src/match/tree.js
index b379b37..9722f94 100644
--- a/dev/js/src/match/tree.js
+++ b/dev/js/src/match/tree.js
@@ -1,5 +1,6 @@
/**
- * Visualize span annotations as a tree using Dagre.
+ * Visualize span annotations as a tree
+ * using Dagre.
*/
define(['lib/dagre'], function (dagre) {
"use strict";
@@ -7,6 +8,9 @@
var svgXmlns = "http://www.w3.org/2000/svg";
var _TermRE = new RegExp("^(?:([^\/]+?)\/)?([^:]+?):(.+?)$");
+ // Node size
+ var WIDTH = 55, HEIGHT = 20;
+
// Create path for node connections
function _line (src, target) {
var x1 = src.x,
@@ -22,24 +26,18 @@
};
return {
+
+ /**
+ * Create new tree visualization based
+ * on a match snippet.
+ */
create : function (snippet) {
- return Object.create(this)._init(snippet);
+ return Object.create(this).
+ _init(snippet);
},
- nodes : function () {
- return this._next;
- },
- _addNode : function (id, obj) {
- obj["width"] = 55;
- obj["height"] = 20;
- this._graph.setNode(id, obj)
- },
-
- _addEdge : function (src, target) {
- this._graph.setEdge(src, target);
- },
-
+ // Initialize the tree based on a snippet.
_init : function (snippet) {
this._next = new Number(0);
@@ -76,6 +74,25 @@
return this;
},
+ /**
+ * The number of nodes in the tree.
+ */
+ nodes : function () {
+ return this._next;
+ },
+
+ // Add new node to graph
+ _addNode : function (id, obj) {
+ obj["width"] = WIDTH;
+ obj["height"] = HEIGHT;
+ this._graph.setNode(id, obj)
+ },
+
+ // Add new edge to graph
+ _addEdge : function (src, target) {
+ this._graph.setEdge(src, target);
+ },
+
// Remove foundry and layer for labels
_clean : function (title) {
return title.replace(_TermRE, "$3");
@@ -148,7 +165,9 @@
};
},
- // Get element
+ /**
+ * Get the dom element of the tree view.
+ */
element : function () {
if (this._element !== undefined)
return this._element;
@@ -183,26 +202,25 @@
// Add node box
var rect = group.appendChild(document.createElementNS(svgXmlns, 'rect'));
- rect.setAttributeNS(null, 'x', v.x - v.width / 2);
- rect.setAttributeNS(null, 'y', v.y - v.height / 2);
- rect.setAttributeNS(null, 'rx', 5);
- rect.setAttributeNS(null, 'ry', 5);
- rect.setAttributeNS(null, 'width', v.width);
- rect.setAttributeNS(null, 'height', v.height);
+ rect.setAttribute('x', v.x - v.width / 2);
+ rect.setAttribute('y', v.y - v.height / 2);
+ rect.setAttribute('rx', 5);
+ rect.setAttribute('ry', 5);
+ rect.setAttribute('width', v.width);
+ rect.setAttribute('height', v.height);
if (v.class === 'root' && v.label === undefined) {
- rect.setAttributeNS(null, 'width', v.height);
- rect.setAttributeNS(null, 'x', v.x - v.height / 2);
- rect.setAttributeNS(null, 'class', 'empty');
+ rect.setAttribute('width', v.height);
+ rect.setAttribute('x', v.x - v.height / 2);
+ rect.setAttribute('class', 'empty');
};
// Add label
if (v.label !== undefined) {
var text = group.appendChild(document.createElementNS(svgXmlns, 'text'));
- text.setAttributeNS(null, 'x', v.x - v.width / 2);
- text.setAttributeNS(null, 'y', v.y - v.height / 2);
- text.setAttributeNS(
- null,
+ text.setAttribute('x', v.x - v.width / 2);
+ text.setAttribute('y', v.y - v.height / 2);
+ text.setAttribute(
'transform',
'translate(' + v.width/2 + ',' + ((v.height / 2) + 5) + ')'
);
diff --git a/dev/js/src/match/treeitem.js b/dev/js/src/match/treeitem.js
index f096861..9a4b952 100644
--- a/dev/js/src/match/treeitem.js
+++ b/dev/js/src/match/treeitem.js
@@ -4,10 +4,20 @@
*/
return {
+
+ /**
+ * Create new menu item
+ * for tree views.
+ */
create : function (params) {
return Object.create(itemClass)
.upgradeTo(this)._init(params);
},
+
+ /**
+ * Get or set the content of the
+ * menu item.
+ */
content : function (content) {
if (arguments.length === 1) {
this._content = content;
@@ -15,17 +25,23 @@
return this._content;
},
- // The foundry attribute
+ /**
+ * The foundry attribute of the menu item.
+ */
foundry : function () {
return this._foundry;
},
- // The layer attribute
+ /**
+ * The layer attribute of the menu item.
+ */
layer : function () {
return this._layer;
},
- // enter or click
+ /**
+ * Override click action of the menu item.
+ */
onclick : function (e) {
var menu = this.menu();
menu.hide();
@@ -33,7 +49,8 @@
if (menu.info() !== undefined)
menu.info().addTree(this._foundry, this._layer);
},
-
+
+ // Initialize tree menu item.
_init : function (params) {
if (params[0] === undefined)
throw new Error("Missing parameters");
diff --git a/dev/js/src/match/treemenu.js b/dev/js/src/match/treemenu.js
index 23341a4..16f6306 100644
--- a/dev/js/src/match/treemenu.js
+++ b/dev/js/src/match/treemenu.js
@@ -5,6 +5,16 @@
"use strict";
return {
+
+ /**
+ * Create new menu object.
+ * Pass the match information object
+ * and the item parameters.
+ *
+ * @param info The match info object
+ * @param params The match menu items
+ * as an array of arrays.
+ */
create : function (info, params) {
var obj = Object.create(menuClass)
.upgradeTo(this)
@@ -19,6 +29,10 @@
return obj;
},
+
+ /**
+ * The match information object of the menu.
+ */
info :function () {
return this._info;
}