def setUp(self):
     self.__simpleNormalization = SimpleNormalization()
     self.__dirPath = os.path.abspath(os.curdir)
     self.__normalizeWords = [
         "thi", "test", "file", "encod", "проверк", "определен", "кодировк",
         "фа"
     ]
class TestSimpleNormalization(unittest.TestCase):

    def setUp(self):
        self.__simpleNormalization = SimpleNormalization()
        self.__dirPath = os.path.abspath(os.curdir)
        self.__normalizeWords = ["thi", "test", "file", "encod", "проверк", "определен", "кодировк", "фа"]

    def testNormalizeText(self):
        filePath = os.path.join(self.__dirPath, "resources/test_encode_utf8")
        with open(filePath) as utf8File:
            words = self.__simpleNormalization.normalizeText(utf8File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords, "not normalized test_encode_utf8")

        filePath = os.path.join(self.__dirPath, "resources/test_encode_win1251")
        with open(filePath) as win1251File:
            words = self.__simpleNormalization.normalizeText(win1251File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords, "not normalized test_encode_win1251")

        filePath = os.path.join(self.__dirPath, "resources/test_encode_win866")
        with open(filePath) as win866File:
            words = self.__simpleNormalization.normalizeText(win866File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords, "not normalized test_encode_win866")

    def testNormalizeTextParamError(self):
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText, None)
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText, "")
 def setUp(self):
     self.__mongoUtils = MongoSaveUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                        FC_DN, MDN)
     self.__simpleNormal = SimpleNormalization()
     self.__fileSourceCustom = FileSourceCustom()
     self.__fileBlockSource = FileBlockSource()
     self.__calcMongo = CalcMongo()
     self.__mongoStatistics = MongoStatistic(self.__mongoUtils)
     self.__dirPath = os.path.abspath(os.curdir)
class TestSimpleNormalization(unittest.TestCase):
    def setUp(self):
        self.__simpleNormalization = SimpleNormalization()
        self.__dirPath = os.path.abspath(os.curdir)
        self.__normalizeWords = [
            "thi", "test", "file", "encod", "проверк", "определен", "кодировк",
            "фа"
        ]

    def testNormalizeText(self):
        filePath = os.path.join(self.__dirPath, "resources/test_encode_utf8")
        with open(filePath) as utf8File:
            words = self.__simpleNormalization.normalizeText(utf8File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords,
                              "not normalized test_encode_utf8")

        filePath = os.path.join(self.__dirPath,
                                "resources/test_encode_win1251")
        with open(filePath) as win1251File:
            words = self.__simpleNormalization.normalizeText(
                win1251File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords,
                              "not normalized test_encode_win1251")

        filePath = os.path.join(self.__dirPath, "resources/test_encode_win866")
        with open(filePath) as win866File:
            words = self.__simpleNormalization.normalizeText(win866File.read())
            for itemWord in words:
                self.assertIn(itemWord, self.__normalizeWords,
                              "not normalized test_encode_win866")

    def testNormalizeTextParamError(self):
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText,
                          None)
        self.assertRaises(ParamError, self.__simpleNormalization.normalizeText,
                          "")
 def setUp(self):
     self.__dirPath = os.path.abspath(os.curdir)
     firstPath = os.path.join(self.__dirPath, "resources/first")
     secondPath = os.path.join(self.__dirPath, "resources/second")
     self.__mongoSaveUtils = MongoSaveRetrievalUtils(
         HOST, PORT, USR, PWD, DB, FC_N, FC_DN, MDN)
     self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                            FC_DN)
     self.__simN = SimpleNormalization()
     self.__simNamesN = FileNameNormalization()
     self.__ms = StatisticFactory().createStatistic(MONGO_TYPE,
                                                    self.__mongoSaveUtils)
     self.__scc = FSSourceCustomCallback()
     self.__rnFS = ReaderNameFS([firstPath, secondPath])
Exemple #6
0
 def setUp(self):
     self.__dirPath = os.path.abspath(os.curdir)
     firstPath = os.path.join(self.__dirPath, "resources/first")
     secondPath = os.path.join(self.__dirPath, "resources/second")
     self.__mongoUtils = MongoSaveRetrievalUtils(HOST, PORT, USR, PWD, DB,
                                                 FC_N, FC_DN, MDN)
     self.__mongoUtilsTypeError = MongoSaveUtils(HOST, PORT, USR, PWD, DB,
                                                 FC_N, FC_DN, MDN)
     self.__mongoReadUtils = MongoReadUtils(HOST, PORT, USR, PWD, DB, FC_N,
                                            FC_DN)
     self.__smN = SimpleNormalization()
     self.__scc = FSSourceCustomCallback()
     self.__rFS = ReaderNameFS([firstPath, secondPath])
     self.__fsWorker = DataSourceWorkerFS()
Exemple #7
0
 def testParseQ(self):
     smN = SimpleNormalization()
     parseList = self.spq.parseQ("testing q q q q testing", None, smN)
     self.assertEqual(parseList[0], TYPE_Q_FULL)
     self.assertListEqual(parseList[1], ["test", "q"])
 def setUp(self):
     self.__simpleNormalization = SimpleNormalization()
     self.__dirPath = os.path.abspath(os.curdir)
     self.__normalizeWords = ["thi", "test", "file", "encod", "проверк", "определен", "кодировк", "фа"]