function ExtractionResults() {
	this._allCategs = new Array();
	this._categ2isTerm = new Object();
	this._id2categ = new Object();
	this._id2name = new Object();
	this._id2meta = new Object();
	this._feature = new Object();
}

// categ -> Category (Company, PersonPositionCompany...)
// name -> Name + all attributes (format: name\nattr1: val1\nattr2: val2...)
// id -> instance id
// isTerm -> True if the is a term
ExtractionResults.prototype.addResult = function(categ, name, id, isTerm, meta) {
	if (this[categ] == null) {
		this[categ] = new Object();
		this[categ]._allInstances = new Array();
		this._allCategs.push(categ);
	}
	if (this[categ][name] == null) {
		this[categ][name] = new Array();
		this[categ]._allInstances.push(name);
	}
	this[categ][name].push(id);
	this._categ2isTerm[categ] = isTerm;
	this._id2categ[id] = categ;
	this._id2name[id] = name;
	this._id2meta[id] = meta;
}

ExtractionResults.prototype.addTerm = function(categ, name, id, meta) {
	this.addResult(categ, name, id, true, meta);
}

ExtractionResults.prototype.addRelation = function(categ, name, id, meta) {
	this.addResult(categ, name, id, false, meta);
}

ExtractionResults.prototype.addFeature = function(feature, name, score) {
	var topicscore = {};
	topicscore['name'] = name;
	topicscore['score'] = score;
	if (this._feature[feature] == null)
		this._feature[feature] = new Array();
	this._feature[feature].push(topicscore);
}

ExtractionResults.prototype.getFeature = function(feature) {
	return this._feature[feature]?this._feature[feature]:new Array();
}

ExtractionResults.prototype.getCategs = function() {
	return this._allCategs;
}

ExtractionResults.prototype.getCategTerms = function(categ) {
	return this[categ]._allInstances;
}

ExtractionResults.prototype.unifiedTerms = function(categFrom, termFrom, categTo, termTo) {
	this[categTo][termTo].push(this[categFrom][termFrom]);
}

ExtractionResults.prototype.deleteTerm = function(categ, term) {
	delete this[categ][term];
	for (var i=0; i < this[categ]._allInstances.length; i++) {
		if (this[categ]._allInstances[i] == term) {
			this[categ]._allInstances.splice(i,1);
			break;
		}
	}
}

ExtractionResults.prototype.getResult = function(categID, termId) {
	var categName = this._allCategs[categID];
	var categTerms = this.getCategTerms(categName);
	var termName = categTerms[termId];
	return this[categName][termName];
}

ExtractionResults.prototype.getMeta = function(termId) {
	return this._id2meta[termId];
}

ExtractionResults.prototype.sort = function() {
	this._allCategs.sortNoCase();
	for (var i=0; i<this._allCategs.length; i++)
		this[this._allCategs[i]]._allInstances.sortNoCase();
}

ExtractionResults.prototype.isTerm = function(categ) {
	return this._categ2isTerm[categ];
}

ExtractionResults.prototype.isTermID = function(id) {
	return this.isTerm(this._id2categ[id]);
}
