def setUp(self):
     sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
     fileName, pathname, description = imp.find_module('infodens')
     
     from infodens.preprocessor import preprocess
     self.prepObj = preprocess.Preprocess('testFile.txt')
     from infodens.formater import format
     
     from infodens.controller import controller
     self.conObj = controller.Controller('testconfig.txt')
     ch, ids, cl = self.conObj.loadConfig()
     
     from infodens.featurextractor import featureManager
     self.featMgrObj = featureManager.FeatureManager(4,self.conObj.featureIDs, self.conObj.featargs, self.prepObj,1)
     
     self.conObj2 = controller.Controller('testconfig2.txt')
     self.conObj2.loadConfig()
     self.prepObj2 = preprocess.Preprocess('testFile.txt')
     self.featMgrObj2 = featureManager.FeatureManager(4,self.conObj2.featureIDs, self.conObj2.featargs, self.prepObj2, 1)
     
     self.features = self.featMgrObj2.callExtractors()
     self.prepObj3 = preprocess.Preprocess('labelFile.txt')
     self.labels = self.prepObj3.preprocessClassID()
     
     self.X = self.features
     self.y = np.asarray(self.labels)
     self.fmtObj = format.Format(self.X, self.y)
     
     from infodens.classifier import classifierManager
     self.clfMgrObj = classifierManager.ClassifierManager(self.conObj2.classifiersList,self.X, self.y)
    def test_classesSentsMismatch(self):

        from infodens.preprocessor import preprocess
        prepObj = preprocess.Preprocess('testFile.txt')
        from infodens.controller import controller

        conObj = controller.Controller('testconfig.txt')
        prepObj = preprocess.Preprocess('testFile.txt')
        c = False
        ch = conObj.classesSentsMismatch(prepObj)
        self.assertEquals(c, ch)
 def setUp(self):
     sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
     fileName, pathname, description = imp.find_module('infodens')
     from infodens.preprocessor import preprocess
     self.prepObj = preprocess.Preprocess('testFile.txt')
     from infodens.featurextractor import surfaceFeatures
     self.surfObj = surfaceFeatures.SurfaceFeatures(self.prepObj)
 def setUp(self):
     sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
     fileName, pathname, description = imp.find_module('infodens')
     from infodens.preprocessor import preprocess
     self.prepObj = preprocess.Preprocess('testFile.txt')
     from infodens.featurextractor import bagOfNgrams
     self.ngramsObj = bagOfNgrams.BagOfNgrams(self.prepObj)
 def setUp(self):
     sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
     fileName, pathname, description = imp.find_module('infodens')
     from infodens.preprocessor import preprocess
     self.prepObj = preprocess.Preprocess('testFile.txt')
     from infodens.controller import controller
     self.conObj = controller.Controller('testconfig.txt')
     self.conObj2 = controller.Controller('testconfig2.txt')
    def test_parseOutputLine2(self):
        from infodens.preprocessor import preprocess
        prepObj = preprocess.Preprocess('testFile.txt')
        from infodens.controller import controller

        conObj = controller.Controller('testconfig.txt')
        c = 1
        ch = conObj.parseOutputLine('output features: feats.txt format')
        self.assertEquals(c, ch)
    def test_parseOutputLine(self):
        from infodens.preprocessor import preprocess
        prepObj = preprocess.Preprocess('testFile.txt')
        from infodens.controller import controller

        conObj = controller.Controller('testconfig.txt')
        c = 1
        ch = conObj.parseOutputLine('output classifier: report1.txt')
        self.assertEquals(c, ch)
    def setUp(self):
        sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
        fileName, pathname, description = imp.find_module('infodens')
        from infodens.preprocessor import preprocess
        self.prepObj = preprocess.Preprocess('testFile.txt')

        from infodens.controller import controller
        self.conObj = controller.Controller('testconfig.txt')
        ch, ids, cids = self.conObj.loadConfig()

        from infodens.featurextractor import featureManager
        self.featMgrObj = featureManager.FeatureManager(
            4, self.conObj.featureIDs, self.conObj.featargs, self.prepObj, 1)

        self.conObj2 = controller.Controller('testconfig2.txt')
        self.conObj2.loadConfig()
        self.prepObj2 = preprocess.Preprocess('testFile.txt')
        self.featMgrObj2 = featureManager.FeatureManager(
            4, self.conObj2.featureIDs, self.conObj2.featargs, self.prepObj2,
            1)
    def test_manageFeatures(self):

        from infodens.preprocessor import preprocess
        prepObj = preprocess.Preprocess('testFile.txt')
        from infodens.controller import controller

        conObj = controller.Controller('testconfig2.txt')
        ch, ids, cids = conObj.loadConfig()
        c = 1
        ch = conObj.manageFeatures()
        self.assertEquals(c, ch)
Exemple #10
0
    def __init__(self, sentCount, configurator):
        self.featureIDs = configurator.featureIDs
        self.featureArgs = configurator.featargs
        self.preprocessor = preprocess.Preprocess(configurator)
        self.threads = configurator.threadsCount
        self.sentCount = sentCount

        sys.path.append(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
        self.pathname = os.path.dirname(os.path.abspath(feat_extr.__file__))

        # Make class variable
        self.idClassmethod, self.allFeatureIds = self.idClassDictionary()
    def test_loadConfig(self):

        from infodens.preprocessor import preprocess
        prepObj = preprocess.Preprocess('testFile.txt')
        from infodens.controller import controller

        conObj = controller.Controller('testconfig.txt')
        c = 1
        ch, ids, cids = conObj.loadConfig()
        self.assertEquals(c, ch)

        fids = conObj.featureIDs
        chfids = [1, 2, 4, 4, 5, 6, 7, 10, 11]
        self.assertListEqual(fids, chfids)

        clfList = conObj.classifiersList
        chclfList = ['DecisionTree', 'RandomForest', 'SVM']
        self.assertListEqual(clfList, chclfList)

        featArgs = [[], [], '1,10', '2,5', '1,10', '1,10', '1,10', [], []]
        chfeatArgs = conObj.featargs
        self.assertListEqual(featArgs, chfeatArgs)
Exemple #12
0
@author: admin
"""

import unittest
import importlib
import imp, os
import sys, inspect
from os import path
import difflib
import time

sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
fileName, pathname, description = imp.find_module('infodens')
from infodens.preprocessor import preprocess
prepObj = preprocess.Preprocess('testFile.txt')


class Test_preprocess(unittest.TestCase):
    
    def setUp(self):
        sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
        fileName, pathname, description = imp.find_module('infodens')
        from infodens.preprocessor import preprocess
        self.prepObj = preprocess.Preprocess('testFile.txt')
        

    def test_preprocessBySentence(self):
        s = ['This is a boy', 'His name is Audu', 'This is a girl', 'Her name is Sarah']
        ps = self.prepObj.preprocessBySentence()
        self.assertListEqual(s,ps)