Merge "Cleanup match specification to leave no document fragments behind"
diff --git a/dev/js/spec/matchSpec.js b/dev/js/spec/matchSpec.js
index b96734d..b72cd9a 100644
--- a/dev/js/spec/matchSpec.js
+++ b/dev/js/spec/matchSpec.js
@@ -1,220 +1,253 @@
// Regarding async:
// http://stackoverflow.com/questions/16423156/getting-requirejs-to-work-with-jasmine
+define(['match',
+ 'view/match/tokentable',
+ 'view/match/relations',
+ 'panel/match',
+ 'match/meta',
+ 'match/infolayer',
+ 'match/treeitem',
+ 'match/treearc',
+ 'buttongroup/menu',
+ 'hint/foundries/cnx',
+ 'hint/foundries/mate'], function (
+ matchClass,
+ tableClass,
+ relClass,
+ panelClass,
+ metaClass,
+ infoClass,
+ matchTreeItemClass,
+ matchRelClass,
+ matchTreeMenuClass) {
-var available = [
- 'base/s=spans',
- 'corenlp/c=spans',
- 'corenlp/ne=tokens',
- 'corenlp/p=tokens',
- 'corenlp/s=spans',
- 'glemm/l=tokens',
- 'mate/l=tokens',
- 'mate/m=tokens',
- 'mate/p=tokens',
- 'opennlp/p=tokens',
- 'opennlp/s=spans',
- 'tt/l=tokens',
- 'tt/p=tokens',
- 'tt/s=spans'
-];
+ var available = [
+ 'base/s=spans',
+ 'corenlp/c=spans',
+ 'corenlp/ne=tokens',
+ 'corenlp/p=tokens',
+ 'corenlp/s=spans',
+ 'glemm/l=tokens',
+ 'mate/l=tokens',
+ 'mate/m=tokens',
+ 'mate/p=tokens',
+ 'opennlp/p=tokens',
+ 'opennlp/s=spans',
+ 'tt/l=tokens',
+ 'tt/p=tokens',
+ 'tt/s=spans'
+ ];
-var match = {
- 'corpusID' : 'WPD',
- 'docID' : 'UUU',
- 'textID' : '01912',
- 'matchID' : 'p121-122',
- 'textSigle' : 'WPD/UUU/01912',
- 'available' : available
-};
-
-
-var fields = [
- {
- "@type": "koral:field",
- "key": "author",
- "type": "type:text",
- "value": "Sprachpfleger, u.a."
- },
- {
- "@type": "koral:field",
- "key": "textClass",
- "type": "type:keywords",
- "value": ["kultur", "film"]
- },
- {
- "@type":"koral:field",
- "key":"foundries",
- "type":"type:string",
- "value":[
- "corenlp",
- "corenlp\/constituency",
- "corenlp\/morpho",
- "corenlp\/sentences",
- "dereko",
- "dereko\/structure",
- "dereko\/structure\/base-sentences-paragraphs-pagebreaks",
- "opennlp",
- "opennlp\/morpho",
- "opennlp\/sentences"
- ]
- }
-];
-
-
-var snippet = "<span title=\"cnx/l:meist\">" +
- " <span title=\"cnx/p:ADV\">" +
- " <span title=\"cnx/syn:@PREMOD\">" +
- " <span title=\"mate/l:meist\">" +
- " <span title=\"mate/l:meist\">" +
- " <span title=\"mate/p:ADV\">" +
- " <span title=\"opennlp/p:ADV\">meist</span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- "</span>" +
- "<span title=\"cnx/l:deutlich\">" +
- " <span title=\"cnx/p:A\">" +
- " <span title=\"cnx/syn:@PREMOD\">" +
- " <span title=\"mate/l:deutlich\">" +
- " <span title=\"mate/m:degree:pos\">" +
- " <span title=\"mate/p:ADJD\">" +
- " <span title=\"opennlp/p:ADJD\">deutlich</span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- "</span>" +
- "<span title=\"cnx/l:fähig\">" +
- " <span title=\"cnx/l:leistung\">" +
- " <span title=\"cnx/p:A\">" +
- " <span title=\"cnx/p:ADJA\">" +
- " <span title=\"cnx/syn:@NH\">" +
- " <span title=\"mate/l:leistungsfähig\">" +
- " <span title=\"mate/m:degree:comp\">" +
- " <span title=\"mate/p:ADJD\">" +
- " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- "</span>";
-
-var treeSnippet =
- "<span class=\"context-left\"></span>" +
- "<span class=\"match\">" +
- " <span title=\"xip/c:MC\">" +
- " <span title=\"xip/c:TOP\">" +
- " <span title=\"xip/c:PP\">" +
- " <span title=\"xip/c:PREP\">Mit</span>" +
- " <span title=\"xip/c:NP\">" +
- " <span title=\"xip/c:DET\">dieser</span>" +
- " <span title=\"xip/c:NPA\">" +
- " <span title=\"xip/c:NOUN\">Methode</span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " <span title=\"xip/c:VERB\">ist</span>" +
- " <mark>" +
- " <span title=\"xip/c:NP\">" +
- " <span title=\"xip/c:PRON\">es</span>" +
- " </span>" +
- " <span title=\"xip/c:AP\">" +
- " <span title=\"xip/c:ADV\">nun</span>" +
- " <span title=\"xip/c:ADJ\">möglich</span>" +
- " </span>" +
- " </mark>" +
- " <span title=\"xip/c:ADV\">z. B.</span>" +
- " <span title=\"xip/c:NPA\">" +
- " <span title=\"xip/c:NP\">" +
- " <span title=\"xip/c:NOUN\">Voice</span>" +
- " </span>" +
- " </span>" + "(" +
- " <span title=\"xip/c:INS\">" +
- " <span title=\"xip/c:NPA\">" +
- " <span title=\"xip/c:NP\">" +
- " <span title=\"xip/c:NOUN\">Sprache</span>" +
- " </span>" +
- " </span>" +
- " </span>" + ")" +
- " <span title=\"xip/c:VERB\">bevorzugt</span>" +
- " <span title=\"xip/c:PP\">" +
- " <span title=\"xip/c:PREP\">in</span>" +
- " <span title=\"xip/c:NP\">" +
- " <span title=\"xip/c:PRON\">der</span>" +
- " </span>" +
- " <span title=\"xip/c:NPA\">" +
- " <span title=\"xip/c:NP\">" +
- " <span title=\"xip/c:NOUN\">Bridge</span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " <span title=\"xip/c:INFC\">" +
- " <span title=\"xip/c:INS\">" +
- " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- " </span>" +
- "</span>" +
- "<span class=\"context-right\"></span>";
-
-
-function matchElementFactory () {
- var me = document.createElement('li');
-
- me.setAttribute(
- 'data-available-info',
- 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
- ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
- ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
- ' tt/p=tokens tt/s=spans');
-
- me.setAttribute('data-corpus-id', 'WPD');
- me.setAttribute('data-doc-id', 'FFF');
- me.setAttribute('data-text-id', '01460');
- me.setAttribute('data-text-sigle', 'WPD/FFF/01460');
- me.setAttribute('data-match-id', 'p119-120');
- me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
- return me;
-};
-
-function matchElementReal () {
- var me = document.createElement('em');
- me.innerHTML =
- '<li data-match-id="p85183-85184"' +
- ' data-text-sigle="GOE/AGI/00000"' +
- ' data-available-info="base/s=spans corenlp/c=spans corenlp/p=tokens corenlp/s=spans dereko/s=spans malt/d=rels opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans"' +
- ' data-info="{"UID":0,"author":"Goethe, Johann Wolfgang von","corpusID":null,"corpusSigle":"GOE","docID":null,"docSigle":"GOE\/AGI","layerInfos":"base\/s=spans corenlp\/c=spans corenlp\/p=tokens corenlp\/s=spans dereko\/s=spans malt\/d=rels opennlp\/p=tokens opennlp\/s=spans tt\/l=tokens tt\/p=tokens tt\/s=spans","matchID":"match-GOE\/AGI\/00000-p85183-85184","pubDate":"1982","pubPlace":"München","subTitle":"Auch ich in Arkadien!","textID":null,"textSigle":"GOE\/AGI\/00000","title":"Italienische Reise"}"' +
- ' id="GOE/AGI/00000#p85183-85184">' +
- '<div>' +
- '<div class="flag"></div>' +
- '<div class="snippet startMore endMore"><span class="context-left"><span class="more"></span>keine großen Flächen, aber sanft gegeneinander laufende Berg- und Hügelrücken, durchgängig mit Weizen und Gerste bestellt, die eine ununterbrochene Masse von Fruchtbarkeit dem Auge darbieten. der diesen Pflanzen geeignete Boden wird so genutzt und so geschont, daß man nirgends einen </span><span class="match"><mark>Baum</mark></span><span class="context-right"> sieht, ja, alle die kleinen Ortschaften und Wohnungen liegen auf Rücken der Hügel, wo eine hinstreichende Reihe Kalkfelsen den Boden ohnehin unbrauchbar macht. dort wohnen die Weiber das ganze Jahr, mit Spinnen und Weben beschäftigt, die Männer hingegen bringen zur<span class="more"></span></span></div>' +
- '</div>' +
- '<p class="ref"><strong>Italienische Reise</strong> von Goethe, Johann Wolfgang von (<time datetime="1982">1982</time>) <span class="sigle">[GOE/AGI/00000]</span> </p>' +
- '</li>';
- return me.firstChild;
-};
-
-
-define(['match', 'hint/foundries/cnx', 'hint/foundries/mate'], function () {
-
- // Override getMatchInfo API call
- KorAP.API.getMatchInfo = function (x, param, cb) {
- if (param['spans'] === undefined || param['spans'] === false)
- cb({ "snippet": snippet });
- else
- cb({ "snippet": treeSnippet });
+ var match = {
+ 'corpusID' : 'WPD',
+ 'docID' : 'UUU',
+ 'textID' : '01912',
+ 'matchID' : 'p121-122',
+ 'textSigle' : 'WPD/UUU/01912',
+ 'available' : available
};
+
+
+ var fields = [
+ {
+ "@type": "koral:field",
+ "key": "author",
+ "type": "type:text",
+ "value": "Sprachpfleger, u.a."
+ },
+ {
+ "@type": "koral:field",
+ "key": "textClass",
+ "type": "type:keywords",
+ "value": ["kultur", "film"]
+ },
+ {
+ "@type":"koral:field",
+ "key":"foundries",
+ "type":"type:string",
+ "value":[
+ "corenlp",
+ "corenlp\/constituency",
+ "corenlp\/morpho",
+ "corenlp\/sentences",
+ "dereko",
+ "dereko\/structure",
+ "dereko\/structure\/base-sentences-paragraphs-pagebreaks",
+ "opennlp",
+ "opennlp\/morpho",
+ "opennlp\/sentences"
+ ]
+ }
+ ];
+
+
+ var snippet = "<span title=\"cnx/l:meist\">" +
+ " <span title=\"cnx/p:ADV\">" +
+ " <span title=\"cnx/syn:@PREMOD\">" +
+ " <span title=\"mate/l:meist\">" +
+ " <span title=\"mate/l:meist\">" +
+ " <span title=\"mate/p:ADV\">" +
+ " <span title=\"opennlp/p:ADV\">meist</span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ "</span>" +
+ "<span title=\"cnx/l:deutlich\">" +
+ " <span title=\"cnx/p:A\">" +
+ " <span title=\"cnx/syn:@PREMOD\">" +
+ " <span title=\"mate/l:deutlich\">" +
+ " <span title=\"mate/m:degree:pos\">" +
+ " <span title=\"mate/p:ADJD\">" +
+ " <span title=\"opennlp/p:ADJD\">deutlich</span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ "</span>" +
+ "<span title=\"cnx/l:fähig\">" +
+ " <span title=\"cnx/l:leistung\">" +
+ " <span title=\"cnx/p:A\">" +
+ " <span title=\"cnx/p:ADJA\">" +
+ " <span title=\"cnx/syn:@NH\">" +
+ " <span title=\"mate/l:leistungsfähig\">" +
+ " <span title=\"mate/m:degree:comp\">" +
+ " <span title=\"mate/p:ADJD\">" +
+ " <span title=\"opennlp/p:ADJD\">leistungsfähiger</span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ "</span>";
+
+ var treeSnippet =
+ "<span class=\"context-left\"></span>" +
+ "<span class=\"match\">" +
+ " <span title=\"xip/c:MC\">" +
+ " <span title=\"xip/c:TOP\">" +
+ " <span title=\"xip/c:PP\">" +
+ " <span title=\"xip/c:PREP\">Mit</span>" +
+ " <span title=\"xip/c:NP\">" +
+ " <span title=\"xip/c:DET\">dieser</span>" +
+ " <span title=\"xip/c:NPA\">" +
+ " <span title=\"xip/c:NOUN\">Methode</span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " <span title=\"xip/c:VERB\">ist</span>" +
+ " <mark>" +
+ " <span title=\"xip/c:NP\">" +
+ " <span title=\"xip/c:PRON\">es</span>" +
+ " </span>" +
+ " <span title=\"xip/c:AP\">" +
+ " <span title=\"xip/c:ADV\">nun</span>" +
+ " <span title=\"xip/c:ADJ\">möglich</span>" +
+ " </span>" +
+ " </mark>" +
+ " <span title=\"xip/c:ADV\">z. B.</span>" +
+ " <span title=\"xip/c:NPA\">" +
+ " <span title=\"xip/c:NP\">" +
+ " <span title=\"xip/c:NOUN\">Voice</span>" +
+ " </span>" +
+ " </span>" + "(" +
+ " <span title=\"xip/c:INS\">" +
+ " <span title=\"xip/c:NPA\">" +
+ " <span title=\"xip/c:NP\">" +
+ " <span title=\"xip/c:NOUN\">Sprache</span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" + ")" +
+ " <span title=\"xip/c:VERB\">bevorzugt</span>" +
+ " <span title=\"xip/c:PP\">" +
+ " <span title=\"xip/c:PREP\">in</span>" +
+ " <span title=\"xip/c:NP\">" +
+ " <span title=\"xip/c:PRON\">der</span>" +
+ " </span>" +
+ " <span title=\"xip/c:NPA\">" +
+ " <span title=\"xip/c:NP\">" +
+ " <span title=\"xip/c:NOUN\">Bridge</span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " <span title=\"xip/c:INFC\">" +
+ " <span title=\"xip/c:INS\">" +
+ " <span title=\"xip/c:VERB\">weiterzugeben</span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ " </span>" +
+ "</span>" +
+ "<span class=\"context-right\"></span>";
+
+
+ function matchElementFactory () {
+ var me = document.createElement('li');
+
+ me.setAttribute(
+ 'data-available-info',
+ 'base/s=spans corenlp/c=spans corenlp/ne=tokens corenlp/p=tokens' +
+ ' corenlp/s=spans glemm/l=tokens mate/l=tokens mate/m=tokens' +
+ ' mate/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens' +
+ ' tt/p=tokens tt/s=spans');
+
+ me.setAttribute('data-corpus-id', 'WPD');
+ me.setAttribute('data-doc-id', 'FFF');
+ me.setAttribute('data-text-id', '01460');
+ me.setAttribute('data-text-sigle', 'WPD/FFF/01460');
+ me.setAttribute('data-match-id', 'p119-120');
+ me.innerHTML = '<div><div class="snippet">check</div></div><p class="ref">me</p>';
+ return me;
+ };
+
+ function matchElementReal () {
+ var me = document.createElement('em');
+ me.innerHTML =
+ '<li data-match-id="p85183-85184"' +
+ ' data-text-sigle="GOE/AGI/00000"' +
+ ' data-available-info="base/s=spans corenlp/c=spans corenlp/p=tokens corenlp/s=spans dereko/s=spans malt/d=rels opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans"' +
+ ' data-info="{"UID":0,"author":"Goethe, Johann Wolfgang von","corpusID":null,"corpusSigle":"GOE","docID":null,"docSigle":"GOE\/AGI","layerInfos":"base\/s=spans corenlp\/c=spans corenlp\/p=tokens corenlp\/s=spans dereko\/s=spans malt\/d=rels opennlp\/p=tokens opennlp\/s=spans tt\/l=tokens tt\/p=tokens tt\/s=spans","matchID":"match-GOE\/AGI\/00000-p85183-85184","pubDate":"1982","pubPlace":"München","subTitle":"Auch ich in Arkadien!","textID":null,"textSigle":"GOE\/AGI\/00000","title":"Italienische Reise"}"' +
+ ' id="GOE/AGI/00000#p85183-85184">' +
+ '<div>' +
+ '<div class="flag"></div>' +
+ '<div class="snippet startMore endMore"><span class="context-left"><span class="more"></span>keine großen Flächen, aber sanft gegeneinander laufende Berg- und Hügelrücken, durchgängig mit Weizen und Gerste bestellt, die eine ununterbrochene Masse von Fruchtbarkeit dem Auge darbieten. der diesen Pflanzen geeignete Boden wird so genutzt und so geschont, daß man nirgends einen </span><span class="match"><mark>Baum</mark></span><span class="context-right"> sieht, ja, alle die kleinen Ortschaften und Wohnungen liegen auf Rücken der Hügel, wo eine hinstreichende Reihe Kalkfelsen den Boden ohnehin unbrauchbar macht. dort wohnen die Weiber das ganze Jahr, mit Spinnen und Weben beschäftigt, die Männer hingegen bringen zur<span class="more"></span></span></div>' +
+ '</div>' +
+ '<p class="ref"><strong>Italienische Reise</strong> von Goethe, Johann Wolfgang von (<time datetime="1982">1982</time>) <span class="sigle">[GOE/AGI/00000]</span> </p>' +
+ '</li>';
+ return me.firstChild;
+ };
+
+ var beforeAllFunc = function () {
+ // Override getMatchInfo API call
+ KorAP.API.getMatchInfo = function (x, param, cb) {
+ if (param['spans'] === undefined || param['spans'] === false)
+ cb({ "snippet": snippet });
+ else
+ cb({ "snippet": treeSnippet });
+ };
+ };
+
+ var afterAllFunc = function () {
+ KorAP.API.getMatchInfo = undefined;
+ // KorAP.annotationHelper = undefined;
+ var body = document.body;
+ for (var i in body.children) {
+ if (body.children[i].nodeType && body.children[i].nodeType === 1) {
+ if (!body.children[i].classList.contains("jasmine_html-reporter")) {
+ body.removeChild(body.children[i]);
+ };
+ };
+ };
+ };
+
describe('KorAP.InfoLayer', function () {
-
- var infoClass = require('match/infolayer');
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
it('should be initializable', function () {
expect(
@@ -241,6 +274,9 @@
describe('KorAP.Match', function () {
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
+
var match = {
'corpusID' : 'WPD',
'docID' : 'UUU',
@@ -250,8 +286,6 @@
'available' : available
};
- var matchClass = require('match');
-
it('should be initializable by Object', function () {
expect(function() {
matchClass.create()
@@ -362,7 +396,7 @@
expect(e["_match"]).not.toBe(undefined);
});
- it('should open tree menu', function () {
+ it('should open tree menu', function () {
var e = matchElementFactory();
var m = matchClass.create(e);
m.open();
@@ -389,10 +423,9 @@
});
describe('KorAP.TableView', function () {
-
- var matchClass = require('match');
- var tableClass = require('view/match/tokentable');
-
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
+
var table;
var matchObj = matchClass.create(match);
@@ -543,10 +576,10 @@
});
describe('KorAP.RelationsView', function () {
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
+
var tree;
- var matchClass = require('match');
- var relClass = require('view/match/relations');
- var panelClass = require('panel/match');
it('should be rendered async 1', function (done) {
var matchObj = matchClass.create(match);
@@ -593,7 +626,9 @@
describe('KorAP.MatchTreeItem', function () {
- var matchTreeItemClass = require('match/treeitem');
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
+
it('should be initializable', function () {
var mi = matchTreeItemClass.create(['cnx/c', 'cnx', 'c'])
expect(mi.element().firstChild.nodeValue).toEqual('cnx/c');
@@ -605,7 +640,8 @@
describe('KorAP.MatchRelation', function () {
- var relClass = require('match/treearc')
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
var relExample = "<span class=\"context-left\"></span>" +
"<span class=\"match\">" +
@@ -628,28 +664,28 @@
it('should be initializable', function () {
- var tree = relClass.create();
+ var tree = matchRelClass.create();
expect(tree.size()).toBe(0);
});
it('should be parse string data', function () {
- var tree = relClass.create(relExample);
+ var tree = matchRelClass.create(relExample);
expect(tree.size()).toBe(4);
});
});
describe('KorAP.MatchTreeMenu', function () {
- var matchTreeMenu = require('buttongroup/menu');
- var matchTreeItem = require('match/treeitem');
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
it('should be initializable', function () {
- var menu = matchTreeMenu.create([
+ var menu = matchTreeMenuClass.create([
['cnx/c', 'cnx', 'c'],
['xip/c', 'xip', 'c']
- ], matchTreeItem);
+ ], matchTreeItemClass);
- expect(menu.itemClass()).toEqual(matchTreeItem);
+ expect(menu.itemClass()).toEqual(matchTreeItemClass);
expect(menu.element().nodeName).toEqual('UL');
expect(menu.element().classList.contains('visible')).toBeFalsy();
expect(menu.limit()).toEqual(6);
@@ -661,9 +697,10 @@
//Test display and sorting of meta information
describe('KorAP.Meta', function(){
-
- var metaClass = require("match/meta");
- var met = metaClass.create(match, fields);
+ beforeAll(beforeAllFunc);
+ afterAll(afterAllFunc);
+
+ var met = metaClass.create(match, fields);
var mel = met.element();
// Meta information should be parsed into a list