Skip to content

Commit 558070b

Browse files
committed
Add a few more pieces to download locally instead of from nlp
1 parent f55cdf8 commit 558070b

File tree

6 files changed

+1009
-4
lines changed

6 files changed

+1009
-4
lines changed

src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java

+4
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,10 @@ public void run(Optional<Pair<String,String>> basicAuth,
17911791
withAuth(server.createContext(uriContext+"/static/fonts/Astloch-Bold.ttf", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/Astloch-Bold.ttf", "font/ttfx")), basicAuth);
17921792
withAuth(server.createContext(uriContext+"/static/fonts/Liberation_Sans-Regular.ttf", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/LiberationSans-Regular.ttf", "font/ttf")), basicAuth);
17931793
withAuth(server.createContext(uriContext+"/static/fonts/PT_Sans-Caption-Web-Regular.ttf", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/PTSansCaption-Regular.ttf", "font/ttf")), basicAuth);
1794+
withAuth(server.createContext(uriContext+"/configuration.js", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/configuration.js", "application/javascript")), basicAuth);
1795+
withAuth(server.createContext(uriContext+"/dispatcher.js", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/dispatcher.js", "application/javascript")), basicAuth);
1796+
withAuth(server.createContext(uriContext+"/util.js", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/util.js", "application/javascript")), basicAuth);
1797+
withAuth(server.createContext(uriContext+"/url_monitor.js", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/url_monitor.js", "application/javascript")), basicAuth);
17941798
withAuth(server.createContext(uriContext+"/visualizer.js", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/visualizer.js", "application/javascript")), basicAuth);
17951799
withAuth(server.createContext(uriContext+"/img/corenlp-title.png", new BytesFileHandler("edu/stanford/nlp/pipeline/demo/corenlp-title.png", "image/png")), basicAuth);
17961800
withAuth(server.createContext(uriContext+"/ping", new PingHandler()), Optional.empty());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; -*-
2+
// vim:set ft=javascript ts=2 sw=2 sts=2 cindent:
3+
var Configuration = (function(window, undefined) {
4+
var abbrevsOn = true;
5+
var textBackgrounds = "striped";
6+
var svgWidth = '100%';
7+
var rapidModeOn = false;
8+
var confirmModeOn = true;
9+
var autorefreshOn = false;
10+
11+
var visual = {
12+
margin: { x: 2, y: 1 },
13+
arcTextMargin: 1,
14+
boxSpacing: 1,
15+
curlyHeight: 4,
16+
arcSpacing: 9, //10;
17+
arcStartHeight: 19, //23; //25;
18+
}
19+
20+
return {
21+
abbrevsOn: abbrevsOn,
22+
textBackgrounds: textBackgrounds,
23+
visual: visual,
24+
svgWidth: svgWidth,
25+
rapidModeOn: rapidModeOn,
26+
confirmModeOn: confirmModeOn,
27+
autorefreshOn: autorefreshOn,
28+
};
29+
})(window);

src/edu/stanford/nlp/pipeline/demo/corenlp-brat.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ head.js(
1212
bratLocation + '/client/lib/jquery.svgdom.min.js',
1313

1414
// brat helper modules
15-
bratLocation + '/client/src/configuration.js',
16-
bratLocation + '/client/src/util.js',
15+
'./configuration.js',
16+
'./util.js',
1717
bratLocation + '/client/src/annotation_log.js',
1818
bratLocation + '/client/lib/webfont.js',
1919

2020
// brat modules
21-
bratLocation + '/client/src/dispatcher.js',
22-
bratLocation + '/client/src/url_monitor.js',
21+
'./dispatcher.js',
22+
'./url_monitor.js',
2323
'./visualizer.js',
2424

2525
// parse viewer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; -*-
2+
// vim:set ft=javascript ts=2 sw=2 sts=2 cindent:
3+
// TODO: does 'arguments.callee.caller' work?
4+
5+
var Dispatcher = (function($, window, undefined) {
6+
var Dispatcher = function() {
7+
var that = this;
8+
9+
var table = {};
10+
11+
var on = function(message, host, handler) {
12+
if (handler === undefined) {
13+
handler = host;
14+
host = arguments.callee.caller;
15+
}
16+
if (table[message] === undefined) {
17+
table[message] = [];
18+
}
19+
table[message].push([host, handler]);
20+
return this;
21+
};
22+
23+
// Notify listeners that we encountered an error in an asynch call
24+
var inAsynchError = false; // To avoid error avalanches
25+
var handleAsynchError = function(e) {
26+
if (!inAsynchError) {
27+
inAsynchError = true;
28+
// TODO: Hook printout into dispatch elsewhere?
29+
console.warn('Handled async error:', e);
30+
that.post('dispatchAsynchError', [e]);
31+
inAsynchError = false;
32+
} else {
33+
console.warn('Dropped asynch error:', e);
34+
}
35+
};
36+
37+
var post = function(asynch, message, args, returnType) {
38+
if (typeof(asynch) !== 'number') {
39+
// no asynch parameter
40+
returnType = args;
41+
args = message;
42+
message = asynch;
43+
asynch = null;
44+
}
45+
if (args === undefined) {
46+
args = [];
47+
}
48+
var results = [];
49+
// DEBUG: if (typeof(message) != "string" || !(message.match(/mouse/) || message == "hideComment")) console.log(message, args);
50+
51+
if (typeof(message) === 'function') {
52+
// someone was lazy and sent a simple function
53+
var host = arguments.callee.caller;
54+
if (asynch !== null) {
55+
result = setTimeout(function() {
56+
try {
57+
message.apply(host, args);
58+
} catch(e) {
59+
that.handleAsynchError(e);
60+
}
61+
}, asynch);
62+
} else {
63+
result = message.apply(host, args);
64+
}
65+
results.push(result);
66+
} else {
67+
// a proper message, propagate to all interested parties
68+
var todo = table[message];
69+
if (todo !== undefined) {
70+
$.each(todo, function(itemNo, item) {
71+
var result;
72+
if (asynch !== null) {
73+
result = setTimeout(function() {
74+
try {
75+
item[1].apply(item[0], args);
76+
} catch (e) {
77+
that.handleAsynchError(e);
78+
}
79+
}, asynch);
80+
} else {
81+
result = item[1].apply(item[0], args);
82+
}
83+
results.push(result);
84+
});
85+
/* DEBUG
86+
} else {
87+
console.warn('Message ' + message + ' has no subscribers.'); // DEBUG
88+
*/
89+
}
90+
}
91+
if (returnType == 'any') {
92+
var i = results.length;
93+
while (i--) {
94+
if (results[i] !== false) return results[i];
95+
}
96+
return false;
97+
}
98+
if (returnType == 'all') {
99+
var i = results.length;
100+
while (i--) {
101+
if (results[i] === false) return results[i];
102+
}
103+
}
104+
return results;
105+
};
106+
107+
var proxy = function(destination, message) {
108+
this.on(message, function() {
109+
destination.post(message, Array.prototype.slice.call(arguments));
110+
});
111+
};
112+
113+
var dispatcher = {
114+
on: on,
115+
post: post,
116+
proxy: proxy,
117+
};
118+
Dispatcher.dispatchers.push(dispatcher);
119+
return dispatcher;
120+
};
121+
122+
Dispatcher.dispatchers = [];
123+
Dispatcher.post = function(asynch, message, args, returnType) {
124+
$.each(Dispatcher.dispatchers, function(dispatcherNo, dispatcher) {
125+
dispatcher.post(asynch, message, args, returnType);
126+
});
127+
};
128+
129+
return Dispatcher;
130+
})(jQuery, window);

0 commit comments

Comments
 (0)