def svm_rank_classify(features, model, predictions): logging.info(('==' * 10 + '%s' + '==' * 10) % ('START SVM CLASSIFING')) svm_rank_classify_format = '%s %s %s %s' cmd_text = svm_rank_classify_format % ( SVM_RANK.svm_rank_classify_command, features, model, predictions) logging.debug(cmd_text) os.system(cmd_text)
def svm_rank_learn(features, output_model, args=''): logging.info(('==' * 10 + '%s' + '==' * 10) % ('START SVM LEARNING')) svm_rank_learn_format = '%s %s %s %s' cmd_text = svm_rank_learn_format % (SVM_RANK.svm_rank_learn_command, args, features, output_model) logging.debug(cmd_text) os.system(cmd_text)
def __get_question_id_group(self): """ :return: tuple(question1_id, question2_id, ...) """ question_id_group = re.findall(find_question_regex, self.page_source_code) if question_id_group: logging.debug("Parse Question Success!") return tuple(zip(*question_id_group)[0]) else: logging.debug("find_question_regex:%s" % find_question_regex) logging.error("Can not find question on page source code.") self.error_message = u"无法解析问题" return ()
def _load_question_bank_unicode(online_question_bank_url=online_question_bank_url, callback=None): """ :return: List [item1, item2, ...] item = { "id": "1010", "answer": "A", "options": [ { "text": "OptionsA", "name": "A" }, { "text": ""OptionsB, "name": "B" }, { "text": "OptionsC", "name": "C" }, { "text": "OptionsD", "name": "D" } ], "title": "qustion_text" } """ try: r = requests.get(url=online_question_bank_url, timeout=15) if r.status_code != 200: logging.debug("online_bank_status_code:%s" % r.status_code) raise ConnectionError else: logging.debug("Load online bank success!") question_bank_temp = r.content except Exception, e: logging.error("Load online bank fail;Error:%s" % e.message) logging.debug("Load local bank...") question_bank_temp = local_question_bank.get()
def __get_answer_choice_group(self): """ :return: list [answer1, answer2, ...] """ if not self.question_id_group: return [] logging.debug(self.question_id_group) __answer_item_group = map(self.__find_answer, self.question_id_group) logging.debug("answer_item_group:{}".format(__answer_item_group)) __answer_choice_group = map(lambda x: x["answer"] if x else "X", __answer_item_group) logging.debug("answer_choice_group:{}".format(__answer_choice_group)) return __answer_choice_group
def __set_question_bank(question_bank): cls.question_bank = question_bank logging.debug("use online question bank instead of local bank!")
def get_auto_select_answer_script(self): if not self.parse_page_status: return "" logging.debug( select_answer_script_template % (",".join(self.question_id_group), ",".join(self.answer_choice_group))) return select_answer_script_template % (",".join(self.question_id_group), ",".join(self.answer_choice_group))
def svm_rank_learn(features, output_model, args = '') : logging.info(('=='*10 + '%s' + '=='*10) % ( 'START SVM LEARNING')) svm_rank_learn_format = '%s %s %s %s' cmd_text = svm_rank_learn_format % (SVM_RANK.svm_rank_learn_command, args, features, output_model) logging.debug(cmd_text) os.system(cmd_text)
def svm_rank_classify(features, model, predictions): logging.info(('=='*10 + '%s' + '=='*10) % ( 'START SVM CLASSIFING')) svm_rank_classify_format = '%s %s %s %s' cmd_text = svm_rank_classify_format % (SVM_RANK.svm_rank_classify_command, features, model, predictions) logging.debug(cmd_text) os.system(cmd_text)