crosslanguagespotter 0.0.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +3 -0
- data/Rakefile +13 -0
- data/crosslanguagespotter.gemspec +36 -0
- data/examples/ex1.rb +13 -0
- data/examples/services_example.rb +13 -0
- data/lib/crosslanguagespotter/basic.rb +157 -0
- data/lib/crosslanguagespotter/context.rb +139 -0
- data/lib/crosslanguagespotter/figures_evaluator.rb +160 -0
- data/lib/crosslanguagespotter/jaccard.rb +114 -0
- data/lib/crosslanguagespotter/methods/context.rb +127 -0
- data/lib/crosslanguagespotter/methods/jaro.rb +118 -0
- data/lib/crosslanguagespotter/methods/tversky.rb +44 -0
- data/lib/crosslanguagespotter/model_loading.rb +333 -0
- data/lib/crosslanguagespotter/oracle.rb +261 -0
- data/lib/crosslanguagespotter/report.rb +88 -0
- data/lib/crosslanguagespotter/version.rb +5 -0
- data/lib/crosslanguagespotter/wekaintegration.rb +83 -0
- data/lib/crosslanguagespotter.rb +7 -0
- data/lib/jars/weka.jar +0 -0
- data/resources/css/bootstrap-theme.css +346 -0
- data/resources/css/bootstrap-theme.min.css +7 -0
- data/resources/css/bootstrap.css +5780 -0
- data/resources/css/bootstrap.min.css +7 -0
- data/resources/css/highlightstyles/arta.css +160 -0
- data/resources/css/highlightstyles/ascetic.css +50 -0
- data/resources/css/highlightstyles/atelier-dune.dark.css +93 -0
- data/resources/css/highlightstyles/atelier-dune.light.css +93 -0
- data/resources/css/highlightstyles/atelier-forest.dark.css +93 -0
- data/resources/css/highlightstyles/atelier-forest.light.css +93 -0
- data/resources/css/highlightstyles/atelier-heath.dark.css +93 -0
- data/resources/css/highlightstyles/atelier-heath.light.css +93 -0
- data/resources/css/highlightstyles/atelier-lakeside.dark.css +93 -0
- data/resources/css/highlightstyles/atelier-lakeside.light.css +93 -0
- data/resources/css/highlightstyles/atelier-seaside.dark.css +93 -0
- data/resources/css/highlightstyles/atelier-seaside.light.css +93 -0
- data/resources/css/highlightstyles/brown_paper.css +105 -0
- data/resources/css/highlightstyles/brown_papersq.png +0 -0
- data/resources/css/highlightstyles/dark.css +105 -0
- data/resources/css/highlightstyles/default.css +153 -0
- data/resources/css/highlightstyles/docco.css +132 -0
- data/resources/css/highlightstyles/far.css +113 -0
- data/resources/css/highlightstyles/foundation.css +133 -0
- data/resources/css/highlightstyles/github.css +125 -0
- data/resources/css/highlightstyles/googlecode.css +147 -0
- data/resources/css/highlightstyles/idea.css +122 -0
- data/resources/css/highlightstyles/ir_black.css +105 -0
- data/resources/css/highlightstyles/magula.css +123 -0
- data/resources/css/highlightstyles/mono-blue.css +62 -0
- data/resources/css/highlightstyles/monokai.css +127 -0
- data/resources/css/highlightstyles/monokai_sublime.css +149 -0
- data/resources/css/highlightstyles/obsidian.css +154 -0
- data/resources/css/highlightstyles/paraiso.dark.css +93 -0
- data/resources/css/highlightstyles/paraiso.light.css +93 -0
- data/resources/css/highlightstyles/pojoaque.css +106 -0
- data/resources/css/highlightstyles/pojoaque.jpg +0 -0
- data/resources/css/highlightstyles/railscasts.css +182 -0
- data/resources/css/highlightstyles/rainbow.css +112 -0
- data/resources/css/highlightstyles/school_book.css +113 -0
- data/resources/css/highlightstyles/school_book.png +0 -0
- data/resources/css/highlightstyles/solarized_dark.css +107 -0
- data/resources/css/highlightstyles/solarized_light.css +107 -0
- data/resources/css/highlightstyles/sunburst.css +160 -0
- data/resources/css/highlightstyles/tomorrow-night-blue.css +93 -0
- data/resources/css/highlightstyles/tomorrow-night-bright.css +92 -0
- data/resources/css/highlightstyles/tomorrow-night-eighties.css +92 -0
- data/resources/css/highlightstyles/tomorrow-night.css +93 -0
- data/resources/css/highlightstyles/tomorrow.css +90 -0
- data/resources/css/highlightstyles/vs.css +89 -0
- data/resources/css/highlightstyles/xcode.css +158 -0
- data/resources/css/highlightstyles/zenburn.css +117 -0
- data/resources/example.html +1501 -0
- data/resources/js/bootstrap.js +1943 -0
- data/resources/js/bootstrap.min.js +7 -0
- data/resources/js/highlight.pack.js +1 -0
- data/resources/services_example.html +141 -0
- data/resources/template.html +61 -0
- data/test/data/angular-puzzle.GS +111 -0
- data/test/data/angular_puzzle/app.js +66 -0
- data/test/data/angular_puzzle/index.html +67 -0
- data/test/data/angular_puzzle/slidingPuzzle.js +203 -0
- data/test/data/angular_puzzle/wordSearchPuzzle.js +270 -0
- data/test/data/example.html +5 -0
- data/test/data/example.js +4 -0
- data/test/data/services/index.html +33 -0
- data/test/data/services/script.js +15 -0
- data/test/test_helper.rb +9 -0
- data/test/test_parsing.rb +23 -0
- data/test/test_spotter.rb +42 -0
- data/test/test_wekaintegration.rb +43 -0
- metadata +328 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
(function(angular) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var module = angular.module('slidingPuzzle', []);
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Service
|
8
|
+
*/
|
9
|
+
module.factory('slidingPuzzle', function() {
|
10
|
+
function shuffle(a) {
|
11
|
+
var q;
|
12
|
+
for (var j, x, i = a.length; i; j = parseInt(Math.random() * i, 10), x = a[--i], a[i] = a[j], a[j] = x) { q = 0; }
|
13
|
+
return a;
|
14
|
+
}
|
15
|
+
|
16
|
+
function SlidingPuzzle(rows, cols) {
|
17
|
+
/**
|
18
|
+
* Puzzle grid
|
19
|
+
* @type {Array}
|
20
|
+
*/
|
21
|
+
this.grid = [];
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Moves count
|
25
|
+
* @type {Number}
|
26
|
+
*/
|
27
|
+
this.moves = 0;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Moves tile
|
31
|
+
* @param srow
|
32
|
+
* @param scol
|
33
|
+
*/
|
34
|
+
this.move = function(srow, scol) {
|
35
|
+
var dirs = [[1, 0], [-1, 0], [0, 1], [0, -1]],
|
36
|
+
tref, trow, tcol;
|
37
|
+
|
38
|
+
for (var d = 0; d < dirs.length; d++) {
|
39
|
+
trow = srow + dirs[d][0];
|
40
|
+
tcol = scol + dirs[d][1];
|
41
|
+
if (this.grid[trow] && this.grid[trow][tcol] && this.grid[trow][tcol].empty) {
|
42
|
+
tref = this.grid[srow][scol];
|
43
|
+
this.grid[srow][scol] = this.grid[trow][tcol];
|
44
|
+
this.grid[trow][tcol] = tref;
|
45
|
+
this.moves++;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Shuffles grid
|
52
|
+
*/
|
53
|
+
this.shuffle = function() {
|
54
|
+
var tiles = [];
|
55
|
+
this.traverse(function(tile) {
|
56
|
+
tiles.push(tile);
|
57
|
+
});
|
58
|
+
shuffle(tiles);
|
59
|
+
this.traverse(function(tile, row, col) {
|
60
|
+
this.grid[row][col] = tiles.shift();
|
61
|
+
});
|
62
|
+
this.moves = 0;
|
63
|
+
};
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Solves puzzle
|
67
|
+
*/
|
68
|
+
this.solve = function() {
|
69
|
+
var tiles = [];
|
70
|
+
this.traverse(function(tile) {
|
71
|
+
tiles.push(tile);
|
72
|
+
});
|
73
|
+
tiles.sort(function(x, y) {
|
74
|
+
return (x.id - y.id);
|
75
|
+
});
|
76
|
+
this.traverse(function(tile, row, col) {
|
77
|
+
this.grid[row][col] = tiles.shift();
|
78
|
+
});
|
79
|
+
};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Is solved?
|
83
|
+
* @type {Boolean}
|
84
|
+
*/
|
85
|
+
this.isSolved = function() {
|
86
|
+
var id = 1;
|
87
|
+
for (var row = 0; row < rows; row++) {
|
88
|
+
for (var col = 0; col < cols; col++) {
|
89
|
+
if (this.grid[row][col].id !== id++) {
|
90
|
+
return false;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return true;
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Traverses grid and executes fn on every tile
|
99
|
+
* @param fn
|
100
|
+
*/
|
101
|
+
this.traverse = function(fn) {
|
102
|
+
for (var row = 0; row < rows; row++) {
|
103
|
+
for (var col = 0; col < cols; col++) {
|
104
|
+
fn.call(this, this.grid && this.grid[row] ? this.grid[row][col] : undefined, row, col);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
109
|
+
// initialize grid
|
110
|
+
var id = 1;
|
111
|
+
this.traverse(function(tile, row, col) {
|
112
|
+
if (!this.grid[row]) {
|
113
|
+
this.grid[row] = [];
|
114
|
+
}
|
115
|
+
this.grid[row][col] = {
|
116
|
+
id: id++,
|
117
|
+
empty: (row === rows - 1) && (col === cols - 1)
|
118
|
+
};
|
119
|
+
if (this.grid[row][col].empty) {
|
120
|
+
this.empty = this.grid[row][col];
|
121
|
+
}
|
122
|
+
});
|
123
|
+
}
|
124
|
+
|
125
|
+
return function(rows, cols) {
|
126
|
+
return new SlidingPuzzle(rows, cols);
|
127
|
+
};
|
128
|
+
});
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Directive
|
132
|
+
*/
|
133
|
+
module.directive('slidingPuzzle', function(slidingPuzzle) {
|
134
|
+
return {
|
135
|
+
restrict: 'EA',
|
136
|
+
replace: true,
|
137
|
+
template: '<table class="sliding-puzzle" ng-class="{\'puzzle-solved\': puzzle.isSolved()}">' +
|
138
|
+
'<tr ng-repeat="($row, row) in puzzle.grid">' +
|
139
|
+
'<td ng-repeat="($col, tile) in row" ng-click="puzzle.move($row, $col)" ng-style="tile.style" ng-class="{\'puzzle-empty\': tile.empty}" title="{{tile.id}}"></td>' +
|
140
|
+
'</tr>' +
|
141
|
+
'</table>',
|
142
|
+
scope: {
|
143
|
+
size: '@',
|
144
|
+
src: '@',
|
145
|
+
api: '='
|
146
|
+
},
|
147
|
+
link: function(scope, element, attrs) {
|
148
|
+
var rows, cols,
|
149
|
+
loading = true,
|
150
|
+
image = new Image();
|
151
|
+
|
152
|
+
function create() {
|
153
|
+
scope.puzzle = slidingPuzzle(rows, cols);
|
154
|
+
|
155
|
+
if (attrs.api) {
|
156
|
+
scope.api = scope.puzzle;
|
157
|
+
}
|
158
|
+
|
159
|
+
tile();
|
160
|
+
}
|
161
|
+
|
162
|
+
function tile() {
|
163
|
+
if (loading) {
|
164
|
+
return;
|
165
|
+
}
|
166
|
+
|
167
|
+
var width = image.width / cols,
|
168
|
+
height = image.height / rows;
|
169
|
+
|
170
|
+
scope.puzzle.traverse(function(tile, row, col) {
|
171
|
+
tile.style = {
|
172
|
+
width: width + 'px',
|
173
|
+
height: height + 'px',
|
174
|
+
background: (tile.empty ? 'none' : "url('" + scope.src + "') no-repeat -" + (col * width) + 'px -' + (row * height) + 'px')
|
175
|
+
};
|
176
|
+
});
|
177
|
+
|
178
|
+
scope.puzzle.shuffle();
|
179
|
+
}
|
180
|
+
|
181
|
+
attrs.$observe('size', function(size) {
|
182
|
+
size = size.split('x');
|
183
|
+
if (size[0] >= 2 && size[1] >= 2) {
|
184
|
+
rows = size[0];
|
185
|
+
cols = size[1];
|
186
|
+
create();
|
187
|
+
}
|
188
|
+
});
|
189
|
+
|
190
|
+
attrs.$observe('src', function(src) {
|
191
|
+
loading = true;
|
192
|
+
image.src = src;
|
193
|
+
image.onload = function() {
|
194
|
+
loading = false;
|
195
|
+
scope.$apply(function() {
|
196
|
+
tile();
|
197
|
+
});
|
198
|
+
};
|
199
|
+
});
|
200
|
+
}
|
201
|
+
};
|
202
|
+
});
|
203
|
+
})(window.angular);
|
@@ -0,0 +1,270 @@
|
|
1
|
+
(function(angular) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var module = angular.module('wordSearchPuzzle', []);
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Service
|
8
|
+
*/
|
9
|
+
module.factory('wordSearchPuzzle', function() {
|
10
|
+
/**
|
11
|
+
* Word search puzzle
|
12
|
+
* @param matrix
|
13
|
+
* @param words
|
14
|
+
* @constructor
|
15
|
+
*/
|
16
|
+
function WordSearchPuzzle(matrix, words) {
|
17
|
+
var maxRow = 0,
|
18
|
+
maxCol = 0;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Matrix
|
22
|
+
* @type {Array}
|
23
|
+
*/
|
24
|
+
this.matrix = [];
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Words
|
28
|
+
* @type {Array}
|
29
|
+
*/
|
30
|
+
this.words = [];
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Is solved?
|
34
|
+
* @type {Boolean}
|
35
|
+
*/
|
36
|
+
this.solved = false;
|
37
|
+
|
38
|
+
// parse matrix and words
|
39
|
+
angular.forEach(matrix, function(letters, row) {
|
40
|
+
angular.forEach(letters, function(letter, col) {
|
41
|
+
var item = {
|
42
|
+
letter: letter,
|
43
|
+
col: col,
|
44
|
+
row: row,
|
45
|
+
used: false
|
46
|
+
};
|
47
|
+
if (!this.matrix[row]) {
|
48
|
+
this.matrix[row] = [];
|
49
|
+
}
|
50
|
+
this.matrix[row].push(item);
|
51
|
+
maxCol = col;
|
52
|
+
}, this);
|
53
|
+
maxRow = row;
|
54
|
+
}, this);
|
55
|
+
angular.forEach(words, function(word) {
|
56
|
+
this.words.push({
|
57
|
+
name: word
|
58
|
+
});
|
59
|
+
}, this);
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Returns matrix item by coords
|
63
|
+
* @param col
|
64
|
+
* @param row
|
65
|
+
* @return {*}
|
66
|
+
*/
|
67
|
+
this.getItem = function(col, row) {
|
68
|
+
return (this.matrix[row] ? this.matrix[row][col] : undefined);
|
69
|
+
};
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Returns matrix items by start/end coords
|
73
|
+
* @param colFrom
|
74
|
+
* @param rowFrom
|
75
|
+
* @param colTo
|
76
|
+
* @param rowTo
|
77
|
+
* @return {Array}
|
78
|
+
*/
|
79
|
+
this.getItems = function(colFrom, rowFrom, colTo, rowTo) {
|
80
|
+
var items = [];
|
81
|
+
|
82
|
+
if (rowTo > maxRow) {
|
83
|
+
rowTo = maxRow;
|
84
|
+
}
|
85
|
+
if (colTo > maxCol) {
|
86
|
+
colTo = maxCol;
|
87
|
+
}
|
88
|
+
|
89
|
+
if (this.getItem(colTo, rowTo) === undefined) {
|
90
|
+
return items;
|
91
|
+
}
|
92
|
+
|
93
|
+
if (colFrom === colTo || rowFrom === rowTo || Math.abs(colTo - colFrom) === Math.abs(rowTo - rowFrom)) {
|
94
|
+
var shiftX = (colFrom === colTo ? 0 : (colTo > colFrom ? 1 : -1)),
|
95
|
+
shiftY = (rowFrom === rowTo ? 0 : (rowTo > rowFrom ? 1 : -1)),
|
96
|
+
col = colFrom,
|
97
|
+
row = rowFrom;
|
98
|
+
|
99
|
+
items.push(this.getItem(col, row));
|
100
|
+
do {
|
101
|
+
col += shiftX;
|
102
|
+
row += shiftY;
|
103
|
+
items.push(this.getItem(col, row));
|
104
|
+
} while (col !== colTo || row !== rowTo);
|
105
|
+
}
|
106
|
+
|
107
|
+
return items;
|
108
|
+
};
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Check items - find word
|
112
|
+
* @param items
|
113
|
+
*/
|
114
|
+
this.lookup = function(items) {
|
115
|
+
if (!items.length) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
|
119
|
+
// create words
|
120
|
+
var words = [''];
|
121
|
+
angular.forEach(items, function(item) {
|
122
|
+
words[0] += item.letter;
|
123
|
+
});
|
124
|
+
words.push(words[0].split('').reverse().join('')); // word in reverse order (when selecting)
|
125
|
+
|
126
|
+
// check words
|
127
|
+
this.solved = true;
|
128
|
+
angular.forEach(this.words, function(word) {
|
129
|
+
if (word.found) {
|
130
|
+
return;
|
131
|
+
}
|
132
|
+
angular.forEach(words, function(itemWord) {
|
133
|
+
if (word.name === itemWord) {
|
134
|
+
word.found = true;
|
135
|
+
angular.forEach(items, function(item) {
|
136
|
+
item.found = true;
|
137
|
+
});
|
138
|
+
}
|
139
|
+
});
|
140
|
+
if (!word.found) {
|
141
|
+
this.solved = false;
|
142
|
+
}
|
143
|
+
}, this);
|
144
|
+
};
|
145
|
+
|
146
|
+
/**
|
147
|
+
* Solves puzzle
|
148
|
+
*/
|
149
|
+
this.solve = function() {
|
150
|
+
var start = {},
|
151
|
+
directions = {
|
152
|
+
N: [0, -1], E: [1, 0], S: [0, 1], W: [-1, 0],
|
153
|
+
NE: [1, -1], NW: [-1, -1], SE: [1, 1], SW: [-1, 1]
|
154
|
+
};
|
155
|
+
|
156
|
+
// group items by letters for faster search
|
157
|
+
angular.forEach(this.matrix, function(items) {
|
158
|
+
angular.forEach(items, function(item) {
|
159
|
+
if (!start[item.letter]) {
|
160
|
+
start[item.letter] = [];
|
161
|
+
}
|
162
|
+
start[item.letter].push(item);
|
163
|
+
});
|
164
|
+
});
|
165
|
+
|
166
|
+
angular.forEach(this.words, function(word) {
|
167
|
+
angular.forEach(start[word.name.charAt(0)], function(start) {
|
168
|
+
if (word.found) {
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
angular.forEach(directions, function(shift) {
|
172
|
+
if (word.found) {
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
this.lookup(this.getItems(
|
176
|
+
start.col, start.row,
|
177
|
+
start.col + (word.name.length - 1) * shift[0],
|
178
|
+
start.row + (word.name.length - 1) * shift[1]
|
179
|
+
));
|
180
|
+
}, this);
|
181
|
+
}, this);
|
182
|
+
}, this);
|
183
|
+
};
|
184
|
+
}
|
185
|
+
|
186
|
+
return function(matrix, words) {
|
187
|
+
return new WordSearchPuzzle(matrix, words);
|
188
|
+
};
|
189
|
+
});
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Directive
|
193
|
+
*/
|
194
|
+
module.directive('wordSearchPuzzle', function(wordSearchPuzzle) {
|
195
|
+
return {
|
196
|
+
restrict: 'EA',
|
197
|
+
replace: true,
|
198
|
+
template: '<table class="word-search-puzzle" cellspacing="0" ng-class="{\'puzzle-solved\': puzzle.solved}">' +
|
199
|
+
'<tr ng-repeat="items in puzzle.matrix">' +
|
200
|
+
'<td ng-repeat="item in items" unselectable="on"' +
|
201
|
+
' ng-class="{\'puzzle-found\': item.found, \'puzzle-selected\': item.selected, \'puzzle-message\': puzzle.solved && !item.found}"' +
|
202
|
+
' ng-mousedown="selectStart(item)" ng-mouseup="selectEnd()" ng-mouseenter="selectEnter(item)">' +
|
203
|
+
' <span>{{item.letter}}</span>' +
|
204
|
+
'</td>' +
|
205
|
+
'</tr>' +
|
206
|
+
'</table>',
|
207
|
+
scope: {
|
208
|
+
matrix: '=',
|
209
|
+
words: '=',
|
210
|
+
api: '='
|
211
|
+
},
|
212
|
+
link: function(scope, element, attrs) {
|
213
|
+
var selectFrom;
|
214
|
+
|
215
|
+
// setup puzzle
|
216
|
+
scope.$watch('matrix', function(matrix) {
|
217
|
+
scope.puzzle = wordSearchPuzzle(matrix, scope.words);
|
218
|
+
|
219
|
+
// link service
|
220
|
+
if (attrs.api) {
|
221
|
+
scope.api = scope.puzzle;
|
222
|
+
}
|
223
|
+
});
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Selected items
|
227
|
+
* @type {Array}
|
228
|
+
*/
|
229
|
+
scope.selected = [];
|
230
|
+
|
231
|
+
/**
|
232
|
+
* Selection start
|
233
|
+
* @param item
|
234
|
+
*/
|
235
|
+
scope.selectStart = function(item) {
|
236
|
+
selectFrom = item;
|
237
|
+
};
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Selection enter (over)
|
241
|
+
* @param item
|
242
|
+
*/
|
243
|
+
scope.selectEnter = function(item) {
|
244
|
+
if (selectFrom) {
|
245
|
+
scope.selected = scope.puzzle.getItems(selectFrom.col, selectFrom.row, item.col, item.row);
|
246
|
+
}
|
247
|
+
};
|
248
|
+
|
249
|
+
/**
|
250
|
+
* Selection end
|
251
|
+
*/
|
252
|
+
scope.selectEnd = function() {
|
253
|
+
selectFrom = null;
|
254
|
+
scope.puzzle.lookup(scope.selected);
|
255
|
+
scope.selected = [];
|
256
|
+
};
|
257
|
+
|
258
|
+
// propagate selection state to matrix
|
259
|
+
scope.$watch('selected', function(newItems, oldItems) {
|
260
|
+
angular.forEach(oldItems, function(item) {
|
261
|
+
item.selected = false;
|
262
|
+
});
|
263
|
+
angular.forEach(newItems, function(item) {
|
264
|
+
item.selected = true;
|
265
|
+
});
|
266
|
+
});
|
267
|
+
}
|
268
|
+
};
|
269
|
+
});
|
270
|
+
})(window.angular);
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<meta charset="utf-8"/>
|
6
|
+
<title>Your First AngularJS App</title>
|
7
|
+
|
8
|
+
<!-- Google web fonts -->
|
9
|
+
<link href="http://fonts.googleapis.com/css?family=PT+Sans:400,700" rel='stylesheet' />
|
10
|
+
|
11
|
+
<!-- The main CSS file -->
|
12
|
+
<link href="assets/css/style.css" rel="stylesheet" />
|
13
|
+
</head>
|
14
|
+
|
15
|
+
<body>
|
16
|
+
|
17
|
+
<form id="main" ng-app ng-controller="myservices">
|
18
|
+
<h1>My Services</h1>
|
19
|
+
|
20
|
+
<ul id="services">
|
21
|
+
<!-- The services will be inserted here -->
|
22
|
+
<li ng-repeat="service in services">
|
23
|
+
</li>
|
24
|
+
</ul>
|
25
|
+
|
26
|
+
<p id="total">total: <span>${{total()}}</span></p>
|
27
|
+
|
28
|
+
<input type="submit" id="order" value="Order"/>
|
29
|
+
|
30
|
+
</form>
|
31
|
+
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function myservices($scope){
|
2
|
+
$scope.services=[
|
3
|
+
{ title: 'web development', price: 200},
|
4
|
+
{ title: 'web design', price: 250},
|
5
|
+
{ title: 'photography', price: 100},
|
6
|
+
{ title: 'coffee drinking', price: 10}];
|
7
|
+
$scope.total=function(){
|
8
|
+
var t = 0;
|
9
|
+
angular.forEach($scope.services, function(s){
|
10
|
+
if(s.selected)
|
11
|
+
t+=s.price;
|
12
|
+
});
|
13
|
+
return t;
|
14
|
+
};
|
15
|
+
}
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'codemodels'
|
3
|
+
require 'codemodels/xml'
|
4
|
+
require 'codemodels/properties'
|
5
|
+
require 'codemodels/html'
|
6
|
+
require 'codemodels/js'
|
7
|
+
|
8
|
+
class TestParsing < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_parse_html_file
|
14
|
+
root = CodeModels.parse_file('./test/data/example.html')
|
15
|
+
assert root.is_a?(CodeModels::Html::HtmlDocument)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_parse_js_file
|
19
|
+
root = CodeModels.parse_file('./test/data/example.js')
|
20
|
+
assert root.is_a?(CodeModels::Js::AstRoot)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'codemodels'
|
3
|
+
require 'codemodels/xml'
|
4
|
+
require 'codemodels/properties'
|
5
|
+
require 'codemodels/html'
|
6
|
+
require 'codemodels/js'
|
7
|
+
|
8
|
+
class TestSpotter < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_models_loading
|
14
|
+
models = CrossLanguageSpotter._load_models('./test/data/angular_puzzle')
|
15
|
+
assert_equal 4,models.count
|
16
|
+
assert models.has_key?('/app.js')
|
17
|
+
assert models.has_key?('/index.html')
|
18
|
+
assert models.has_key?('/slidingPuzzle.js')
|
19
|
+
assert models.has_key?('/wordSearchPuzzle.js')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_features_calc
|
23
|
+
dir = './test/data/angular_puzzle'
|
24
|
+
spotter = CrossLanguageSpotter::Spotter.new()
|
25
|
+
spotter.features_for_dir(dir)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_oracle
|
29
|
+
dir = './test/data/angular_puzzle'
|
30
|
+
oracle_loader = OracleLoader.new
|
31
|
+
oracle_loader.to_train_data(dir,'./test/data/angular-puzzle.GS')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_full_behavior
|
35
|
+
oracle_loader = OracleLoader.new
|
36
|
+
classifier = oracle_loader.build_weka_classifier('./test/data/angular_puzzle','./test/data/angular-puzzle.GS')
|
37
|
+
spotter = CrossLanguageSpotter::Spotter.new()
|
38
|
+
project = Project.new('./test/data/services')
|
39
|
+
results = spotter.classify_relations(project,classifier)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestWekaIntegration < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@train_data = [
|
7
|
+
{a: 10.0, b:7, c:false},
|
8
|
+
{a: 12.0, b:3, c:false},
|
9
|
+
{a: 18.4, b:-4, c:true}
|
10
|
+
]
|
11
|
+
@sample_data = [
|
12
|
+
{a: 10.5, b:6},
|
13
|
+
{a: 12.1, b:2},
|
14
|
+
{a: 21.4, b:-8}
|
15
|
+
]
|
16
|
+
@sample_data2 = [
|
17
|
+
{a: 10.5, b:6, c:false},
|
18
|
+
{a: 12.1, b:2, c:false},
|
19
|
+
{a: 21.4, b:-8, c:false}
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_hash2weka_instances_with_train_data
|
24
|
+
instances = hash2weka_instances('my_dataset',@train_data,{a: :numeric, b: :numeric, c: :boolean},:c)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_hash2weka_instances_with_data_to_classify
|
28
|
+
instances = hash2weka_instances('my_dataset',@sample_data,{a: :numeric, b: :numeric},nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_build_classifier
|
32
|
+
instances = hash2weka_instances('my_dataset',@train_data,{a: :numeric, b: :numeric, c: :boolean},:c)
|
33
|
+
c = build_classifier(instances)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_classify
|
37
|
+
train_instances = hash2weka_instances('my_train_dataset',@train_data,{a: :numeric, b: :numeric, c: :boolean},:c)
|
38
|
+
data_instances = hash2weka_instances('my_sample_dataset',@sample_data2,{a: :numeric, b: :numeric, c: :boolean},:c)
|
39
|
+
classifier = WekaClassifier.new(train_instances)
|
40
|
+
results = classifier.classify(data_instances)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|