Ejemplo n.º 1
0
 def test_Majors(self):
     testmajors = Majors('You must be a linguistics major', MajorOptions, '5')
     self.assertIsNotNone(testmajors)
     self.assertEqual(True,
                      testmajors.checkContext(
                          'enrolled in|majoring in|program|major|concentration|pursuing|student'))
     self.assertEqual(testmajors.getMajors(), 'linguistics')
Ejemplo n.º 2
0
 def test_Majorsfailure(self):
     failmajors = Majors('I really like plant science', MajorOptions, '5')
     self.assertIsNotNone(failmajors)
     self.assertEqual(False,
                      failmajors.checkContext(
                          'enrolled in|majoring in|program|major|concentration|pursuing|student'))
     self.assertNotEqual('plant science', failmajors.getMajors())
     self.assertEqual('', failmajors.getMajors())
Ejemplo n.º 3
0
 def test_Majorsfailure(self):
     failmajors = Majors('I really like plant science', MajorOptions, '5')
     self.assertIsNotNone(failmajors)
     self.assertEqual(
         False,
         failmajors.checkContext(
             'enrolled in|majoring in|program|major|concentration|pursuing|student'
         ))
     self.assertNotEqual('plant science', failmajors.getMajors())
     self.assertEqual('', failmajors.getMajors())
Ejemplo n.º 4
0
 def test_Majors(self):
     testmajors = Majors('You must be a linguistics major', MajorOptions,
                         '5')
     self.assertIsNotNone(testmajors)
     self.assertEqual(
         True,
         testmajors.checkContext(
             'enrolled in|majoring in|program|major|concentration|pursuing|student'
         ))
     self.assertEqual(testmajors.getMajors(), 'linguistics')
Ejemplo n.º 5
0
 def test_MajorsCreateSPRFClass(self):
     testSPRFforMajors = Majors('You must be a Japanese major in order to make this SPRF class work.', MajorOptions,
                                '2947')
     self.assertIsNotNone(testSPRFforMajors)
     self.assertEqual(True, testSPRFforMajors.checkContext(
         'enrolled in|majoring in|program|major|concentration|pursuing|student'))
     self.assertEqual('japanese', testSPRFforMajors.getMajors())
     self.assertIsNotNone(testSPRFforMajors.getScholarshipPackageRequirementFormat())
     test_SPRF = testSPRFforMajors.getScholarshipPackageRequirementFormat()
     self.assertEqual('2947', test_SPRF.scholarshipPackageId)
     self.assertEqual('417', test_SPRF.attributeId)
     self.assertEqual('*', test_SPRF.requirementType)
     self.assertEqual('japanese', test_SPRF.requirementValue)
     self.assertEqual('0', test_SPRF.logicGroup)
Ejemplo n.º 6
0
    def getMajorFromSentences(self, sentences):
        majors = []

        majorsList = GetFastFindMajorsList.getDefaultList()
        majorsList = [major.lower() for major in majorsList]
        majorsList = list(set(majorsList))

        majorsListRegex = '|'.join(majorsList)

        for sentence in sentences:
            if len(sentence) <= 1000:
                maybeMajor = Majors(sentence, majorsListRegex).getMajors()
                if maybeMajor != '':
                    majors.append(maybeMajor)

        majors = list(set(majors))
        majors = ', '.join(majors)

        return majors
Ejemplo n.º 7
0
 def test_MajorsCreateSPRFClass(self):
     testSPRFforMajors = Majors(
         'You must be a Japanese major in order to make this SPRF class work.',
         MajorOptions, '2947')
     self.assertIsNotNone(testSPRFforMajors)
     self.assertEqual(
         True,
         testSPRFforMajors.checkContext(
             'enrolled in|majoring in|program|major|concentration|pursuing|student'
         ))
     self.assertEqual('japanese', testSPRFforMajors.getMajors())
     self.assertIsNotNone(
         testSPRFforMajors.getScholarshipPackageRequirementFormat())
     test_SPRF = testSPRFforMajors.getScholarshipPackageRequirementFormat()
     self.assertEqual('2947', test_SPRF.scholarshipPackageId)
     self.assertEqual('417', test_SPRF.attributeId)
     self.assertEqual('*', test_SPRF.requirementType)
     self.assertEqual('japanese', test_SPRF.requirementValue)
     self.assertEqual('0', test_SPRF.logicGroup)
Ejemplo n.º 8
0
    ScholarshipIds.append(row.ScholarshipPackageId)

for e in range(len(Eligibilities)):
    Eligibility = Eligibilities[e]
    print(ScholarshipIds[e])

    FormattedEligibilities = []
    StripULTag = re.sub('<ul>|</ul>', '', Eligibility)
    Eligibility = StripULTag
    IndividualEligibilities = Eligibility.split('</li>')
    for IndividualEligibility in IndividualEligibilities:
        IndividualEligibility.strip('\r')
        IndividualEligibility.strip('\n')
        StripXMLTags = re.sub('<\/*[a-z]*\s*\/*>', '', IndividualEligibility)
        #need to remove the xml tags first (specificially the end of line) or else the next one will capture the whole
        #string and delete it
        StripRemainingTags = re.sub('<.*>', '', StripXMLTags)
        IndividualEligibility = StripRemainingTags
        FormattedEligibilities.append(IndividualEligibility)

    JoinEligibilitytoString = ', '.join(FormattedEligibilities)
    StripApostrophe = re.sub('\'*\"*', '', JoinEligibilitytoString)
    Stripnbsp = re.sub('&nbsp;', '', StripApostrophe)
    JoinEligibilitytoString = Stripnbsp

    Eligibility = JoinEligibilitytoString

    testMajors = Majors(Eligibility, ScholarshipIds[e], MajorOptions)
    print(Eligibility)
    print(testMajors.getMajors())
    print('\n\n')
Ejemplo n.º 9
0
 def test_MajorsNoScholarshipPackageIdSpecified(self):
     testSPRFnoSPISpecified = Majors(
         'This scholarship is for creative writing majors', MajorOptions)
     self.assertIsNotNone(testSPRFnoSPISpecified)
     self.assertEqual('0', testSPRFnoSPISpecified.scholarshipPackageId)
Ejemplo n.º 10
0
 def doMajorsParser(self, eligibility, scholarshipId):
     parseMajors = Majors(eligibility, scholarshipId, Majors.majorsRegexForTesting())
     if parseMajors.getMajors() != '':
         # print(parseMajors.getMajors())
         # print(parseMajors.getScholarshipPackageRequirementFormat().getStringValue())
         return parseMajors.getScholarshipPackageRequirementFormat()
Ejemplo n.º 11
0
    ScholarshipIds.append(row.ScholarshipPackageId)

for e in range(len(Eligibilities)):
    Eligibility = Eligibilities[e]
    print(ScholarshipIds[e])

    FormattedEligibilities = []
    StripULTag = re.sub('<ul>|</ul>', '', Eligibility)
    Eligibility = StripULTag
    IndividualEligibilities = Eligibility.split('</li>')
    for IndividualEligibility in IndividualEligibilities:
        IndividualEligibility.strip('\r')
        IndividualEligibility.strip('\n')
        StripXMLTags = re.sub('<\/*[a-z]*\s*\/*>', '', IndividualEligibility)
        #need to remove the xml tags first (specificially the end of line) or else the next one will capture the whole
        #string and delete it
        StripRemainingTags = re.sub('<.*>', '', StripXMLTags)
        IndividualEligibility = StripRemainingTags
        FormattedEligibilities.append(IndividualEligibility)

    JoinEligibilitytoString = ', '.join(FormattedEligibilities)
    StripApostrophe = re.sub('\'*\"*', '', JoinEligibilitytoString)
    Stripnbsp = re.sub('&nbsp;', '', StripApostrophe)
    JoinEligibilitytoString = Stripnbsp

    Eligibility = JoinEligibilitytoString

    testMajors = Majors(Eligibility, ScholarshipIds[e], MajorOptions)
    print(Eligibility)
    print(testMajors.getMajors())
    print('\n\n')
Ejemplo n.º 12
0
 def doMajorsParser(self):
     for line in self.textLines:
         parseMajors = Majors(line, Majors.majorsRegexForTesting())
         if parseMajors.getMajors() != '':
             return parseMajors.getScholarshipPackageRequirementFormat()