-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfenci.js
53 lines (42 loc) · 1.14 KB
/
fenci.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
var mmseg = require("mmseg");
var Sequelize = require('sequelize');
var sequelize = new Sequelize('tips_test', 'zx', 'admin', {
dialect: "postgres", // or 'sqlite', 'postgres', 'mariadb'
host: "172.31.214.169",
port: 5432, // or 5432 (for postgres)
});
sequelize
.authenticate()
.complete(function(err) {
if (!!err) {
console.log('Unable to connect to the database:', err)
} else {
console.log('Connection has been established successfully.')
}
});
var Tip = sequelize.define('Tip', {
content: Sequelize.STRING,
other: Sequelize.STRING
});
var Word = sequelize.define('Word', {
content: Sequelize.STRING,
other: Sequelize.STRING
});
var TipWord = sequelize.define('TipWord', {
tip_id: Sequelize.INTEGER,
word_id: Sequelize.INTEGER,
other: Sequelize.STRING
});
// var q = mmseg.open('/usr/local/etc/');
// console.log(q.segmentSync("我是中文分词"));
// var exclude_words = ["我","的"];
function fenci () {
Tip.findAll().success(function (tips) {
console.log(tips);
tips.forEach(function(tip) {
words = q.segmentSync(tip.content);
console.log(words);
});
})
}
fenci();