Exemple #1
0
class Application(object):
    """
        This just stores a pipeline object and makes sure
        the given temporary directory exists.  (only used for
        testing the speech recognition miner independently)
    """
    def __init__(self, tmpDir):
        # Check if temp directory exists, if not create it.
        if not os.path.exists(tmpDir):
            os.makedirs(tmpDir)

        # Store path to temp directory
        self.tmpDir = tmpDir
        # Create pipeline
        self.pl = Pipeline()

    def acquireAndBuildCorpus(self, acquireTag, minerTag, corpusTag, *acquireArgs):
        # Call the pipeline function
        self.pl.acquireAndBuildCorpus(acquireTag, minerTag, corpusTag, *acquireArgs)

    def clean(self):
        # Delete all files in temp directory
        for f in os.listdir(self.tmpDir):
            fpath = os.path.join(self.tmpDir, f)
            try:
                if os.path.isfile(fpath):
                    os.unlink(fpath)
            except Exception as e:
                print e


    def clear(self):
        # Clear and delete the temp directory
        rmtree(self.tmpDir)