def __init__(self): self.evaluator = Evaluator.Evaluator() self.parser = Parser() self.converter = Converter.DocConverter() self.scorer = Scorer() self.cv_list = [] self.cv_scores = [] self.setup_evaluators() self.job_function = ""
class Controller(): def __init__(self): self.evaluator = Evaluator.Evaluator() self.parser = Parser() self.converter = Converter.DocConverter() self.scorer = Scorer() self.cv_list = [] self.cv_scores = [] self.setup_evaluators() self.job_function = "" def setup_evaluators(self): language_evaluator = LangEvaluator() skill_evaluator = SkillEvaluator() education_evaluator = EduEvaluator() experience_evaluator = ExpEvaluator() other_evaluator = OtherEvaluator() self.evaluator.add(language_evaluator) self.evaluator.add(skill_evaluator) self.evaluator.add(education_evaluator) self.evaluator.add(experience_evaluator) self.evaluator.add(other_evaluator) def clear(self): self.cv_list = [] self.cv_scores = [] def setup_requirement(self, requirement): self.evaluator.set_requirement(requirement) def set_weight(self, weight): self.scorer.set_weight(weight) def set_job_function(self, job_function): "" def evaluate(self, cvs): self.clear() for cv in cvs: CV_Text = self.converter.documentToText(cv).decode('unicode_escape').encode('ascii','ignore') cvobj = self.parser.convertToObj(CV_Text) #pp.pprint(cvobj) self.cv_list.append(cvobj) self.evaluator.set_cv(cvobj) self.cv_scores.append(self.evaluator.evaluate()) #x.print_rank() def get_scores(self): return self.scorer.cal_all_score(self.cv_scores) def get_cv_list(self): return self.cv_list def get_cv_score(self): return self.cv_scores
from cvClassifier.Classifier import Classifier from cvConverter import Converter from cvParser.Parser import Parser import os __author__ = 'siwei' root_dir_path = os.path.dirname(os.path.abspath(__file__)) converter = Converter.DocConverter() parser = Parser() cl = Classifier() cl.load() to_classify = ["cv/simple.doc"] classified_cv = [] for cv in to_classify: CV_Text = converter.documentToText(root_dir_path+"/"+cv) cvobj = parser.convertToObj(CV_Text) classified_cv.append((cv, cl.classify(cvobj))) print classified_cv