Skip to content

Commit

Permalink
Use bootstrap visual labels for tokenizer tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Mar 3, 2013
1 parent a9dbed5 commit c1d6538
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions _site/js/controllers/TokenizerCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ function TokenizerCtrl($scope, $http, Tokenizer, Data){
$scope.tokenizer = Tokenizer;
$scope.data = Data;

$scope.ttext = [];

$scope.$watch('tokenizer.query', function(value){
for (i in $scope.tokenizer.tokenizers){
$scope.analyze($scope.tokenizer.tokenizers[i]);
Expand All @@ -17,11 +15,16 @@ function TokenizerCtrl($scope, $http, Tokenizer, Data){

$http.post(path, $scope.tokenizer.query)
.success(function(response){
var ret = '';
var tokens = [];
for(i in response.tokens){
ret += '[' + response.tokens[i].token + '] ';
var token = response.tokens[i].token;

//bootstrap labels do silly things with only a single space
if (token === ' ') {token = " ";}

tokens.push(token);
}
$scope.tokenizer.ttext[tokenizer] = ret;
$scope.tokenizer.ttext[tokenizer] = tokens;

})
.error(function(data, status, headers, config){
Expand Down
6 changes: 4 additions & 2 deletions _site/views/tokenizers.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
</tr>
</thead>
<tbody >
<tr ng-repeat="t in tokenizer.tokenizers">
<tr ng-repeat="t in tokenizer.tokenizers">
<td>{{t}}</td>
<td>{{$parent.tokenizer.ttext[t]}}</td>
<td>
<span class="label" style="margin-right: 0.25em" ng-repeat="token in tokenizer.ttext[t]" ng-bind-html="token"> </span>
</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit c1d6538

Please sign in to comment.