def checkYear(self): findYear = Parser(self.stringToScan.lower(), '1st|2nd|3rd|4th|5th|6th') if findYear.doesMatchExist(): years = [] for i in findYear.getResult(): years.append('%s Year' % i) return years
def getMajors(self): if self.checkContext( 'enrolled in|majoring in|program|major|concentration|pursuing|student|study\sof') and self.doesMatchExist(): for i in self.getResult(): self.resultList.append(i) if self.checkContext('of\sscience|of\sarts|of\smedicine') and self.doesMatchExist(): if 'science' in self.resultList: self.resultList.remove('science') if 'arts' in self.resultList: self.resultList.remove('arts') if 'medicine' in self.resultList: self.resultList.remove('medicine') if self.checkContext('engineering'): tokenizeEngineeringString = re.findall(r"[\w']+", self.stringToScan) for i in range(len(tokenizeEngineeringString)): if tokenizeEngineeringString[i] == 'engineering': engineeringContextSlice = tokenizeEngineeringString[i - 5:i] concatenateEngineeringWithWord = [] for i in engineeringContextSlice: concatenateEngineeringWithWord.append('%s engineering' % i) for i in concatenateEngineeringWithWord: checkEngineeringMajors = Parser(i, self.majorsRegex) if checkEngineeringMajors.doesMatchExist(): for i in checkEngineeringMajors.getResult(): self.resultList.append(i) if 'engineering' in self.resultList: self.resultList.remove('engineering') self.resultList = list(set(self.resultList)) self.major = ', '.join(self.resultList) return self.major
def getEmploymentStatus(self): if self.checkContext('work|employ|job'): if self.doesMatchExist(): for i in self.getResult(): self.resultList.append(i) elif self.checkContext('hour'): findHours = Parser(self.stringToScan, '\d{1,2}') if findHours.doesMatchExist(): for i in findHours.getResult(): self.resultList.append('%s Hours' % i) self.resultList = list(set(self.resultList)) return self.resultList
def test_Parser(self): testparser = Parser('This is a test', 'test') self.assertIsNotNone(testparser) self.assertEqual(testparser.doesMatchExist(), True) self.assertEqual(testparser.getResult(), ['test'])
def test_ParserFailure(self): failparser = Parser('This test should return false', 'chicken') self.assertIsNotNone(failparser) self.assertEqual(failparser.doesMatchExist(), False)
def checkContext(self, contextRegex): contextChecker = Parser(self.stringToScan.lower(), contextRegex) return contextChecker.doesMatchExist()
def checkContext(self, contextCriteria): contextChecker = Parser(self.stringToScan.lower(), contextCriteria) return contextChecker.doesMatchExist()
def checkGraduate(self): if not self.checkContext('graduate\sfrom|graduates'): findGraduate = Parser(self.stringToScan.lower(), '^graduate|\sgraduate') if findGraduate.doesMatchExist(): return ['graduate']
def checkDueDateContext(self): contextRegex = 'due\sdate|application\swindow|deadline|dead\sline|close\sdate|close|closing\sdate' contextChecker = Parser(self.stringToScan.lower(), contextRegex) return contextChecker.doesMatchExist()