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')
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())
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())
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')
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)
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
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)
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(' ', '', StripApostrophe) JoinEligibilitytoString = Stripnbsp Eligibility = JoinEligibilitytoString testMajors = Majors(Eligibility, ScholarshipIds[e], MajorOptions) print(Eligibility) print(testMajors.getMajors()) print('\n\n')
def test_MajorsNoScholarshipPackageIdSpecified(self): testSPRFnoSPISpecified = Majors( 'This scholarship is for creative writing majors', MajorOptions) self.assertIsNotNone(testSPRFnoSPISpecified) self.assertEqual('0', testSPRFnoSPISpecified.scholarshipPackageId)
def doMajorsParser(self, eligibility, scholarshipId): parseMajors = Majors(eligibility, scholarshipId, Majors.majorsRegexForTesting()) if parseMajors.getMajors() != '': # print(parseMajors.getMajors()) # print(parseMajors.getScholarshipPackageRequirementFormat().getStringValue()) return parseMajors.getScholarshipPackageRequirementFormat()
def doMajorsParser(self): for line in self.textLines: parseMajors = Majors(line, Majors.majorsRegexForTesting()) if parseMajors.getMajors() != '': return parseMajors.getScholarshipPackageRequirementFormat()