Giter Club home page Giter Club logo

gazcomp's Introduction

gazComp

gazComp is a web application used to compare gazetteers with a human brain. Currently two gazetteer sources can be compared, Pleiades and Geonames.

gazComp's architecture allows for other gazetteer sources to be defined. See the following classes in src/js/gazComp.js

  • gazComp.Data
  • gazComp.GeonamesData
  • gazComp.PleiadesData

Requirements

  • jQuery
  • Google Maps API

Installation

Create an HTML document with an empty <body> tag pair. Include the required Javascript and CSS files.

<link href="gazComp/src/css/gazComp.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="gazComp/src/js/gazComp.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=#{API_Key}&sensor=false"></script>

Use

Initialize gazComp.App passing along the URL to the server-side script which will receive data generated by gazComp.

var gaz = new gazComp.App( '#{path_to_your_server_script}' );

Call the compare method passing along two data sources. Data sources are instances of classes that extend gazComp.Data.

gaz.compare( new gazComp.GeonamesData( '2343234' ), new gazComp.PleiadesData( '83473298' ) );

Define a new gazComp collection class.

gazComp collection classes extend gazComp.Data. Collection classes are interfaces to retrieve data from specific gazetteer collections, for example Geonames http://www.geonames.org/ and Pleiades http://pleiades.stoa.org/.

Each class must define a custom get() method to retrieve data from the collection. The class must also define a custom convert() method to change retrieved data into a standardized gazComp data object.

How to write your own.

The constructor creates a gazComp.Data object and specifies the URL where data can be retrieved.

/**
 * Collection data retrieval and conversion
 *
 * @param { String } _id Collection gazetteer id
 */
gazComp.CollectionData = function( _id ) {
	this.data = new gazComp.Data( "Geonames", _id);
	this.url = 'http://path-to-da.ta/json/'
}

Make the required ajax calls to retrieve all gazetteer data. Chain them together if you have to, but if all goes well call the convert method.

gazComp.GeonamesData.prototype.get = function() {
	var self = this;
	$.ajax({
		type: 'GET',
		url: self.url + self.data.id,
		timeout: 5000,
		dataType: 'json',
		success: function( _data ) { self.convert( _data ) },
		error: function( _data, _error, _opt ) {
			$( document ).trigger( self.data.error, [ _error, _opt ] );
		}
	});
}

The convert function creates a json object, this.data.clean, that specifies common gazetteer key-value pairs. At the end of your conversion code make sure you trigger the data ready event.

gazComp.GeonamesData.prototype.convert = function( _data ) {
	var self = this;
	self.data.src = _data;
	//------------------------------------------------------------
	//  Coords
	//------------------------------------------------------------
	self.data.clean.coords = [ _data.reprPoint[0], _data.reprPoint[1] ];
	//------------------------------------------------------------
	//  Names
	//------------------------------------------------------------
	self.data.clean.names = [];
	for ( var i=0, ii=_data.names.length; i<ii; i++ ) {
		self.data.clean.names.push( _data.names[i].name );
	}
	//------------------------------------------------------------
	//  Citations
	//------------------------------------------------------------
	self.data.clean.citations = [];
	for ( var i=0, ii=_data.citations.length; i<ii; i++ ) {
		for ( var key in _data.citations[i] ) {
			self.data.clean.citations.push( _data.citations[i][key] );
		}
	}
	//------------------------------------------------------------
	//  Trigger that the data is ready.
	//------------------------------------------------------------
	$( document ).trigger( self.data.ready );
}

That's about it.

Improvement Wishlist

Code that can look at raw gazetteer data and infer its type so custom convert() methods don't have to be written.

gazcomp's People

Contributors

caesarfeta avatar paregorios avatar ryanfb avatar

Watchers

 avatar

gazcomp's Issues

indicate JSON loading/errors

If Pleiades or GeoNames JSON loading fails, current behavior doesn't really give any feedback to the user. Maybe just reload after a timeout?

disable vote buttons upon click

Not sure what actually happens in current case - is vote actually for all pairs presented, or multiple votes for same pair? In either case, this should be a quick fix for erroneous multiple submission.

expire cookies if parent cite-collection-editor session resets

When the administrator reauthorizes, we should expire the gazComp end-user cookies as well. Probably need to set a session cookie on the cite-colleciton-manager side that we check on the gazComp site and reset our cookies if we have a different session.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.