'''
@author mojosaurus
Technically, spellcheck is not a tagger. It works on the tags generated by language tagger. 
Don't use this before languagetagger is used
'''

import os,sys
# Appeding our src directory to sys path so that we can import modules.
sys.path.append(os.path.join(os.path.dirname(__file__),'../../..'))
from src.tn.document.document import Document
from src.tn.docproc.pipeline import Tagger
from src.tn.document.spellcheckhelper import SpellCheckHelper

class SpellCheckTagger(Tagger):
    def __init__(self, document=Document()):
        self.document = document
        self.helper = SpellCheckHelper()
        print ("Inside object of type : {}".format(self.__class__.__name__))

    # This is where the magix is done.
    def execute(self):
        print ("Before processing : {} :  {}".format(self.__class__.__name__, self.document))
        tagged = self.helper.correct(self.document)
        self.document.set("tagged", tagged)
        print ("After processing : {} :  {}".format(self.__class__.__name__, self.document))