Commit 75321f72 by snisioi

initial commit

parents
Pipeline #4470468 passed with stages
in 1 minute 39 seconds
before_script:
- apt-get update -qq && apt-get install -y -qq nodejs npm
pages:
script:
- cd public
- npm install
artifacts:
paths:
- public
only:
- master
\ No newline at end of file
### Wittgenstein Tractatus as a Network
First you need to run `npm install`
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<!doctype html>
<html ng-app="wittgenstein-app">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta charset="UTF-8">
<head>
<title>Wittgenstein Tractatus Network</title>
<link href="node_modules/vis/dist/vis.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="node_modules/mobile-angular-ui/dist/css/mobile-angular-ui-hover.min.css" />
<link rel="stylesheet" href="node_modules/mobile-angular-ui/dist/css/mobile-angular-ui-base.min.css" />
<link rel="stylesheet" href="node_modules/mobile-angular-ui/dist/css/mobile-angular-ui-desktop.min.css" />
<style type="text/css">
#conceptNetwork {
margin: auto;
width: 100%;
height: 100%;
border: 1px solid lightgray;
display: none;
}
#textDiv {
margin-left: 10px;
margin-right: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
#loadersmall {
position: absolute;
left: 50%;
top: 50%;
z-index: 1;
border: 5px solid #f3f3f3;
-webkit-animation: spin 1s linear infinite;
animation: spin 1s linear infinite;
border-top: 5px solid #555;
border-radius: 50%;
width: 30px;
height: 30px;
}
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.animate-bottom {
position: relative;
-webkit-animation-name: animatebottom;
-webkit-animation-duration: 1s;
animation-name: animatebottom;
animation-duration: 1s
}
@-webkit-keyframes animatebottom {
from {
bottom: -100px;
opacity: 0
}
to {
bottom: 0px;
opacity: 1
}
}
@keyframes animatebottom {
from {
bottom: -100px;
opacity: 0
}
to {
bottom: 0;
opacity: 1
}
}
</style>
<script src="node_modules/angular/angular.min.js"></script>
<script type="text/javascript" src="node_modules/vis/dist/vis.js"></script>
<script type="text/javascript" src="node_modules/fuse.js/src/fuse.min.js"></script>
<script src="node_modules/mobile-angular-ui/dist/js/mobile-angular-ui.min.js"></script>
<script src="node_modules/mobile-angular-ui/dist/js/mobile-angular-ui.gestures.min.js"></script>
<script type="text/javascript" src="data/edges.js"></script>
<script type="text/javascript" src="data/nodes.js"></script>
</head>
<body style="margin:0;" ng-controller="WittgensteinController">
<div id="loadersmall"></div>
<div id="conceptNetwork" class="animate-bottom"></div>
<div id="textDiv">
<p>
Search Wittgenstein's Tractatus Logico-Philosophicus
<input type="text" class="form-control" id="searchTextbox" ng-model="searchTextBox" placeholder="logical">
<p id="resultTextArea"> Proposition </p>
</p>
<p>
<label for="languageSelect">Select language:</label>
<select id="languageSelect" ng-model="languageSelect" ng-init="languageSelect='english_ogden'">
<option value="english_ogden" selected>English Ogden</option>
<option value="german">German</option>
<option value="english_peamg">English Pears &amp; McGuinness</option>
<option value="italian">Italian</option>
<option value="spanish">Spanish</option>
<option value="french">French</option>
<option value="russian">Russian</option>
</select>
</p>
</div>
<script src="js/tractatus.js"></script>
</body>
</html>
\ No newline at end of file
angular.module('wittgenstein-app', ['mobile-angular-ui.gestures','mobile-angular-ui']);
angular.module('wittgenstein-app').controller('WittgensteinController',function($scope, $http, $q){
$scope.nodesDataset = new vis.DataSet(nodes["english_ogden"]);
$scope.edgesDataset = new vis.DataSet(edges["english_ogden"]);
$scope.searchNodes = nodes["english_ogden"];
function loadNetwork() {
var container = document.getElementById('conceptNetwork');
var options = {
autoResize: true,
layout: {
improvedLayout:false
},
nodes: {
shape: 'dot',
size: 16
},
physics: {
forceAtlas2Based: {
gravitationalConstant: -38,
centralGravity: 0.005,
//springLength: 230,
springConstant: 0.18
},
maxVelocity: 146,
solver: 'forceAtlas2Based',
timestep: 0.35,
stabilization: {
iterations: 150
}
}
};
var data = {
nodes: $scope.nodesDataset,
edges: $scope.edgesDataset
}
$scope.network = new vis.Network(container, data, options);
$scope.network.on("click", neighbourhoodHighlight);
$scope.network.on("stabilizationProgress", function(params) {
document.getElementById("loadersmall").style.display = "block";
document.getElementById("conceptNetwork").style.display = "none";
});
$scope.network.once("stabilizationIterationsDone", function() {
setTimeout(function(){
document.getElementById("loadersmall").style.display = "none";
document.getElementById("conceptNetwork").style.display = "block";
}
, 5500);
});
}
$scope.$watch('languageSelect', function() {
if ($scope.languageSelect){
$scope.nodesDataset = new vis.DataSet(nodes[$scope.languageSelect]);
$scope.edgesDataset = new vis.DataSet(edges[$scope.languageSelect]);
$scope.searchNodes = nodes[$scope.languageSelect];
loadNetwork();
}
}, true);
$scope.$watch('searchTextBox', function() {
if ($scope.searchTextBox){
var options = {
shouldSort: true,
threshold: 0.6,
location: 0,
distance: 100,
maxPatternLength: 32,
keys: ["title", "label"]
};
var fuse = new Fuse($scope.searchNodes, options);
var result = fuse.search($scope.searchTextBox);
if (result==null || result===false || result[0] == null || result[0].id == null)
{
var params = {
nodes: []
}
}
else
{
var params = {
nodes: [result[0].id]
}
$scope.network.focus(result[0].id);
}
neighbourhoodHighlight(params);
}
else
{
neighbourhoodHighlight({nodes:[]});
}
}, true);
loadNetwork();
function neighbourhoodHighlight(params) {
var allNodes = $scope.nodesDataset.get({
returnType: "Object"
});
if (params.nodes.length > 0) {
$scope.highlightActive = true;
var i, j;
var selectedNode = params.nodes[0];
var degrees = 2;
document.getElementById('resultTextArea').innerHTML = " Proposition: " + allNodes[selectedNode].title;
for (var nodeId in allNodes) {
allNodes[nodeId].color = 'rgba(200,200,200,0.5)';
if (allNodes[nodeId].hiddenLabel === undefined) {
allNodes[nodeId].hiddenLabel = allNodes[nodeId].label;
allNodes[nodeId].label = undefined;
}
}
var connectedNodes = $scope.network.getConnectedNodes(selectedNode);
var allConnectedNodes = [];
for (i = 1; i < degrees; i++) {
for (j = 0; j < connectedNodes.length; j++) {
allConnectedNodes = allConnectedNodes.concat($scope.network.getConnectedNodes(connectedNodes[j]));
}
}
for (i = 0; i < allConnectedNodes.length; i++) {
allNodes[allConnectedNodes[i]].color = 'rgba(150,150,150,0.75)';
if (allNodes[allConnectedNodes[i]].hiddenLabel !== undefined) {
allNodes[allConnectedNodes[i]].label = allNodes[allConnectedNodes[i]].hiddenLabel;
allNodes[allConnectedNodes[i]].hiddenLabel = undefined;
}
}
for (i = 0; i < connectedNodes.length; i++) {
allNodes[connectedNodes[i]].color = undefined;
if (allNodes[connectedNodes[i]].hiddenLabel !== undefined) {
allNodes[connectedNodes[i]].label = allNodes[connectedNodes[i]].hiddenLabel;
allNodes[connectedNodes[i]].hiddenLabel = undefined;
}
}
allNodes[selectedNode].color = undefined;
if (allNodes[selectedNode].hiddenLabel !== undefined) {
allNodes[selectedNode].label = allNodes[selectedNode].hiddenLabel;
allNodes[selectedNode].hiddenLabel = undefined;
}
} else if ($scope.highlightActive === true) {
for (var nodeId in allNodes) {
allNodes[nodeId].color = undefined;
if (allNodes[nodeId].hiddenLabel !== undefined) {
allNodes[nodeId].label = allNodes[nodeId].hiddenLabel;
allNodes[nodeId].hiddenLabel = undefined;
}
}
$scope.highlightActive = false
}
var updateArray = [];
for (nodeId in allNodes) {
if (allNodes.hasOwnProperty(nodeId)) {
updateArray.push(allNodes[nodeId]);
}
}
$scope.nodesDataset.update(updateArray);
}
});
\ No newline at end of file
{
"name": "wittgenstein-network",
"version": "0.0.1",
"description": "\"Wittgenstein's Tractatus Concept Network\"",
"main": "index.js",
"dependencies": {
"angular": "~1.5.8",
"fuse.js": "~2.5.0",
"mobile-angular-ui": "~1.3.3",
"vis": "~4.16.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/senisioi/wittgenstein-network.git"
},
"keywords": [
"wittgenstein",
"tractatus",
"concepts",
"philosophy",
"network",
"digital humanities"
],
"author": "Anca Bucur & Sergiu Nisioi",
"license": "GNU General Public License",
"bugs": {
"url": "https://github.com/senisioi/wittgenstein-network/issues"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment