-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init factual-consensus-finder from remote
- Loading branch information
Showing
26 changed files
with
2,210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
# gfs | ||
# GlobalFactSync | ||
|
||
DBpedia, which frequently crawls and analyses over 120 Wikipedia language editions has near complete information about (1) which facts are in infoboxes across all Wikipedias (2) where Wikidata is already used in those infoboxes. GlobalFactSyncRE will extract all infobox facts and their references to produce a tool for Wikipedia editors that detects and displays differences across infobox facts in an intelligent way to help sync infoboxes between languages and/or Wikidata. The extracted references will also be used to enhance Wikidata. Click Join below to receive GFS updates via {{ping}} to your Wikiaccount. | ||
|
||
# Applications | ||
|
||
## Factual Consensus Finder | ||
|
||
**TODO** | ||
|
||
# Services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# TODO | ||
# Usage | ||
|
||
``` | ||
npm install | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
var express = require('express'); | ||
// var createError = require('http-errors'); | ||
// var path = require('path'); | ||
// var cookieParser = require('cookie-parser'); | ||
// var logger = require('morgan'); | ||
var expressLayouts = require('express-ejs-layouts'); | ||
// var conf = require('config') | ||
// var indexRouter = require('./routes/index'); | ||
// var usersRouter = require('./routes/users'); | ||
var dateTime = require('node-datetime'); | ||
|
||
var conf = require('./config'); | ||
var MongoClient = require('mongodb').MongoClient; | ||
var util = require('util'); | ||
var connection; | ||
|
||
var getJSON = require('get-json'); | ||
|
||
var app = express(); | ||
|
||
var sourceList = conf.preference.split(","); | ||
sourceList.push("general"); | ||
sourceList.sort(); | ||
|
||
app.use(expressLayouts); | ||
//app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'ejs'); | ||
app.use(express.static('public')); | ||
|
||
|
||
MongoClient.connect(conf.mongo_url, function(err, client) { | ||
|
||
if (err) return console.log(err); | ||
|
||
connection = client.db(conf.database_name) | ||
}); | ||
|
||
app.get('/', function(req, res) { | ||
|
||
var s = req.query.s; | ||
var p = req.query.p; | ||
var src = req.query.src; | ||
|
||
if( s == null ) s = conf.default_subject; | ||
if( p == null ) p = conf.default_predicate; | ||
if( src == null ) src = "general"; | ||
|
||
var original = s; | ||
var locals; | ||
|
||
//TODO logging | ||
if ( s.includes("wikipedia.org/wiki/") ) { | ||
s = s.replace("https://","http://"); | ||
s = s.replace("http://en.","http://"); | ||
s = s.replace("wikipedia.org/wiki/","dbpedia.org/resource/"); | ||
} | ||
|
||
getJSON(conf.id_management+s).then( function (idResponse) { | ||
|
||
if( s.startsWith("https://global.dbpedia")) { | ||
console.log("[ "+dateTime.create().format('Y-m-d H:M:S')+" ]\t/\t"+original+"\t"+p); | ||
} else { | ||
console.log("[ "+dateTime.create().format('Y-m-d H:M:S')+" ]\t/\t"+original+">>"+idResponse['global']+"\t"+p); | ||
} | ||
|
||
connection.collection(conf.collection).find( {"subject.@id" : idResponse['global'] }).toArray(function (mongoError, mongoResponse) { | ||
res.render('clientbased',{jarray: mongoResponse, subject: idResponse['global'], predicate: p, | ||
source: src, util: util, conf: conf, locals: idResponse['locals'] }); | ||
}) | ||
|
||
}).catch(function (idError) { | ||
console.log("[ "+dateTime.create().format('Y-m-d H:M:S')+" ]\t/\t"+original+"\t"+p+"\tunmanaged id"); | ||
|
||
connection.collection(conf.collection).find( {"subject.@id" : s }).toArray(function (mongoError, mongoResponse) { | ||
res.render('clientbased',{jarray: mongoResponse, subject: s, predicate: p, | ||
source: src, util: util, conf: conf, locals: [s] }); | ||
}) | ||
}); | ||
|
||
|
||
}); | ||
|
||
|
||
app.get('/raw', function(req, res) { | ||
|
||
var s = req.query.s; | ||
var p = req.query.p; | ||
var src = req.query.src; | ||
|
||
if( s == null ) s = conf.default_subject; | ||
if( p == null ) p = conf.default_predicate; | ||
if( src == null ) src = "general"; | ||
|
||
var locals = [s]; | ||
|
||
getJSON(conf.id_management+s).then( function (idResponse) { | ||
console.log("[ "+dateTime.create().format('Y-m-d H:M:S')+" ]\t/\t"+s+"\t"+p); | ||
s = idResponse['global']; | ||
locals = idResponse['locals']; | ||
}).catch(function (idError) { | ||
console.log("[ "+dateTime.create().format('Y-m-d H:M:S')+" ]\t/\t"+s+"\t"+p+"\tunmanaged id"); | ||
}); | ||
|
||
connection.collection(conf.collection).find( {"subject.@id" : s }).toArray(function (mongoError, mongoResponse) { | ||
res.send(JSON.stringify({jarray: mongoResponse, subject: s, predicate: p, source: src})); | ||
}); | ||
}); | ||
|
||
app.get('/label', function (req,res) { | ||
|
||
var s = req.query.s; | ||
|
||
//TODO better conf | ||
var p = conf.default_predicate; | ||
|
||
if( s == null ) s = conf.default_subject; | ||
|
||
console.log("[ "+dateTime.create().format('Y-m-d H:M:S')+" ]\t/label\t"+s); | ||
|
||
connection.collection(conf.collection) | ||
.find( { "subject.@id" : s, "predicate.@id" : p } ) | ||
.project( { "objects.object.@value" :1, _id: 0 } ) | ||
.toArray(function (mongoError, mongoResponse) { | ||
res.send(JSON.stringify(mongoResponse)); | ||
}) | ||
}); | ||
|
||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
var app = require('../app'); | ||
|
||
var debug = require('debug')('fusion-wiki:server'); | ||
var http = require('http'); | ||
|
||
var conf = require('../config') | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
|
||
// var port = normalizePort(process.env.PORT || process.argv[2]); | ||
var port = normalizePort(process.env.PORT || conf.expose_port); | ||
app.set('port', port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
var server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port, '0.0.0.0'); | ||
server.on('error', onError); | ||
server.on('listening', onListening); | ||
console.log('listen on 0.0.0.0:'+port); | ||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
var port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error; | ||
} | ||
|
||
var bind = typeof port === 'string' | ||
? 'Pipe ' + port | ||
: 'Port ' + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(bind + ' requires elevated privileges'); | ||
process.exit(1); | ||
break; | ||
case 'EADDRINUSE': | ||
console.error(bind + ' is already in use'); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
var addr = server.address(); | ||
var bind = typeof addr === 'string' | ||
? 'pipe ' + addr | ||
: 'port ' + addr.port; | ||
debug('Listening on ' + bind); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
expose_port: "9005", | ||
|
||
mongo_url: "mongodb://readonly:[email protected]:8989/prefusion", | ||
database_name: "prefusion", | ||
collection: "provenance", | ||
|
||
id_management: "https://global.dbpedia.org/same-thing/lookup/?uri=", | ||
|
||
preference: "wikidata.dbpedia.org,en.dbpedia.org,de.dbpedia.org,fr.dbpedia.org,nl.dbpedia.org,sv.dbpedia.org", | ||
|
||
default_subject: "https://global.dbpedia.org/id/4KKSo", | ||
default_predicate: "http://www.w3.org/2000/01/rdf-schema#label" | ||
}; |
Oops, something went wrong.