def test_normalRun(self):
        # set up
        db = SUDBConnect()
        sponsorsList = []
        descriptionList = []
        ocList = []
        iefaLeadTrainingIdList = []
        actualBad = []
        concatenatedDescriptionOCList = []
        rows = db.getRowsDB("select * from dbo.IefaLeadsTrainingItems where BadScholarship!='Maybe'")
        for row in rows:
            sponsorsList.append(row.Sponsor)
            descriptionList.append(row.Description)
            ocList.append(row.OtherCriteria)
            actualBad.append(row.BadScholarship)
            iefaLeadTrainingIdList.append(str(row.IefaLeadTrainingId))

        for i in range(len(descriptionList)):
            conatenatedItem = '%s %s' % (descriptionList[i], ocList[i])
            concatenatedDescriptionOCList.append(conatenatedItem)

        # test
        testNER = ClassifyBadScholarships(sponsorsList, concatenatedDescriptionOCList)
        predictedBad = testNER.loopThroughLeadsAndDoStuff()

        accuracy = ComputeAccuracy(actualBad, predictedBad).calculateAccuracy()
        print(accuracy)

        # put result in db
        for i in range(len(predictedBad)):
            iefaLeadTrainingId = iefaLeadTrainingIdList[i]
            predicted = predictedBad[i]
            db.insertUpdateOrDeleteDB(
                "update dbo.IefaLeadsTrainingItems set NormalTestPredictedTag='" + predicted + "' where IefaLeadTrainingId='" + iefaLeadTrainingId + "'")
    def test_infoTextOnlyNoInsert(self):
        # set up
        db = SUDBConnect()
        sponsorsList = []
        descriptionList = []
        ocList = []
        iefaLeadTrainingIdList = []
        actualBad = []
        concatenatedDescriptionOCList = []
        rows = db.getRowsDB("select * from dbo.IefaLeadsTrainingItems where BadScholarship!='Maybe'")
        for row in rows:
            sponsorsList.append(row.Sponsor)
            descriptionList.append(row.Description)
            ocList.append(row.OtherCriteria)
            actualBad.append(row.BadScholarship)
            iefaLeadTrainingIdList.append(str(row.IefaLeadTrainingId))

        for i in range(len(descriptionList)):
            conatenatedItem = '%s %s' % (descriptionList[i], ocList[i])
            concatenatedDescriptionOCList.append(conatenatedItem)

        # test
        testNER = ClassifyBadScholarships(sponsorsList, concatenatedDescriptionOCList, test='infoTextOnly')
        infoTextPredictedBad = testNER.loopThroughLeadsAndDoStuff()

        accuracy = ComputeAccuracy(actualBad, infoTextPredictedBad).calculateAccuracy()
        print(accuracy)
 def checkBadScholarship(leadArray, fundingClassification):
     if fundingClassification == 'Scholarship':
         sponsor = leadArray[4]
         infoText = '%s %s %s' % (leadArray[3], leadArray[6], leadArray[7])
         badScholarshipClassifier = ClassifyBadScholarships()
         badScholarshipPrediction = badScholarshipClassifier.classifyOpportunity(sponsor, infoText)
         return badScholarshipPrediction
     else:
         return ''
示例#4
0
 def checkBadScholarship(leadArray, fundingClassification):
     if fundingClassification == 'Scholarship':
         sponsor = leadArray[4]
         infoText = '%s %s' % (leadArray[7], leadArray[8])
         badScholarshipClassifier = ClassifyBadScholarships()
         badScholarshipPrediction = badScholarshipClassifier.classifyOpportunity(sponsor, infoText)
         return badScholarshipPrediction
     else:
         return ''
    def test_checkSponsorBadInstitutions(self):
        nertest = ClassifyBadScholarships(['blah'], ['blah'])

        sponsor1 = 'University of Arizona'
        testSponsor1 = nertest.checkBadSponsor(sponsor1)
        self.assertFalse(testSponsor1)

        sponsor2 = 'University of Colorado'
        testSponsor2 = nertest.checkBadSponsor(sponsor2)
        self.assertTrue(testSponsor2)

        sponsor3 = 'Chicken and Egg Group'
        testSponsor3 = nertest.checkBadSponsor(sponsor3)
        self.assertFalse(testSponsor3)

        sponsor4 = 'School of Bacon'
        testSponsor4 = nertest.checkBadSponsor(sponsor4)
        self.assertTrue(testSponsor4)
示例#6
0
 def getPredictedBad(self):
     predictedBad = ClassifyBadScholarships(
         self.sponsorList, self.infoTextList).loopThroughLeadsAndDoStuff()
     return predictedBad
    def test_CheckBadTextRewrite(self):
        nertest = ClassifyBadScholarships(['blah'], ['blah'])

        infoText = 'CollegeWeekLive gives away $1,000 per month just for viewing and visiting US colleges online. Winning is easy - all you need to do is login to CollegeWeekLive and visit 3 colleges that interest you. One lucky winner will be awarded a $1,000 scholarship every month. And many other winners may find the college of their dreams.'
        testText = nertest.checkBadText(infoText)
    def test_CheckBadText(self):
        nertest = ClassifyBadScholarships(['blah'], ['blah'])

        infoText = 'I go to the University of Arizona in Tucson, Arizona'
        testText = nertest.checkBadText(infoText)
        self.assertFalse(testText)