# -*- coding: utf-8 -*-
'''
Created on Dec 10, 2010

@author: boban
'''

class AbstractProcessor(object):
	"""
	Abstract class for processing multiple triples generators.
	"""
	
	def __init__(self):
		"""
		Arguments:
		- token_filter - a function that returns true if given token should be kept
		"""
		self.data = {} # (l,rel,r) -> count
		
	def process(self, triples_generator):
		"""
		Adds or 'relation' triples from the given document.
		"""
		raise NotImplementedError
	
	def dump(self, filename):
		"""
		Writes data to simple CSV file.

		File format:
		head;relation;modifier;count 
		"""
		raise NotImplementedError
	
	def extend(self, data):
		"""
		Adds all the data gather by someone else to this objects dataset
		"""
		for k in data:
			if k in self.data:
				self.data[k] += data[k]
			else:
				self.data[k] = data[k]