-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
94 lines (71 loc) · 1.81 KB
/
main.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
非同期処理に悩まされたので取り敢えず分割。
こっちはサスペンドで。
var usemecab = require('./usemecab.js');
var url1 = "http://kenko100.jp/articles/121019001761/";
kekka = function(url){
var ary = usemecab.chushutu(url);
console.log(ary);
}
async.waterfall([
function A(done){
var ary = usemecab.chushutu(url1);
},
function B(done){
console.log(ary);
}
],function(err){
console.log('all comp');
});
*/
/*
こっからは
usemecab1.js
usemecab2.js
を終わらせた後に使う関係性算出プログラムです。
*/
var json1 = require('./1st.json');
var json2 = require('./2st.json');
var kikyaku = 0.5;
function keisan(hyosoi,hiritui){
this.hyoso = hyosoi;
this.hiritu = hiritui;
}
var json1_kikyaku = [];
var json2_kikyaku = [];
var ketugo = [];
json1.forEach(function(line){
if(line.hiritu >= kikyaku){
json1_kikyaku.push(new keisan(line.hyoso,line.hiritu));
}
});
json2.forEach(function(line){
if(line.hiritu >= kikyaku){
json2_kikyaku.push(new keisan(line.hyoso,line.hiritu));
}
});
console.log(json1_kikyaku);
console.log(json2_kikyaku);
json1_kikyaku.forEach(function(line){
json2_kikyaku.forEach(function(line2){
if(line.hyoso == line2.hyoso){
if(line.hiritu > line2.hiritu){
var kyotu = line.hiritu - (line.hiritu - line2.hiritu);
}
else if(line.hiritu == line2.hiritu){
var kyotu = 0;
}
else if(line.hiritu < line2.hiritu){
var kyotu = line2.hiritu - (line2.hiritu - line.hiritu);
}
ketugo.push(new keisan(line.hyoso,kyotu));
console.log("keisanに投入!!!");
}
});
});
console.log(ketugo);
var goke = 0;
ketugo.forEach(function(line){
goke = goke + line.hiritu * line.hyoso.length;
});
console.log("関係指数は " + goke + " です。");