from saper.utils.chunker import Chunker
from flow_elem import FlowElem
__author__ = 'blaz'


class Iobber(FlowElem):
    """
    The Iobber flow elem is used for adding phrase annotations.
    """
    def __init__(self, config):
        iobber_config_path = config.get('iobber','config')
        iobber_model_path = config.get('iobber', 'model')
        self.chunker = Chunker(iobber_config_path, iobber_model_path)

    def feed_flow(self, document):
        """
        It preforms the chunking process on the given document and returns 
        the updated chunked document.

        @type document: corpus2.Document
        @rtype: corpus2.Document
        """
        return self.chunker.chunking_document(document, update = True)
