-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathapi.js
61 lines (53 loc) · 1.32 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
const vntk = require('../lib/vntk');
const tokenizer = vntk.wordTokenizer();
const posTag = vntk.posTag();
const chunking = vntk.chunking();
const ner = vntk.ner();
// kites extension definition
module.exports = function (kites) {
kites.on('express:config', (app) => {
/**
* API Homepage
*/
app.get('/', (req, res) => {
res.send('This is an example Vntk Server!')
})
/**
* Word Tokenizer
*/
app.get('/api/tok/:text', (req, res) => {
var text = req.param('text')
var format = req.param('format')
var result = tokenizer.tag(text, format)
res.ok(result)
});
/**
* POS Tagging
*/
app.get('/api/pos/:text', (req, res) => {
var text = req.param('text')
var format = req.param('format')
var result = posTag.tag(text, format)
res.ok(result)
})
/**
* Chunking
*/
app.get('/api/chunking/:text', (req, res) => {
var text = req.param('text')
var format = req.param('format')
var result = chunking.tag(text, format)
res.ok(result)
})
/**
* Named Entity Recognition
*/
app.get('/api/ner/:text', (req, res) => {
var text = req.param('text')
var format = req.param('format')
var result = ner.tag(text, format)
res.ok(result)
})
})
}